diff --git a/src/MacVim/MMFullscreenWindow.h b/src/MacVim/MMFullscreenWindow.h index 134224a5fe..6ac2008b71 100644 --- a/src/MacVim/MMFullscreenWindow.h +++ b/src/MacVim/MMFullscreenWindow.h @@ -19,6 +19,7 @@ MMVimView *view; NSPoint oldPosition; NSString *oldTabBarStyle; + int options; // These are only valid in fullscreen mode and store pre-fu vim size int nonFuRows, nonFuColumns; @@ -32,8 +33,8 @@ - (MMFullscreenWindow *)initWithWindow:(NSWindow *)t view:(MMVimView *)v backgroundColor:(NSColor *)back; - -- (void)enterFullscreen:(int)fuoptions; +- (void)setOptions:(int)opt; +- (void)enterFullscreen; - (void)leaveFullscreen; - (void)centerView; diff --git a/src/MacVim/MMFullscreenWindow.m b/src/MacVim/MMFullscreenWindow.m index 9480f5f8fe..3b1f10271b 100644 --- a/src/MacVim/MMFullscreenWindow.m +++ b/src/MacVim/MMFullscreenWindow.m @@ -107,8 +107,15 @@ [super dealloc]; } -- (void)enterFullscreen:(int)fuoptions +- (void)setOptions:(int)opt { + options = opt; +} + +- (void)enterFullscreen +{ + ASLogDebug(@"Enter full screen now"); + // fade to black Boolean didBlend = NO; CGDisplayFadeReservationToken token; @@ -117,7 +124,11 @@ kCGDisplayBlendSolidColor, .0, .0, .0, true); didBlend = YES; } - + + // NOTE: The window may have moved to another screen in between init.. and + // this call so set the frame again just in case. + [self setFrame:[[target screen] frame] display:NO]; + // fool delegate id delegate = [target delegate]; [target setDelegate:nil]; @@ -146,7 +157,7 @@ // focus gained message [self setDelegate:delegate]; - // resize vim view according to fuoptions + // resize vim view according to options int currRows, currColumns; [[view textView] getMaxRows:&currRows columns:&currColumns]; @@ -163,12 +174,12 @@ nonFuColumns = currColumns; // Compute current fu size - if (fuoptions & FUOPT_MAXVERT) + if (options & FUOPT_MAXVERT) fuRows = maxRows; - if (fuoptions & FUOPT_MAXHORZ) + if (options & FUOPT_MAXHORZ) fuColumns = maxColumns; - startFuFlags = fuoptions; + startFuFlags = options; // if necessary, resize vim to target fu size if (currRows != fuRows || currColumns != fuColumns) { diff --git a/src/MacVim/MMWindowController.m b/src/MacVim/MMWindowController.m index a0fb1bda1d..680adc3c43 100644 --- a/src/MacVim/MMWindowController.m +++ b/src/MacVim/MMWindowController.m @@ -273,6 +273,13 @@ [[MMAppController sharedInstance] windowControllerWillOpen:self]; [[self window] makeKeyAndOrderFront:self]; + if (fullscreenWindow) { + // Delayed entering of full screen happens here (a ":set fu" in a + // GUIEnter auto command could cause this). + [fullscreenWindow enterFullscreen]; + fullscreenEnabled = YES; + } + return YES; } @@ -607,17 +614,28 @@ { if (fullscreenEnabled) return; + // fullscreenWindow could be nil here if this is called multiple times + // during startup. + [fullscreenWindow release]; + fullscreenWindow = [[MMFullscreenWindow alloc] - initWithWindow:decoratedWindow view:vimView backgroundColor:back]; - [fullscreenWindow enterFullscreen:fuoptions]; - [fullscreenWindow setDelegate:self]; + initWithWindow:decoratedWindow view:vimView backgroundColor:back]; + [fullscreenWindow setOptions:fuoptions]; [fullscreenWindow setRepresentedFilename: [decoratedWindow representedFilename]]; - fullscreenEnabled = YES; - // The resize handle disappears so the vim view needs to update the - // scrollbars. - shouldResizeVimView = YES; + // If the window is not visible then delay entering full screen until the + // window is presented. + if ([decoratedWindow isVisible]) { + [fullscreenWindow enterFullscreen]; + fullscreenEnabled = YES; + + // The resize handle disappears so the vim view needs to update the + // scrollbars. + shouldResizeVimView = YES; + } else { + ASLogDebug(@"Delay enter full screen"); + } } - (void)leaveFullscreen @@ -635,7 +653,7 @@ - (void)setFullscreenBackgroundColor:(NSColor *)back { - if (fullscreenEnabled) + if (fullscreenWindow) [fullscreenWindow setBackgroundColor:back]; }