Compare commits

...

17 Commits

Author SHA1 Message Date
Mihai 2a48059186 fix: skip maximise if starting to tray
Signed-off-by: Mihai <cristian@mihaimuresan.com>
2026-03-06 14:48:17 +01:00
stoat-tofu[bot] b57faa2c59 chore: modify .github/workflows/release-webhook.yml 2026-02-18 20:28:00 +00:00
stoat-release[bot] c1e4d4ee91 chore(main): release 1.3.0 (#128)
Co-authored-by: stoat-release[bot] <245062572+stoat-release[bot]@users.noreply.github.com>
2026-02-18 09:09:14 +00:00
Jacob Schlecht ffe17ec2c5 fix: flatpak icons not building correctly and wayland support (#132)
This commit was made without the use of generative AI.

Signed-off-by: Jacob Schlecht <dadadah@echoha.us>
2026-02-18 09:05:56 +00:00
Mihai 63b9ea818a fix: firstLaunch = false after initial setup (#131)
fix: don't re-enable abutostart

Signed-off-by: Mihai <cristian@mihaimuresan.com>
Co-authored-by: Mihai <cristian@mihaimuresan.com>
2026-02-17 22:33:46 -05:00
Paul Makles 58ccb63d23 fix: use template icon for macOS tray, use higher res icons for other platforms (#130) 2026-02-17 20:36:25 +00:00
Mihai 8284117e76 feat: minimise-to-tray-on-startup (#126)
* feat: minimise-to-tray-on-startup

Signed-off-by: Mihai <cristian@mihaimuresan.com>

* feat: minimise-to-tray-on-startup

Signed-off-by: Mihai <cristian@mihaimuresan.com>

* fix: redundant call

Signed-off-by: Mihai <cristian@mihaimuresan.com>

* fix: redundant call

Signed-off-by: Mihai <cristian@mihaimuresan.com>

---------

Signed-off-by: Mihai <cristian@mihaimuresan.com>
Co-authored-by: Mihai <cristian@mihaimuresan.com>
2026-02-17 20:28:29 +00:00
Mihai 897d706983 fix: try to restore maximised windows to correct display (#92)
fix: App-maximized-2nd-monitor

Signed-off-by: Mihai <cristian@mihaimuresan.com>
Signed-off-by: Mihai <45673304+mihaicm93@users.noreply.github.com>
Co-authored-by: Mihai <cristian@mihaimuresan.com>
2026-02-17 20:27:01 +00:00
dxty522 7d2f296ca7 fix: replace default dialog with notification (#98)
Signed-off-by: dxty522 <261609953+dxty522@users.noreply.github.com>
2026-02-17 20:05:26 +00:00
Abel Ortolan 17d6d174ae chore: changing flatpak runtime version to newest stable release (#120)
Update forge.config.ts

Changing Flatpak runtime version from 21.08 (EOL) to 25.08 (newest stable version)

Signed-off-by: Abel Ortolan <70042422+TrojanHorse-bot@users.noreply.github.com>
2026-02-17 20:02:46 +00:00
trendwhore 742a95f3cb fix: toggle window visibility on tray click instead of always showing (#103) 2026-02-17 20:02:17 +00:00
a distraction 2b962c5d06 fix: allow CTRL+"+" to also zoom in. (#108)
Allow "+" to also zoom in.

Signed-off-by: a distraction <106486896+dresklaw@users.noreply.github.com>
Co-authored-by: Paul Makles <me@insrt.uk>
2026-02-17 19:59:18 +00:00
a distraction def29f9b3c fix: Add common zoom-reset shortcut. (#112)
Add common zoom reset shortcut.

Signed-off-by: a distraction <106486896+dresklaw@users.noreply.github.com>
Signed-off-by: marcy <69540471+reeesespuffs@users.noreply.github.com>
Co-authored-by: marcy <69540471+reeesespuffs@users.noreply.github.com>
2026-02-17 14:35:57 -05:00
Paul Makles e2dc20b755 chore: Nix, mise, CI configuration (#129)
* chore: update Nix flake and setup mise for toolchains

* ci: use workflows
2026-02-17 19:29:43 +00:00
Mihai 2e99b19353 feat: Reload/Refresh shortcut (#119)
Signed-off-by: Mihai <cristian@mihaimuresan.com>
Co-authored-by: Mihai <cristian@mihaimuresan.com>
2026-02-17 14:21:57 -05:00
sfalken 1243f88b21 chore: add files to manage flathub details upstream (#104)
* Add files for flathub compliance

Please see: https://github.com/flathub/flathub/pull/7783

This adds the requested files to the upstream git repo, and adds the
screenshot.png so it may be sourced from Stoat, rather than from a user
repository.

* chore: update product screenshot

* chore: update desktop entry comment

* chore: update icon

* chore: update summary to current github tag

---------

Co-authored-by: Shawn W Dunn <sfalken@opensuse.org>
Co-authored-by: izzy <me@insrt.uk>
2026-02-17 19:04:04 +00:00
V3RM1N 7d3d80ae6e docs: add installation section to README (#81)
Add Installation section with Repology badge and links to download page and GitHub releases

Signed-off-by: V3RM1N <mail@v3rm1n.dev>
2026-02-17 18:59:29 +00:00
19 changed files with 265 additions and 58 deletions
+5 -10
View File
@@ -1,7 +1,8 @@
on: on:
push: push:
branches: branches:
- "**" - main
pull_request:
jobs: jobs:
build: build:
@@ -15,16 +16,10 @@ jobs:
- name: Checkout assets - name: Checkout assets
run: git -c submodule."assets".update=checkout submodule update --init assets run: git -c submodule."assets".update=checkout submodule update --init assets
- name: Install pnpm - name: Setup Mise
uses: pnpm/action-setup@v4 uses: immich-app/devtools/actions/use-mise@cd24790a7f5f6439ac32cc94f5523cb2de8bfa8c # use-mise-action-v1.1.0
with: with:
run_install: false github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: "pnpm"
- name: Install dependencies - name: Install dependencies
run: pnpm install run: pnpm install
+19
View File
@@ -0,0 +1,19 @@
name: Git Town
on:
pull_request:
jobs:
git-town:
name: Display the branch stack
runs-on: ubuntu-slim
if: ${{ !startsWith(github.head_ref, 'release-please--') }}
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- uses: stoatchat/action-git-town@4bc5c942e4603bffa0806b51d5fe5f0bc5deb0ac
+7 -3
View File
@@ -12,8 +12,12 @@ jobs:
steps: steps:
- name: Send release notification webhook - name: Send release notification webhook
env:
TAG_NAME: ${{ github.event.release.tag_name }}
REPOSITORY: ${{ github.repository }}
WEBHOOK_URL: ${{ secrets.STOAT_WEBHOOK_UPDATES_URL }}
run: | run: |
RELEASE_URL="https://github.com/${{ github.repository }}/releases/tag/${{ github.event.release.tag_name }}" RELEASE_URL="https://github.com/${REPOSITORY}/releases/tag/${TAG_NAME}"
curl -X POST "${{ secrets.STOAT_WEBHOOK_UPDATES_URL }}" \ curl -X POST "$WEBHOOK_URL" \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d "{\"content\": \"$RELEASE_URL\"}" -d "{\"content\": \"$RELEASE_URL\"}"
+1 -1
View File
@@ -1,3 +1,3 @@
{ {
".": "1.2.0" ".": "1.3.0"
} }
+22
View File
@@ -1,5 +1,27 @@
# Changelog # Changelog
## [1.3.0](https://github.com/stoatchat/for-desktop/compare/v1.2.0...v1.3.0) (2026-02-18)
### Features
* minimise-to-tray-on-startup ([#126](https://github.com/stoatchat/for-desktop/issues/126)) ([8284117](https://github.com/stoatchat/for-desktop/commit/8284117e76c0fcff4091de3ef623014e4594a593))
* Reload/Refresh shortcut ([#119](https://github.com/stoatchat/for-desktop/issues/119)) ([2e99b19](https://github.com/stoatchat/for-desktop/commit/2e99b19353fbd45d9fdf1d148bae3a8a19c788ed))
### Bug Fixes
* Add common zoom-reset shortcut. ([#112](https://github.com/stoatchat/for-desktop/issues/112)) ([def29f9](https://github.com/stoatchat/for-desktop/commit/def29f9b3c1205944aab58beb8000815d41633b5))
* allow CTRL+"+" to also zoom in. ([#108](https://github.com/stoatchat/for-desktop/issues/108)) ([2b962c5](https://github.com/stoatchat/for-desktop/commit/2b962c5d066787601223368ee7dcc1e46a345b8a))
* App-maximized-2nd-monitor ([897d706](https://github.com/stoatchat/for-desktop/commit/897d706983a347938a2fb42ba8e58e40794bba13))
* don't re-enable abutostart ([63b9ea8](https://github.com/stoatchat/for-desktop/commit/63b9ea818a9f32ca8535948e18752726c0f50a12))
* firstLaunch = false after initial setup ([#131](https://github.com/stoatchat/for-desktop/issues/131)) ([63b9ea8](https://github.com/stoatchat/for-desktop/commit/63b9ea818a9f32ca8535948e18752726c0f50a12))
* flatpak icons not building correctly and wayland support ([#132](https://github.com/stoatchat/for-desktop/issues/132)) ([ffe17ec](https://github.com/stoatchat/for-desktop/commit/ffe17ec2c54fca6967435b8a4ada7fa8d4da7b33))
* replace default dialog with notification ([#98](https://github.com/stoatchat/for-desktop/issues/98)) ([7d2f296](https://github.com/stoatchat/for-desktop/commit/7d2f296ca72bbd7ad694c66a917d47067f883fc5))
* toggle window visibility on tray click instead of always showing ([#103](https://github.com/stoatchat/for-desktop/issues/103)) ([742a95f](https://github.com/stoatchat/for-desktop/commit/742a95f3cb820c5b5398c815b7b45017b6b06053))
* try to restore maximised windows to correct display ([#92](https://github.com/stoatchat/for-desktop/issues/92)) ([897d706](https://github.com/stoatchat/for-desktop/commit/897d706983a347938a2fb42ba8e58e40794bba13))
* use template icon for macOS tray, use higher res icons for other platforms ([#130](https://github.com/stoatchat/for-desktop/issues/130)) ([58ccb63](https://github.com/stoatchat/for-desktop/commit/58ccb63d23541a03e05a48a37a98f883a2ba0d3f))
## [1.2.0](https://github.com/stoatchat/for-desktop/compare/v1.1.12...v1.2.0) (2026-02-14) ## [1.2.0](https://github.com/stoatchat/for-desktop/compare/v1.1.12...v1.2.0) (2026-02-14)
+8
View File
@@ -13,6 +13,14 @@ Application for Windows, macOS, and Linux.
</div> </div>
<br/> <br/>
## Installation
<a href="https://repology.org/project/stoat-desktop/versions">
<img src="https://repology.org/badge/vertical-allrepos/stoat-desktop.svg" alt="Packaging status" align="right">
</a>
- All downloads and instructions for Stoat can be found on our [Website](https://stoat.chat/download).
## Development Guide ## Development Guide
_Contribution guidelines for Desktop app TBA!_ _Contribution guidelines for Desktop app TBA!_
+1 -1
Submodule assets updated: f106946659...bd432f2298
+11
View File
@@ -0,0 +1,11 @@
[Desktop Entry]
Name=Stoat
Comment=Open source, user-first chat platform
Exec=stoat-desktop
Terminal=false
Type=Application
Icon=chat.stoat.StoatDesktop
Categories=Network;InstantMessaging
StartupWMClass=stoat-desktop
X-Desktop-File-Install-Version=0.26
X-Flatpak=chat.stoat.StoatDesktop
+70
View File
@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop">
<id>chat.stoat.StoatDesktop</id>
<launchable type="desktop-id">chat.stoat.StoatDesktop.desktop</launchable>
<name>Stoat</name>
<developer id="chat.stoat">
<name>Revolt Platforms Ltd</name>
</developer>
<summary>Open source, user-first chat platform</summary>
<metadata_license>CC0-1.0</metadata_license>
<project_license>AGPL-3.0</project_license>
<icon type="remote" height="256" width="256">
https://raw.githubusercontent.com/stoatchat/assets/f106946659af67ad4f008588ac51570029b2fd47/desktop/icon.png</icon>
<description>
<p>Stoat is an open source, user-first chat platform. Send messages, share
images, mention users, and join voice channels — all from a native desktop
application.</p>
</description>
<screenshots>
<screenshot type="default">
<caption>Main window</caption>
<image>screenshot.png</image>
</screenshot>
</screenshots>
<releases>
<release date="2026-02-14" version="1.2.0">
<description>
<p>Features:</p>
<ul>
<li>New Branding</li>
<li>Persist and restore window size and position</li>
</ul>
<p>Bug Fixes:</p>
<ul>
<li>App Autostart</li>
</ul>
</description>
</release>
<release date="2025-12-29" version="1.1.12">
<description>
<p>Bug fixes:</p>
<ul>
<li>Add NixOS compatibility for electron startup</li>
<li>Correctly load badge count; expose to renderer</li>
<li>Fix event listener accumulation from rpc client</li>
<li>Fix macOS tray icon size</li>
<li>Fix RPC largeImageText</li>
<li>Use the correct argument for auto start</li>
</ul>
</description>
</release>
</releases>
<url type="bugtracker">https://github.com/stoatchat/for-desktop/issues</url>
<url type="homepage">https://stoat.chat</url>
<url type="vcs-browser">https://github.com/stoatchat/for-desktop</url>
<content_rating type="oars-1.1">
<content_attribute id="social-chat">intense</content_attribute>
<content_attribute id="social-info">intense</content_attribute>
<content_attribute id="social-audio">intense</content_attribute>
<content_attribute id="social-contacts">intense</content_attribute>
</content_rating>
<requires>
<display_length compare="ge">940</display_length>
<internet>always</internet>
</requires>
<supports>
<control>keyboard</control>
<control>pointing</control>
</supports>
</component>
+16 -9
View File
@@ -1,16 +1,13 @@
{ { pkgs ? import (fetchTarball {
pkgs ? import <nixpkgs> { }, url = "https://github.com/NixOS/nixpkgs/archive/77ef7a29d276c6d8303aece3444d61118ef71ac2.tar.gz";
sha256 = "0pm4l48jq8plzrrrisimahxqlcpx7qqq9c99hylmf7p3zlc3phsy";
}) {},
}: }:
pkgs.mkShell rec { pkgs.mkShell rec {
buildInputs = [ buildInputs = with pkgs; [
# Tools # Tools
pkgs.git pkgs.mise
pkgs.gh
# Node
pkgs.nodejs
pkgs.nodejs.pkgs.pnpm
# Electron # Electron
(pkgs.writeShellScriptBin "electron-nix" '' (pkgs.writeShellScriptBin "electron-nix" ''
@@ -29,5 +26,15 @@ pkgs.mkShell rec {
pkgs.flatpak-builder pkgs.flatpak-builder
pkgs.elfutils pkgs.elfutils
# flatpak remote-add --if-not-exists --user flathub https://dl.flathub.org/repo/flathub.flatpakrepo # flatpak remote-add --if-not-exists --user flathub https://dl.flathub.org/repo/flathub.flatpakrepo
(writeShellScriptBin "fish" ''
exec ${pkgs.fish}/bin/fish -C 'mise activate fish | source' "$@"
'')
]; ];
shellHook = ''
export ELECTRON_OVERRIDE_DIST_PATH="${pkgs.electron}/bin"
export MISE_NODE_COMPILE=false
eval "$(mise activate bash)"
'';
} }
+10 -3
View File
@@ -58,8 +58,15 @@ if (!process.env.PLATFORM) {
description: STRINGS.description, description: STRINGS.description,
productName: STRINGS.name, productName: STRINGS.name,
productDescription: STRINGS.description, productDescription: STRINGS.description,
runtimeVersion: "21.08", runtimeVersion: "25.08",
icon: `${ASSET_DIR}/icon.png`, icon: {
"16x16": `${ASSET_DIR}/hicolor/16x16.png`,
"32x32": `${ASSET_DIR}/hicolor/32x32.png`,
"64x64": `${ASSET_DIR}/hicolor/64x64.png`,
"128x128": `${ASSET_DIR}/hicolor/128x128.png`,
"256x256": `${ASSET_DIR}/hicolor/256x256.png`,
"512x512": `${ASSET_DIR}/hicolor/512x512.png`,
} as unknown,
categories: ["Network"], categories: ["Network"],
modules: [ modules: [
// use the latest zypak -- Electron sandboxing for Flatpak // use the latest zypak -- Electron sandboxing for Flatpak
@@ -77,7 +84,7 @@ if (!process.env.PLATFORM) {
finishArgs: [ finishArgs: [
// default arguments found by running // default arguments found by running
// DEBUG=electron-installer-flatpak* pnpm make // DEBUG=electron-installer-flatpak* pnpm make
"--socket=x11", "--socket=fallback-x11",
"--share=ipc", "--share=ipc",
"--device=dri", "--device=dri",
"--socket=pulseaudio", "--socket=pulseaudio",
+5
View File
@@ -0,0 +1,5 @@
[tools]
node = "25.4.0"
pnpm = "10.28.1"
gh = "2.25.0"
"github:git-town/git-town" = "22.4.0"
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"name": "stoat-desktop", "name": "stoat-desktop",
"productName": "stoat-desktop", "productName": "stoat-desktop",
"version": "1.2.0", "version": "1.3.0",
"main": ".vite/build/main.js", "main": ".vite/build/main.js",
"repository": "stoatchat/desktop", "repository": "stoatchat/desktop",
"scripts": { "scripts": {
+2
View File
@@ -1,7 +1,9 @@
nodeLinker: hoisted nodeLinker: hoisted
onlyBuiltDependencies: onlyBuiltDependencies:
- bufferutil
- electron - electron
- electron-winstaller - electron-winstaller
- esbuild - esbuild
- register-scheme - register-scheme
- utf-8-validate
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 702 KiB

+17 -5
View File
@@ -1,6 +1,6 @@
import { updateElectronApp } from "update-electron-app"; import { IUpdateInfo, updateElectronApp } from "update-electron-app";
import { BrowserWindow, app, shell } from "electron"; import { BrowserWindow, Notification, app, shell } from "electron";
import started from "electron-squirrel-startup"; import started from "electron-squirrel-startup";
import { autoLaunch } from "./native/autoLaunch"; import { autoLaunch } from "./native/autoLaunch";
@@ -24,21 +24,33 @@ if (!config.hardwareAcceleration) {
// ensure only one copy of the application can run // ensure only one copy of the application can run
const acquiredLock = app.requestSingleInstanceLock(); const acquiredLock = app.requestSingleInstanceLock();
const onNotifyUser = (_info: IUpdateInfo) => {
const notification = new Notification({
title: "Update Available",
body: "Restart the app to install the update.",
silent: true,
});
notification.show();
};
if (acquiredLock) { if (acquiredLock) {
// start auto update logic // start auto update logic
updateElectronApp(); updateElectronApp({ onNotifyUser });
// create and configure the app when electron is ready // create and configure the app when electron is ready
app.on("ready", () => { app.on("ready", () => {
// create window and application contexts
createMainWindow();
// enable auto start on Windows and MacOS // enable auto start on Windows and MacOS
if (config.firstLaunch) { if (config.firstLaunch) {
if (process.platform === "win32" || process.platform === "darwin") { if (process.platform === "win32" || process.platform === "darwin") {
autoLaunch.enable(); autoLaunch.enable();
} }
config.firstLaunch = false;
} }
// create window and application contexts
createMainWindow();
initTray(); initTray();
initDiscordRpc(); initDiscordRpc();
+24 -4
View File
@@ -16,6 +16,9 @@ const schema = {
minimiseToTray: { minimiseToTray: {
type: "boolean", type: "boolean",
} as JSONSchema.Boolean, } as JSONSchema.Boolean,
startMinimisedToTray: {
type: "boolean",
} as JSONSchema.Boolean,
spellchecker: { spellchecker: {
type: "boolean", type: "boolean",
} as JSONSchema.Boolean, } as JSONSchema.Boolean,
@@ -29,16 +32,16 @@ const schema = {
type: "object", type: "object",
properties: { properties: {
x: { x: {
type: 'number' type: "number",
} as JSONSchema.Number, } as JSONSchema.Number,
y: { y: {
type: 'number' type: "number",
} as JSONSchema.Number, } as JSONSchema.Number,
width: { width: {
type: 'number' type: "number",
} as JSONSchema.Number, } as JSONSchema.Number,
height: { height: {
type: 'number' type: "number",
} as JSONSchema.Number, } as JSONSchema.Number,
isMaximised: { isMaximised: {
type: "boolean", type: "boolean",
@@ -53,6 +56,7 @@ const store = new Store({
firstLaunch: true, firstLaunch: true,
customFrame: true, customFrame: true,
minimiseToTray: true, minimiseToTray: true,
startMinimisedToTray: false,
spellchecker: true, spellchecker: true,
hardwareAcceleration: true, hardwareAcceleration: true,
discordRpc: true, discordRpc: true,
@@ -75,6 +79,7 @@ class Config {
firstLaunch: this.firstLaunch, firstLaunch: this.firstLaunch,
customFrame: this.customFrame, customFrame: this.customFrame,
minimiseToTray: this.minimiseToTray, minimiseToTray: this.minimiseToTray,
startMinimisedToTray: this.startMinimisedToTray,
spellchecker: this.spellchecker, spellchecker: this.spellchecker,
hardwareAcceleration: this.hardwareAcceleration, hardwareAcceleration: this.hardwareAcceleration,
discordRpc: this.discordRpc, discordRpc: this.discordRpc,
@@ -123,6 +128,21 @@ class Config {
this.sync(); this.sync();
} }
get startMinimisedToTray() {
return (store as never as { get(k: string): boolean }).get(
"startMinimisedToTray",
);
}
set startMinimisedToTray(value: boolean) {
(store as never as { set(k: string, value: boolean): void }).set(
"startMinimisedToTray",
value,
);
this.sync();
}
get spellchecker() { get spellchecker() {
return (store as never as { get(k: string): boolean }).get("spellchecker"); return (store as never as { get(k: string): boolean }).get("spellchecker");
} }
+15 -11
View File
@@ -1,6 +1,7 @@
import { Menu, Tray, nativeImage } from "electron"; import { Menu, Tray, nativeImage } from "electron";
import trayIconAsset from "../../assets/desktop/icon.png?asset"; import trayIconAsset from "../../assets/desktop/icon.png?asset";
import macOsTrayIconAsset from "../../assets/desktop/iconTemplate.png?asset";
import { version } from "../../package.json"; import { version } from "../../package.json";
import { mainWindow, quitApp } from "./window"; import { mainWindow, quitApp } from "./window";
@@ -10,17 +11,16 @@ let tray: Tray = null;
// Create and resize tray icon for macOS // Create and resize tray icon for macOS
function createTrayIcon() { function createTrayIcon() {
const image = nativeImage.createFromDataURL(trayIconAsset); if (process.platform === "darwin") {
const resized = image.resize({ width: 20, height: 20 }); const image = nativeImage.createFromDataURL(macOsTrayIconAsset);
const resized = image.resize({ width: 20, height: 20 });
// Mark as template image so it adapts to dark/light mode resized.setTemplateImage(true);
resized.setTemplateImage(true); return resized;
} else {
return resized; return nativeImage.createFromDataURL(trayIconAsset);
}
} }
// trayIcon.setTemplateImage(true);
export function initTray() { export function initTray() {
const trayIcon = createTrayIcon(); const trayIcon = createTrayIcon();
tray = new Tray(trayIcon); tray = new Tray(trayIcon);
@@ -28,8 +28,12 @@ export function initTray() {
tray.setToolTip("Stoat for Desktop"); tray.setToolTip("Stoat for Desktop");
tray.setImage(trayIcon); tray.setImage(trayIcon);
tray.on("click", () => { tray.on("click", () => {
mainWindow.show(); if (mainWindow.isVisible()) {
mainWindow.focus(); mainWindow.hide();
} else {
mainWindow.show();
mainWindow.focus();
}
}); });
} }
+31 -10
View File
@@ -36,6 +36,10 @@ const windowIcon = nativeImage.createFromDataURL(windowIconAsset);
* Create the main application window * Create the main application window
*/ */
export function createMainWindow() { export function createMainWindow() {
// (CLI arg --hidden or config)
const startHidden =
app.commandLine.hasSwitch("hidden") || config.startMinimisedToTray;
// create the window // create the window
mainWindow = new BrowserWindow({ mainWindow = new BrowserWindow({
minWidth: 300, minWidth: 300,
@@ -45,6 +49,7 @@ export function createMainWindow() {
backgroundColor: "#191919", backgroundColor: "#191919",
frame: !config.customFrame, frame: !config.customFrame,
icon: windowIcon, icon: windowIcon,
show: !startHidden,
webPreferences: { webPreferences: {
// relative to `.vite/build` // relative to `.vite/build`
preload: join(__dirname, "preload.js"), preload: join(__dirname, "preload.js"),
@@ -57,19 +62,25 @@ export function createMainWindow() {
// hide the options // hide the options
mainWindow.setMenu(null); mainWindow.setMenu(null);
// maximise the window if it was maximised before
if (config.windowState.isMaximised) {
mainWindow.maximize();
}
// restore last position if it was moved previously // restore last position if it was moved previously
if(config.windowState.x > 0 || config.windowState.y > 0) { if (config.windowState.x > 0 || config.windowState.y > 0) {
mainWindow.setPosition(config.windowState.x ?? 0, config.windowState.y ?? 0); mainWindow.setPosition(
config.windowState.x ?? 0,
config.windowState.y ?? 0,
);
} }
// restore last size if it was resized previously // restore last size if it was resized previously
if(config.windowState.width > 0 && config.windowState.height > 0) { if (config.windowState.width > 0 && config.windowState.height > 0) {
mainWindow.setSize(config.windowState.width ?? 1280, config.windowState.height ?? 720); mainWindow.setSize(
config.windowState.width ?? 1280,
config.windowState.height ?? 720,
);
}
// maximise the window if it was maximised before
if (config.windowState.isMaximised && !startHidden) {
mainWindow.maximize();
} }
// load the entrypoint // load the entrypoint
@@ -105,7 +116,7 @@ export function createMainWindow() {
// rebind zoom controls to be more sensible // rebind zoom controls to be more sensible
mainWindow.webContents.on("before-input-event", (event, input) => { mainWindow.webContents.on("before-input-event", (event, input) => {
if (input.control && input.key === "=") { if (input.control && (input.key === "=" || input.key === "+")) {
// zoom in (+) // zoom in (+)
event.preventDefault(); event.preventDefault();
mainWindow.webContents.setZoomLevel( mainWindow.webContents.setZoomLevel(
@@ -117,6 +128,16 @@ export function createMainWindow() {
mainWindow.webContents.setZoomLevel( mainWindow.webContents.setZoomLevel(
mainWindow.webContents.getZoomLevel() - 1, mainWindow.webContents.getZoomLevel() - 1,
); );
} else if (input.control && input.key === "0") {
// reset zoom to default.
event.preventDefault();
mainWindow.webContents.setZoomLevel(0);
} else if (
input.key === "F5" ||
((input.control || input.meta) && input.key.toLowerCase() === "r")
) {
event.preventDefault();
mainWindow.webContents.reload();
} }
}); });