Skip to content

fix: restore original bounds after CenterWindow clamps to primary display OS-21449#141

Open
t-bashir-bs wants to merge 1 commit into
42-x-y-bsfrom
tbashir/42-x-y-bs-fix-multi-hdmi-OS-21449
Open

fix: restore original bounds after CenterWindow clamps to primary display OS-21449#141
t-bashir-bs wants to merge 1 commit into
42-x-y-bsfrom
tbashir/42-x-y-bs-fix-multi-hdmi-OS-21449

Conversation

@t-bashir-bs
Copy link
Copy Markdown

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

Release Notes

Notes:

…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant