From 86e5bd35525ad3c4afdb9cb22832cfbdd49628a6 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 15 Aug 2016 13:14:19 -0700 Subject: [PATCH] Disable resize during any stylemask change --- atom/browser/native_window_mac.mm | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index 8e8f988ee99..f1145348e8e 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -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];