Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Allow windows behind macOS elements if frame = false #24033

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 14 additions & 2 deletions shell/browser/ui/cocoa/electron_ns_window.mm
Expand Up @@ -91,8 +91,20 @@ - (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen*)screen {

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;
}

Expand Down
7 changes: 7 additions & 0 deletions spec-main/api-browser-window-spec.ts
Expand Up @@ -1650,6 +1650,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);
Expand Down