From 2cf38fcc413bbf93dc8f08795d9a71f67319ac19 Mon Sep 17 00:00:00 2001 From: beyondkmp Date: Fri, 23 Jan 2026 01:50:04 +0800 Subject: [PATCH] fix(linux): fix main window not coming to front when clicked from tray (#12503) When clicking the tray icon on Linux with another window on top, the main window would not properly come to the front. This was due to Linux window managers' focus stealing prevention. The fix uses a hide/show sequence to simulate the "close to tray and reopen" behavior which works correctly. This approach resets the window state and makes the window manager treat it as a new window activation request. Co-authored-by: Claude Sonnet 4.5 --- src/main/services/WindowService.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/main/services/WindowService.ts b/src/main/services/WindowService.ts index cda99cc37a..c76753156d 100644 --- a/src/main/services/WindowService.ts +++ b/src/main/services/WindowService.ts @@ -415,6 +415,23 @@ export class WindowService { return } + /** + * [Linux] Special handling for window activation + * When the window is visible but covered by other windows, simply calling show() and focus() + * is not enough to bring it to the front. We need to hide it first, then show it again. + * This mimics the "close to tray and reopen" behavior which works correctly. + */ + if (isLinux && this.mainWindow.isVisible() && !this.mainWindow.isFocused()) { + this.mainWindow.hide() + setImmediate(() => { + if (this.mainWindow && !this.mainWindow.isDestroyed()) { + this.mainWindow.show() + this.mainWindow.focus() + } + }) + return + } + /** * About setVisibleOnAllWorkspaces *