From 2a27a7d1c7bba4b74aa0e0f09955f67271860d86 Mon Sep 17 00:00:00 2001 From: samuelmaddock Date: Wed, 1 Sep 2021 18:36:45 -0400 Subject: [PATCH 1/3] fix: show maximized frameless window --- shell/browser/native_window_views.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/shell/browser/native_window_views.cc b/shell/browser/native_window_views.cc index cd5e8c19ce4b4..b2ad39ca6c101 100644 --- a/shell/browser/native_window_views.cc +++ b/shell/browser/native_window_views.cc @@ -1629,8 +1629,17 @@ void NativeWindowViews::OnMouseEvent(ui::MouseEvent* event) { } ui::WindowShowState NativeWindowViews::GetRestoredState() { - if (IsMaximized()) + if (IsMaximized()) { +#if defined(OS_WIN) + // Only restore Maximized state when window is NOT transparent style + if (!transparent()) { + return ui::SHOW_STATE_MAXIMIZED; + } +#else return ui::SHOW_STATE_MAXIMIZED; +#endif + } + if (IsFullscreen()) return ui::SHOW_STATE_FULLSCREEN; From c0d1c1841bf939c908031f4a20ec52bd75809c6d Mon Sep 17 00:00:00 2001 From: samuelmaddock Date: Wed, 1 Sep 2021 20:00:09 -0400 Subject: [PATCH 2/3] test: show maximized transparent window --- spec-main/api-browser-window-spec.ts | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/spec-main/api-browser-window-spec.ts b/spec-main/api-browser-window-spec.ts index 374d928fc01cd..16939361ecc46 100644 --- a/spec-main/api-browser-window-spec.ts +++ b/spec-main/api-browser-window-spec.ts @@ -4647,4 +4647,32 @@ describe('BrowserWindow module', () => { }); }); }); + + describe('"transparent" option', () => { + afterEach(closeAllWindows); + + // 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(); + + const w = new BrowserWindow({ + ...display.bounds, + frame: false, + transparent: true, + show: true + }); + + w.loadURL('about:blank'); + await emittedOnce(w, 'ready-to-show'); + + expect(w.isMaximized()).to.be.true(); + + // Fails when the transparent HWND is in an invalid maximized state. + expect(w.getBounds()).to.deep.equal(display.bounds); + + const newBounds = { width: 256, height: 256, x: 0, y: 0 }; + w.setBounds(newBounds); + expect(w.getBounds()).to.deep.equal(newBounds); + }); + }); }); From 401e54fe2fcfcf18d1d799b160c7192b6617a446 Mon Sep 17 00:00:00 2001 From: samuelmaddock Date: Thu, 2 Sep 2021 13:51:29 -0400 Subject: [PATCH 3/3] fix: test using wrong bounds BrowserWindow will be sized to the workArea when the Windows taskbar is visible. --- spec-main/api-browser-window-spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec-main/api-browser-window-spec.ts b/spec-main/api-browser-window-spec.ts index 16939361ecc46..b4914dbeca9f2 100644 --- a/spec-main/api-browser-window-spec.ts +++ b/spec-main/api-browser-window-spec.ts @@ -4668,7 +4668,7 @@ describe('BrowserWindow module', () => { expect(w.isMaximized()).to.be.true(); // Fails when the transparent HWND is in an invalid maximized state. - expect(w.getBounds()).to.deep.equal(display.bounds); + expect(w.getBounds()).to.deep.equal(display.workArea); const newBounds = { width: 256, height: 256, x: 0, y: 0 }; w.setBounds(newBounds);