From 705cce16cb710fc38dbf4a73bec04b20475f064c Mon Sep 17 00:00:00 2001 From: Bjorn Winckler Date: Tue, 26 Jul 2011 14:43:34 +0200 Subject: [PATCH] Support "set fu" in gvimrc for Lion full screen --- src/MacVim/MMWindowController.h | 1 + src/MacVim/MMWindowController.m | 31 +++++++++++++++++++++++++------ 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/MacVim/MMWindowController.h b/src/MacVim/MMWindowController.h index f2af4319d9..001fcc38f4 100644 --- a/src/MacVim/MMWindowController.h +++ b/src/MacVim/MMWindowController.h @@ -35,6 +35,7 @@ NSString *windowAutosaveKey; MMFullscreenWindow *fullscreenWindow; int fullscreenOptions; + BOOL delayEnterFullscreen; NSRect preFullscreenFrame; MMWindow *decoratedWindow; NSString *lastSetTitle; diff --git a/src/MacVim/MMWindowController.m b/src/MacVim/MMWindowController.m index 82445f9c7e..22879e4ed3 100644 --- a/src/MacVim/MMWindowController.m +++ b/src/MacVim/MMWindowController.m @@ -298,6 +298,19 @@ // code to depend on the screen state. (Such as constraining views etc.) windowPresented = YES; +#if (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7) + if (delayEnterFullscreen) { + NSWindow *win = [self window]; + if ([win respondsToSelector:@selector(realToggleFullScreen:)]) { + // Set alpha to zero so that the decorated window doesn't pop up + // before we enter full screen. + [win setAlphaValue:0]; + [win performSelector:@selector(realToggleFullScreen:) + withObject:self]; + fullscreenEnabled = YES; + } + } +#endif if (fullscreenWindow) { // Delayed entering of full screen happens here (a ":set fu" in a // GUIEnter auto command could cause this). @@ -657,12 +670,16 @@ if (fullscreenEnabled) return; #if (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7) - NSWindow *win = [self window]; - if ([win respondsToSelector:@selector(realToggleFullScreen:)]) { - [win performSelector:@selector(realToggleFullScreen:) - withObject:self]; - fullscreenOptions = fuoptions; - fullscreenEnabled = YES; + fullscreenOptions = fuoptions; + if (windowPresented) { + NSWindow *win = [self window]; + if ([win respondsToSelector:@selector(realToggleFullScreen:)]) { + [win performSelector:@selector(realToggleFullScreen:) + withObject:self]; + fullscreenEnabled = YES; + } + } else { + delayEnterFullscreen = YES; } #else // fullscreenWindow could be nil here if this is called multiple times @@ -1084,6 +1101,7 @@ // TODO: Is this the correct way to deal with this message? ASLogNotice(@"Failed to ENTER full screen, restoring window frame..."); + [window setAlphaValue:1]; [window setStyleMask:([window styleMask] & ~NSFullScreenWindowMask)]; [[vimView tabBarControl] setStyleNamed:@"Metal"]; [window setFrame:preFullscreenFrame display:YES]; @@ -1131,6 +1149,7 @@ // TODO: Is this the correct way to deal with this message? ASLogNotice(@"Failed to EXIT full screen, maximizing window..."); + [window setAlphaValue:1]; [window setStyleMask:([window styleMask] | NSFullScreenWindowMask)]; [[vimView tabBarControl] setStyleNamed:@"Unified"]; [self maximizeWindow:fullscreenOptions];