Merge pull request #6850 from electron/disable-resize-when-changing-style-mask
Disable all resizes when changing the window's style mask
This commit is contained in:
Коммит
79f35fa475
|
@ -160,7 +160,7 @@ bool ScopedDisableResize::disable_resize_ = false;
|
|||
|
||||
- (void)windowDidMove:(NSNotification*)notification {
|
||||
// TODO(zcbenz): Remove the alias after figuring out a proper
|
||||
// way to disptach move.
|
||||
// way to dispatch move.
|
||||
shell_->NotifyWindowMove();
|
||||
shell_->NotifyWindowMoved();
|
||||
}
|
||||
|
@ -321,6 +321,13 @@ bool ScopedDisableResize::disable_resize_ = false;
|
|||
return [super constrainFrameRect:frameRect toScreen:screen];
|
||||
}
|
||||
|
||||
- (void)setFrame:(NSRect)windowFrame display:(BOOL)displayViews {
|
||||
// constrainFrameRect is not called on hidden windows so disable adjusting
|
||||
// the frame directly when resize is disabled
|
||||
if (!ScopedDisableResize::IsResizeDisabled())
|
||||
[super setFrame:windowFrame display:displayViews];
|
||||
}
|
||||
|
||||
- (id)accessibilityAttributeValue:(NSString*)attribute {
|
||||
if (![attribute isEqualToString:@"AXChildren"])
|
||||
return [super accessibilityAttributeValue:attribute];
|
||||
|
@ -784,9 +791,6 @@ void NativeWindowMac::SetContentSizeConstraints(
|
|||
}
|
||||
|
||||
void NativeWindowMac::SetResizable(bool resizable) {
|
||||
// Change styleMask for frameless causes the window to change size, so we have
|
||||
// to explicitly disables that.
|
||||
ScopedDisableResize disable_resize;
|
||||
SetStyleMask(resizable, NSResizableWindowMask);
|
||||
}
|
||||
|
||||
|
@ -1201,6 +1205,10 @@ void NativeWindowMac::UpdateDraggableRegionViews(
|
|||
}
|
||||
|
||||
void NativeWindowMac::SetStyleMask(bool on, NSUInteger flag) {
|
||||
// Changing the styleMask of a frameless windows causes it to change size so
|
||||
// we explicitly disable resizing while setting it.
|
||||
ScopedDisableResize disable_resize;
|
||||
|
||||
bool was_maximizable = IsMaximizable();
|
||||
if (on)
|
||||
[window_ setStyleMask:[window_ styleMask] | flag];
|
||||
|
|
|
@ -751,6 +751,36 @@ describe('browser-window module', function () {
|
|||
})
|
||||
|
||||
describe('window states', function () {
|
||||
it('does not resize frameless windows when states change', function () {
|
||||
w.destroy()
|
||||
w = new BrowserWindow({
|
||||
frame: false,
|
||||
width: 300,
|
||||
height: 200,
|
||||
show: false
|
||||
})
|
||||
|
||||
w.setMinimizable(false)
|
||||
w.setMinimizable(true)
|
||||
assert.deepEqual(w.getSize(), [300, 200])
|
||||
|
||||
w.setResizable(false)
|
||||
w.setResizable(true)
|
||||
assert.deepEqual(w.getSize(), [300, 200])
|
||||
|
||||
w.setMaximizable(false)
|
||||
w.setMaximizable(true)
|
||||
assert.deepEqual(w.getSize(), [300, 200])
|
||||
|
||||
w.setFullScreenable(false)
|
||||
w.setFullScreenable(true)
|
||||
assert.deepEqual(w.getSize(), [300, 200])
|
||||
|
||||
w.setClosable(false)
|
||||
w.setClosable(true)
|
||||
assert.deepEqual(w.getSize(), [300, 200])
|
||||
})
|
||||
|
||||
describe('resizable state', function () {
|
||||
it('can be changed with resizable option', function () {
|
||||
w.destroy()
|
||||
|
|
Загрузка…
Ссылка в новой задаче