Skip to content

Commit

Permalink
fix: don't allow window to go behind menu bar on mac (#22828)
Browse files Browse the repository at this point in the history
Co-authored-by: Cezary Kulakowski <cezary@openfin.co>
  • Loading branch information
trop[bot] and CezaryKulakowski committed Mar 25, 2020
1 parent a6ff42c commit 0600420
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 3 additions & 3 deletions shell/browser/ui/cocoa/electron_ns_window.mm
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ - (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen*)screen {
if (electron::ScopedDisableResize::IsResizeDisabled())
return [self frame];

NSRect result = [super constrainFrameRect:frameRect toScreen:screen];
// Enable the window to be larger than screen.
if ([self enableLargerThanScreen])
return frameRect;
else
return [super constrainFrameRect:frameRect toScreen:screen];
result.size = frameRect.size;
return result;
}

- (void)setFrame:(NSRect)windowFrame display:(BOOL)displayViews {
Expand Down
8 changes: 7 additions & 1 deletion spec-main/api-browser-window-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1581,10 +1581,16 @@ describe('BrowserWindow module', () => {
ifdescribe(process.platform === 'darwin')('"enableLargerThanScreen" option', () => {
afterEach(closeAllWindows);
it('can move the window out of screen', () => {
const w = new BrowserWindow({ show: true, enableLargerThanScreen: true });
w.setPosition(-10, 50);
const after = w.getPosition();
expect(after).to.deep.equal([-10, 50]);
});
it('cannot move the window behind menu bar', () => {
const w = new BrowserWindow({ show: true, enableLargerThanScreen: true });
w.setPosition(-10, -10);
const after = w.getPosition();
expect(after).to.deep.equal([-10, -10]);
expect(after[1]).to.be.at.least(0);
});
it('without it, cannot move the window out of screen', () => {
const w = new BrowserWindow({ show: true, enableLargerThanScreen: false });
Expand Down

0 comments on commit 0600420

Please sign in to comment.