diff --git a/src/MacVim/MMWindowController.h b/src/MacVim/MMWindowController.h index 11b66de47f..df164d75a6 100644 --- a/src/MacVim/MMWindowController.h +++ b/src/MacVim/MMWindowController.h @@ -22,7 +22,7 @@ MMVimView *vimView; BOOL setupDone; BOOL shouldResizeVimView; - int shouldUpdateToolbar; + int updateToolbarFlag; BOOL keepOnScreen; BOOL fullscreenEnabled; NSString *windowAutosaveKey; diff --git a/src/MacVim/MMWindowController.m b/src/MacVim/MMWindowController.m index f62501d002..62f0ccf21e 100644 --- a/src/MacVim/MMWindowController.m +++ b/src/MacVim/MMWindowController.m @@ -453,10 +453,8 @@ keepOnScreen = NO; } - if (shouldUpdateToolbar != 0) { + if (updateToolbarFlag != 0) [self updateToolbar]; - shouldUpdateToolbar = 0; - } } - (void)showTabBar:(BOOL)on @@ -491,16 +489,16 @@ [toolbar setSizeMode:size]; [toolbar setDisplayMode:mode]; + // Positive flag shows toolbar, negative hides it. + updateToolbarFlag = on ? 1 : -1; + // NOTE: If the window is not visible we must toggle the toolbar // immediately, otherwise "set go-=T" in .gvimrc will lead to the toolbar // showing its hide animation every time a new window is opened. (See // processCommandQueueDidFinish for the reason why we need to delay // toggling the toolbar when the window is visible.) - if ([decoratedWindow isVisible]) { - shouldUpdateToolbar = on ? 1 : -1; - } else { + if (![decoratedWindow isVisible]) [self updateToolbar]; - } } - (void)setMouseShape:(int)shape @@ -1061,9 +1059,10 @@ - (void)updateToolbar { NSToolbar *toolbar = [decoratedWindow toolbar]; - if (!toolbar) return; + if (nil == toolbar || 0 == updateToolbarFlag) return; - BOOL on = shouldUpdateToolbar > 0 ? YES : NO; + // Positive flag shows toolbar, negative hides it. + BOOL on = updateToolbarFlag > 0 ? YES : NO; [toolbar setVisible:on]; if (([decoratedWindow styleMask] & NSTexturedBackgroundWindowMask) == 0) { @@ -1079,6 +1078,8 @@ // is visible (because it brings its own separator). [self hideTablineSeparator:![[vimView tabBarControl] isHidden]]; } + + updateToolbarFlag = 0; } @end // MMWindowController (Private)