From ad077125618bb3dc93dd2a660bf6c6956204bae5 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Wed, 17 May 2023 10:17:08 +0200 Subject: [PATCH] fix: `win.isMaximized()` for transparent windows on Windows (#38234) --- shell/browser/native_window_views.cc | 2 +- spec/api-browser-window-spec.ts | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/shell/browser/native_window_views.cc b/shell/browser/native_window_views.cc index 364da7e82458..f21ba2a8eeab 100644 --- a/shell/browser/native_window_views.cc +++ b/shell/browser/native_window_views.cc @@ -656,7 +656,7 @@ bool NativeWindowViews::IsMaximized() { return true; } else { #if BUILDFLAG(IS_WIN) - if (transparent()) { + if (transparent() && !IsMinimized()) { // Compare the size of the window with the size of the display auto display = display::Screen::GetScreen()->GetDisplayNearestWindow( GetNativeWindow()); diff --git a/spec/api-browser-window-spec.ts b/spec/api-browser-window-spec.ts index 0e558e0b0e2e..fc37f7296b84 100644 --- a/spec/api-browser-window-spec.ts +++ b/spec/api-browser-window-spec.ts @@ -6059,6 +6059,24 @@ describe('BrowserWindow module', () => { describe('"transparent" option', () => { afterEach(closeAllWindows); + ifit(process.platform !== 'linux')('correctly returns isMaximized() when the window is maximized then minimized', async () => { + const w = new BrowserWindow({ + frame: false, + transparent: true + }); + + const maximize = once(w, 'maximize'); + w.maximize(); + await maximize; + + const minimize = once(w, 'minimize'); + w.minimize(); + await minimize; + + expect(w.isMaximized()).to.be.false(); + expect(w.isMinimized()).to.be.true(); + }); + // Only applicable on Windows where transparent windows can't be maximized. ifit(process.platform === 'win32')('can show maximized frameless window', async () => { const display = screen.getPrimaryDisplay();