From 3eade2c22866acde3ecb243adab2672f60f81806 Mon Sep 17 00:00:00 2001 From: Felix Rieseberg Date: Tue, 9 Jun 2020 11:52:14 -0700 Subject: [PATCH] fix: Allow windows behind macOS elements if frame = false (#23976) --- shell/browser/ui/cocoa/electron_ns_window.mm | 16 ++++++++++++++-- spec-main/api-browser-window-spec.ts | 7 +++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/shell/browser/ui/cocoa/electron_ns_window.mm b/shell/browser/ui/cocoa/electron_ns_window.mm index b11a7659566..05c9af04fe6 100644 --- a/shell/browser/ui/cocoa/electron_ns_window.mm +++ b/shell/browser/ui/cocoa/electron_ns_window.mm @@ -91,8 +91,20 @@ bool ScopedDisableResize::disable_resize_ = false; NSRect result = [super constrainFrameRect:frameRect toScreen:screen]; // Enable the window to be larger than screen. - if ([self enableLargerThanScreen]) - result.size = frameRect.size; + if ([self enableLargerThanScreen]) { + // If we have a frame, ensure that we only position the window + // somewhere where the user can move or resize it (and not + // behind the menu bar, for instance) + // + // If there's no frame, put the window wherever the developer + // wanted it to go + if (shell_->has_frame()) { + result.size = frameRect.size; + } else { + result = frameRect; + } + } + return result; } diff --git a/spec-main/api-browser-window-spec.ts b/spec-main/api-browser-window-spec.ts index 3e5bf561c6b..d3b6f4bc64c 100644 --- a/spec-main/api-browser-window-spec.ts +++ b/spec-main/api-browser-window-spec.ts @@ -1673,6 +1673,13 @@ describe('BrowserWindow module', () => { const after = w.getPosition(); expect(after[1]).to.be.at.least(0); }); + it('can move the window behind menu bar if it has no frame', () => { + const w = new BrowserWindow({ show: true, enableLargerThanScreen: true, frame: false }); + w.setPosition(-10, -10); + const after = w.getPosition(); + expect(after[0]).to.be.equal(-10); + expect(after[1]).to.be.equal(-10); + }); it('without it, cannot move the window out of screen', () => { const w = new BrowserWindow({ show: true, enableLargerThanScreen: false }); w.setPosition(-10, -10);