fix: don't allow window to go behind menu bar on mac (#22770)
This commit is contained in:
parent
07cd70a37e
commit
bdef77bad8
2 changed files with 10 additions and 4 deletions
|
@ -89,11 +89,11 @@ bool ScopedDisableResize::disable_resize_ = false;
|
|||
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 {
|
||||
|
|
|
@ -1597,10 +1597,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 });
|
||||
|
|
Loading…
Reference in a new issue