Merge pull request #6736 from electron/maximizable-state
Always restore maximizable state after changing window behavior/style
This commit is contained in:
commit
3be68ba136
2 changed files with 18 additions and 9 deletions
|
@ -591,11 +591,9 @@ NativeWindowMac::NativeWindowMac(
|
||||||
|
|
||||||
InstallView();
|
InstallView();
|
||||||
|
|
||||||
// Disable zoom button if window is not resizable.
|
|
||||||
// Set maximizable state last to ensure zoom button does not get reset
|
// Set maximizable state last to ensure zoom button does not get reset
|
||||||
// by calls to other APIs.
|
// by calls to other APIs.
|
||||||
if (!maximizable)
|
SetMaximizable(maximizable);
|
||||||
SetMaximizable(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NativeWindowMac::~NativeWindowMac() {
|
NativeWindowMac::~NativeWindowMac() {
|
||||||
|
@ -1178,27 +1176,25 @@ void NativeWindowMac::UpdateDraggableRegionViews(
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowMac::SetStyleMask(bool on, NSUInteger flag) {
|
void NativeWindowMac::SetStyleMask(bool on, NSUInteger flag) {
|
||||||
bool zoom_button_enabled = IsMaximizable();
|
bool was_maximizable = IsMaximizable();
|
||||||
if (on)
|
if (on)
|
||||||
[window_ setStyleMask:[window_ styleMask] | flag];
|
[window_ setStyleMask:[window_ styleMask] | flag];
|
||||||
else
|
else
|
||||||
[window_ setStyleMask:[window_ styleMask] & (~flag)];
|
[window_ setStyleMask:[window_ styleMask] & (~flag)];
|
||||||
// Change style mask will make the zoom button revert to default, probably
|
// Change style mask will make the zoom button revert to default, probably
|
||||||
// a bug of Cocoa or macOS.
|
// a bug of Cocoa or macOS.
|
||||||
if (!zoom_button_enabled)
|
SetMaximizable(was_maximizable);
|
||||||
SetMaximizable(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowMac::SetCollectionBehavior(bool on, NSUInteger flag) {
|
void NativeWindowMac::SetCollectionBehavior(bool on, NSUInteger flag) {
|
||||||
bool zoom_button_enabled = IsMaximizable();
|
bool was_maximizable = IsMaximizable();
|
||||||
if (on)
|
if (on)
|
||||||
[window_ setCollectionBehavior:[window_ collectionBehavior] | flag];
|
[window_ setCollectionBehavior:[window_ collectionBehavior] | flag];
|
||||||
else
|
else
|
||||||
[window_ setCollectionBehavior:[window_ collectionBehavior] & (~flag)];
|
[window_ setCollectionBehavior:[window_ collectionBehavior] & (~flag)];
|
||||||
// Change collectionBehavior will make the zoom button revert to default,
|
// Change collectionBehavior will make the zoom button revert to default,
|
||||||
// probably a bug of Cocoa or macOS.
|
// probably a bug of Cocoa or macOS.
|
||||||
if (!zoom_button_enabled)
|
SetMaximizable(was_maximizable);
|
||||||
SetMaximizable(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
|
|
|
@ -738,6 +738,10 @@ describe('browser-window module', function () {
|
||||||
w.destroy()
|
w.destroy()
|
||||||
w = new BrowserWindow({show: false, resizable: false})
|
w = new BrowserWindow({show: false, resizable: false})
|
||||||
assert.equal(w.isResizable(), false)
|
assert.equal(w.isResizable(), false)
|
||||||
|
|
||||||
|
if (process.platform === 'darwin') {
|
||||||
|
assert.equal(w.isMaximizable(), true)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can be changed with setResizable method', function () {
|
it('can be changed with setResizable method', function () {
|
||||||
|
@ -846,6 +850,15 @@ describe('browser-window module', function () {
|
||||||
assert.equal(w.isMaximizable(), false)
|
assert.equal(w.isMaximizable(), false)
|
||||||
w.setClosable(false)
|
w.setClosable(false)
|
||||||
assert.equal(w.isMaximizable(), false)
|
assert.equal(w.isMaximizable(), false)
|
||||||
|
|
||||||
|
w.setMaximizable(true)
|
||||||
|
assert.equal(w.isMaximizable(), true)
|
||||||
|
w.setClosable(true)
|
||||||
|
assert.equal(w.isMaximizable(), true)
|
||||||
|
w.setFullScreenable(false)
|
||||||
|
assert.equal(w.isMaximizable(), true)
|
||||||
|
w.setResizable(false)
|
||||||
|
assert.equal(w.isMaximizable(), true)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue