Skip to content

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

Merged
t-bashir-bs merged 1 commit into
42-x-y-bsfrom
tbashir/42-x-y-bs-fix-multi-hdmi-OS-21449
Jun 2, 2026
Merged

fix: restore original bounds after CenterWindow clamps to primary display OS-21449#141
t-bashir-bs merged 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:

Comment thread shell/browser/native_window.cc Outdated
…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.
@t-bashir-bs t-bashir-bs force-pushed the tbashir/42-x-y-bs-fix-multi-hdmi-OS-21449 branch from bbd6a36 to a41a571 Compare June 2, 2026 08:41
Copy link
Copy Markdown

@caneraltinbasak caneraltinbasak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change is fine. Consider sending upstream.

// and preserves the clamped size, so we must restore the full bounds.
const int w = options.ValueOrDefault(options::kWidth, GetSize().width());
const int h = options.ValueOrDefault(options::kHeight, GetSize().height());
SetBounds(gfx::Rect(x, y, w, h), false);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be upstreamed?

@t-bashir-bs t-bashir-bs merged commit b8875e6 into 42-x-y-bs Jun 2, 2026
28 checks passed
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.

2 participants