fix: ensure windows respect fullscreenability with different resizability values (#39620)
* fix: ensure child windows respect fullscreenability/resizability when parent is fullscreen * test: add an extra resize test
This commit is contained in:
parent
2affecd4dd
commit
33e66b5cd0
2 changed files with 46 additions and 14 deletions
|
@ -830,23 +830,19 @@ void NativeWindowMac::SetResizable(bool resizable) {
|
||||||
ScopedDisableResize disable_resize;
|
ScopedDisableResize disable_resize;
|
||||||
SetStyleMask(resizable, NSWindowStyleMaskResizable);
|
SetStyleMask(resizable, NSWindowStyleMaskResizable);
|
||||||
|
|
||||||
|
bool was_fullscreenable = IsFullScreenable();
|
||||||
|
|
||||||
// Right now, resizable and fullscreenable are decoupled in
|
// Right now, resizable and fullscreenable are decoupled in
|
||||||
// documentation and on Windows/Linux. Chromium disables
|
// documentation and on Windows/Linux. Chromium disables
|
||||||
// fullscreenability if resizability is false on macOS as well
|
// fullscreen collection behavior as well as the maximize traffic
|
||||||
// as disabling the maximize traffic light unless the window
|
// light in SetCanResize if resizability is false on macOS unless
|
||||||
// is both resizable and maximizable. To work around this, we want
|
// the window is both resizable and maximizable. We want consistent
|
||||||
// to match behavior on other platforms by disabiliting the maximize
|
// cross-platform behavior, so if resizability is disabled we disable
|
||||||
// button but keeping fullscreenability enabled.
|
// the maximize button and ensure fullscreenability matches user setting.
|
||||||
// TODO(codebytere): refactor this once we have a better solution.
|
|
||||||
SetCanResize(resizable);
|
SetCanResize(resizable);
|
||||||
if (!resizable) {
|
SetFullScreenable(was_fullscreenable);
|
||||||
SetFullScreenable(true);
|
[[window_ standardWindowButton:NSWindowZoomButton]
|
||||||
[[window_ standardWindowButton:NSWindowZoomButton] setEnabled:false];
|
setEnabled:resizable ? was_fullscreenable : false];
|
||||||
} else {
|
|
||||||
SetFullScreenable(true);
|
|
||||||
[[window_ standardWindowButton:NSWindowZoomButton]
|
|
||||||
setEnabled:IsFullScreenable()];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NativeWindowMac::IsResizable() {
|
bool NativeWindowMac::IsResizable() {
|
||||||
|
|
|
@ -5416,6 +5416,42 @@ describe('BrowserWindow module', () => {
|
||||||
expect(w.isFullScreenable()).to.be.true('isFullScreenable');
|
expect(w.isFullScreenable()).to.be.true('isFullScreenable');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('does not open non-fullscreenable child windows in fullscreen if parent is fullscreen', async () => {
|
||||||
|
const w = new BrowserWindow();
|
||||||
|
|
||||||
|
const enterFS = once(w, 'enter-full-screen');
|
||||||
|
w.setFullScreen(true);
|
||||||
|
await enterFS;
|
||||||
|
|
||||||
|
const child = new BrowserWindow({ parent: w, resizable: false, fullscreenable: false });
|
||||||
|
const shown = once(child, 'show');
|
||||||
|
await shown;
|
||||||
|
|
||||||
|
expect(child.resizable).to.be.false('resizable');
|
||||||
|
expect(child.fullScreen).to.be.false('fullscreen');
|
||||||
|
expect(child.fullScreenable).to.be.false('fullscreenable');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('is set correctly with different resizable values', async () => {
|
||||||
|
const w1 = new BrowserWindow({
|
||||||
|
resizable: false,
|
||||||
|
fullscreenable: false
|
||||||
|
});
|
||||||
|
|
||||||
|
const w2 = new BrowserWindow({
|
||||||
|
resizable: true,
|
||||||
|
fullscreenable: false
|
||||||
|
});
|
||||||
|
|
||||||
|
const w3 = new BrowserWindow({
|
||||||
|
fullscreenable: false
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(w1.isFullScreenable()).to.be.false('isFullScreenable');
|
||||||
|
expect(w2.isFullScreenable()).to.be.false('isFullScreenable');
|
||||||
|
expect(w3.isFullScreenable()).to.be.false('isFullScreenable');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
ifdescribe(process.platform === 'darwin')('isHiddenInMissionControl state', () => {
|
ifdescribe(process.platform === 'darwin')('isHiddenInMissionControl state', () => {
|
||||||
|
|
Loading…
Add table
Reference in a new issue