From c6a6bca944371db8105701519225e3847d7ac8c6 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Wed, 17 May 2023 11:12:01 +0000 Subject: [PATCH] fix: getNormalBounds for transparent windows on Windows Co-authored-by: Shelley Vohr --- shell/browser/native_window_views.cc | 4 ++++ spec/api-browser-window-spec.ts | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/shell/browser/native_window_views.cc b/shell/browser/native_window_views.cc index be77b9e3e67ae..c1457dea0b92e 100644 --- a/shell/browser/native_window_views.cc +++ b/shell/browser/native_window_views.cc @@ -771,6 +771,10 @@ gfx::Size NativeWindowViews::GetContentSize() { } gfx::Rect NativeWindowViews::GetNormalBounds() { +#if BUILDFLAG(IS_WIN) + if (IsMaximized() && transparent()) + return restore_bounds_; +#endif return widget()->GetRestoredBounds(); } diff --git a/spec/api-browser-window-spec.ts b/spec/api-browser-window-spec.ts index 23ab1e3ec2ae0..00a6aedbad405 100644 --- a/spec/api-browser-window-spec.ts +++ b/spec/api-browser-window-spec.ts @@ -1476,6 +1476,23 @@ describe('BrowserWindow module', () => { expect(w.isFullScreen()).to.equal(true); }); + it('checks normal bounds for maximized transparent window', async () => { + w.destroy(); + w = new BrowserWindow({ + transparent: true, + show: false + }); + w.show(); + + const bounds = w.getNormalBounds(); + + const maximize = emittedOnce(w, 'maximize'); + w.maximize(); + await maximize; + + expectBoundsEqual(w.getNormalBounds(), bounds); + }); + it('does not change size for a frameless window with min size', async () => { w.destroy(); w = new BrowserWindow({