fix: use win.getBounds() instead of getPosition()/getSize() to prevent window drift on Linux#315493
Open
harshagarwalnyu wants to merge 4 commits into
Open
fix: use win.getBounds() instead of getPosition()/getSize() to prevent window drift on Linux#315493harshagarwalnyu wants to merge 4 commits into
harshagarwalnyu wants to merge 4 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses Linux window-position “drift” when native titlebars are enabled by ensuring we persist/compute window geometry using Electron’s full window bounds (frame-inclusive) rather than composing coordinates from getPosition() + getSize().
Changes:
- Update
CodeWindow.getBounds()to delegate directly toBrowserWindow.getBounds().
Author
|
Verified this fix on GNOME/X11 (Ubuntu 22.04). Using win.getBounds() correctly accounts for the window decorations (titlebars), preventing the coordinate drift that occurs when manually composing from getPosition() and getSize(). This ensures the window restored position remains consistent across restarts. |
1c4c89f to
470fe80
Compare
Author
|
@mjbvz Hi! Could you approve the CI workflows to run on this PR? Happy to address any feedback once the checks are in. Thanks! |
470fe80 to
78e01bd
Compare
…ndow drift on Linux On Linux (GNOME/X11) with native titlebars, getPosition() can return content-area coordinates instead of frame coordinates. When saved and restored, the window manager re-adds the titlebar height causing drift. Replace two call sites with getBounds() which always returns the full frame-inclusive geometry: - CodeWindow.getBounds() in windowImpl.ts - maximize event handler in BaseWindow Fixes microsoft#117180
78e01bd to
9cf6e52
Compare
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.
Fixes #117180
On Linux (specifically GNOME/X11), win.getPosition() can sometimes return the coordinates of the content area instead of the window frame when native titlebars are enabled. When these coordinates are saved and later used to restore the window position (e.g., in the constructor or via setBounds), the window manager adds the titlebar height again, causing the window to drift downwards with each restart.
Using win.getBounds() is more robust as it is designed to return the full window geometry including decorations, ensuring that the saved coordinates correctly represent the window frame.