fix(desktop): resolve window maximize, titlebar interactions, and keyboard shortcut leaks#154
Open
AI-fullcup wants to merge 1 commit into
Open
Conversation
…board shortcut leaks - Fix Sherlockouo#99: titlebar double-click maximize behavior - Stop propagation of double-click events on interactive buttons in TopbarDesktop to prevent accidental maximize when double-clicking navigation/search/avatar. - Fix swapped width/height in ipcMain.ts when saving/restoring unmaximize size. - Remove erroneous second width argument in win.setSize(). - Fix implicit bug: remove manual isMaximized state in main process - Use win.isMaximized() directly so the renderer always sees the real window state. - This also fixes minimize/unminimize incorrectly toggling the maximized flag. - Fix Sherlockouo#74: global keyboard shortcuts failing and leaking memory - Correct removeListener target from webContexts to win in keyboardShortcuts.ts. - Add safeRegister wrapper with null-check and try-catch to prevent crashes when formatForAccelerator returns null or the shortcut is invalid. Fixes Sherlockouo#99 Fixes Sherlockouo#74
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR bundles three closely related fixes in the Electron main process and window interactions.
Fixes #99: Titlebar double-click maximize behavior
Problem:
TopbarDesktop'sonDoubleClickhandler.app-region-dragswallows events on Windows frameless windows, while the fallbackonDoubleClickonly fires onapp-region-no-dragchildren.ipcMain.tshad the width/height swapped and passedwidthtwice tosetSize().Changes:
TopbarDesktop.tsx: Addede.stopPropagation()on the left and right interactive containers so button double-clicks no longer maximize the window.ipcMain.ts: FixedunMaximizeSize = { width: size[0], height: size[1] }(wassize[1], size[0]) and correctedwin.setSize(width, height).Fixes implicit bug: Broken maximize state synchronization
Problem:
ipcMain.tsmanually trackedisMaximizedwith a local boolean. This easily desynchronizes when the user maximizes the window via OS shortcuts (e.g. Win+↑) or edge snapping. The stale state then caused wrong restore behavior and confusing IPC replies.Changes:
isMaximizedvariable withwin.isMaximized()everywhere.isMaximized = !isMaximizedinsideMinimizeOrUnminimize; minimizing a window has nothing to do with its maximized state and was corrupting the UI.Fixes #74: Global keyboard shortcuts failing and leaking memory
Problem:
keyboardShortcuts.tsaddedfocus/blurlisteners onwinbut attempted to remove them fromwebContexts, so they were never unregistered. Every window recreate leaks two listeners on the main process, eventually making shortcuts sluggish or dead.formatForAccelerator()can returnnull, but the code used a non-null assertion (!) and fed it straight intoglobalShortcut.register(null), which throws an uncaught exception and can kill the shortcut subsystem.Changes:
removeListenertarget fromwebContextstowin.safeRegister()with explicitnullchecks andtry/catcharound everyglobalShortcut.registercall.Testing notes: