fix: restore original bounds after CenterWindow clamps to primary display OS-21449#141
Open
t-bashir-bs wants to merge 1 commit into
Open
fix: restore original bounds after CenterWindow clamps to primary display OS-21449#141t-bashir-bs wants to merge 1 commit into
t-bashir-bs wants to merge 1 commit into
Conversation
…play OS-21449 When creating a frameless BrowserWindow spanning multiple displays (e.g. 3840x1080 across dual HDMI), CenterWindow in the NativeWindowViews constructor clamps the size to the primary display's work area (1920x1080). InitFromOptions then called SetPosition(x, y), which only updated the position and preserved the clamped size, so the window was permanently stuck at 1920x1080. Fix: change InitFromOptions to call SetBounds with the full rect (position + original size from options) instead of SetPosition, restoring the intended dimensions after CenterWindow's clamping. This regression was introduced by upstream Electron commit 4affacb ("fix: external resize hit targets for frameless windows on Windows", PR electron#50864). That commit added a guard condition `if (!GetRestoredFrameBorderInsets().IsEmpty())` around a post-CenterWindow SetBounds call in the NativeWindowViews constructor, which previously ran unconditionally on Linux. For frameless windows (where frame border insets are zero), the SetBounds is now skipped, leaving CenterWindow's clamped size in effect. In Electron 28, the unconditional SetBounds after CenterWindow always restored the original requested size: // On linux after the widget is initialized we might have to force set the // bounds if the bounds are smaller than the current display SetBounds(gfx::Rect(GetPosition(), bounds.size()), false); This was preserved in commit 931c257 (PR electron#49209, "accurate window sizing and support for content sizing on Linux/Wayland with CSD"), which even documented the intent: "The widget clamps bounds to fit the screen, but we want to allow windows larger than the display." The subsequent commit 4affacb then inadvertently broke this for frameless windows.
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.
Description of Change
When creating a frameless BrowserWindow spanning multiple displays (e.g. 3840x1080 across dual HDMI), CenterWindow in the NativeWindowViews constructor clamps the size to the primary display's work area (1920x1080). InitFromOptions then called SetPosition(x, y), which only updated the position and preserved the clamped size, so the window was permanently stuck at 1920x1080.
Fix: change InitFromOptions to call SetBounds with the full rect (position + original size from options) instead of SetPosition, restoring the intended dimensions after CenterWindow's clamping.
This regression was introduced by upstream Electron commit 4affacb ("fix: external resize hit targets for frameless windows on Windows", PR electron#50864). That commit added a guard condition
if (!GetRestoredFrameBorderInsets().IsEmpty())around a post-CenterWindow SetBounds call in the NativeWindowViews constructor, which previously ran unconditionally on Linux. For frameless windows (where frame border insets are zero), the SetBounds is now skipped, leaving CenterWindow's clamped size in effect.In Electron 28, the unconditional SetBounds after CenterWindow always restored the original requested size:
// On linux after the widget is initialized we might have to force set the
// bounds if the bounds are smaller than the current display
SetBounds(gfx::Rect(GetPosition(), bounds.size()), false);
This was preserved in commit 931c257 (PR electron#49209, "accurate window sizing and support for content sizing on Linux/Wayland with CSD"), which even documented the intent: "The widget clamps bounds to fit the screen, but we want to allow windows larger than the display." The subsequent commit 4affacb then inadvertently broke this for frameless windows.
Checklist
npm testpassesRelease Notes
Notes: