From e7454ea6b9a0f4cf3420c67da189bdbef77662c8 Mon Sep 17 00:00:00 2001 From: Johannes Millan Date: Mon, 11 May 2026 14:31:19 +0200 Subject: [PATCH] fix(window): preserve maximized state for shortcut hide --- electron/ipc-handlers/global-shortcuts.ts | 3 ++- electron/main-window.ts | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/electron/ipc-handlers/global-shortcuts.ts b/electron/ipc-handlers/global-shortcuts.ts index 656aa59779..7f1afe34d5 100644 --- a/electron/ipc-handlers/global-shortcuts.ts +++ b/electron/ipc-handlers/global-shortcuts.ts @@ -1,7 +1,7 @@ import { globalShortcut, ipcMain } from 'electron'; import { IPC } from '../shared-with-frontend/ipc-events.const'; import { KeyboardConfig } from '../../src/app/features/config/keyboard-config.model'; -import { getWin } from '../main-window'; +import { getWin, setWasMaximizedBeforeHide } from '../main-window'; import { showOrFocus } from '../various-shared'; import { ensureIndicator } from '../indicator'; import { getIsMinimizeToTray } from '../shared-state'; @@ -49,6 +49,7 @@ const registerShowAppShortCuts = (cfg: KeyboardConfig): void => { // tray was successfully (re)created; otherwise minimize so a // taskbar handle remains as a safety net. blur() is a Windows // focus workaround (electron#20464) and a no-op elsewhere. + setWasMaximizedBeforeHide(mainWin.isMaximized()); if (IS_MAC) { mainWin.hide(); } else if (getIsMinimizeToTray() && ensureIndicator()) { diff --git a/electron/main-window.ts b/electron/main-window.ts index fc34ca78f1..1b9fc002c9 100644 --- a/electron/main-window.ts +++ b/electron/main-window.ts @@ -223,6 +223,7 @@ export const createWindow = async ({ }); mainWindowState.manage(mainWin); + setWasMaximizedBeforeHide(mainWin.isMaximized()); // Fix for #7276: electron-window-state saves state in its `closed` handler, // which calls win.isMaximized() on an already-hidden window (tray/shortcut