mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-02-06 02:51:07 +08:00
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 <noreply@anthropic.com>
This commit is contained in:
parent
1f209dc280
commit
2cf38fcc41
@ -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
|
||||
*
|
||||
|
||||
Loading…
Reference in New Issue
Block a user