Permalink
Browse files

Fix window restore on enter full-screen failure

  • Loading branch information...
1 parent 8b7a78a commit 871d6fb68d4b87c838a32b6753725fcb9c4bc743 @b4winckler b4winckler committed Jul 27, 2011
Showing with 19 additions and 10 deletions.
  1. +2 −2 src/MacVim/MMTextViewHelper.m
  2. +17 −8 src/MacVim/MMWindowController.m
@@ -809,12 +809,12 @@ - (void)setImControl:(BOOL)enable
#endif
imControl = enable;
- ASLogInfo(@"IM control %sabled", enable ? "en" : "dis");
+ ASLogDebug(@"IM control %sabled", enable ? "en" : "dis");
}
- (void)activateIm:(BOOL)enable
{
- ASLogInfo(@"Activate IM=%d", enable);
+ ASLogDebug(@"Activate IM=%d", enable);
// HACK: If there is marked text when switching IM it will be inserted as
// normal text. To avoid this we abandon the marked text before switching.
@@ -735,7 +735,7 @@ - (void)enterFullscreen:(int)fuoptions backgroundColor:(NSColor *)back
if (useNativeFullScreen) {
// Enter native full-screen mode. Only supported on Mac OS X 10.7+.
- ASLogDebug(@"Enter native full-screen");
+ ASLogInfo(@"Enter native full-screen");
fullscreenOptions = fuoptions;
if (windowPresented) {
@@ -746,7 +746,7 @@ - (void)enterFullscreen:(int)fuoptions backgroundColor:(NSColor *)back
}
} else {
// Enter custom full-screen mode. Always supported.
- ASLogDebug(@"Enter custom full-screen");
+ ASLogInfo(@"Enter custom full-screen");
// fullscreenWindow could be non-nil here if this is called multiple
// times during startup.
@@ -777,7 +777,7 @@ - (void)leaveFullscreen
{
if (!fullscreenEnabled) return;
- ASLogDebug(@"Exit full-screen");
+ ASLogInfo(@"Exit full-screen");
if (fullscreenWindow) {
// Using custom full-screen
@@ -1139,9 +1139,6 @@ - (NSArray *)customWindowsToEnterFullScreenForWindow:(NSWindow *)window
- (void)window:(NSWindow *)window
startCustomAnimationToEnterFullScreenWithDuration:(NSTimeInterval)duration
{
- // Store window frame and use it when exiting full-screen.
- preFullscreenFrame = [window frame];
-
// Fade out window, remove title bar and maximize, then fade back in.
// (There is a small delay before window is maximized but usually this is
// not noticeable on a relatively modern Mac.)
@@ -1162,11 +1159,21 @@ - (void)window:(NSWindow *)window
}];
}
+- (void)windowWillEnterFullScreen:(NSNotification *)notification
+{
+ // Store window frame and use it when exiting full-screen.
+ preFullscreenFrame = [decoratedWindow frame];
+}
+
- (void)windowDidFailToEnterFullScreen:(NSWindow *)window
{
- // TODO: Is this the correct way to deal with this message?
+ // NOTE: This message can be called without
+ // window:startCustomAnimationToEnterFullScreenWithDuration: ever having
+ // been called so any state to store before entering full-screen must be
+ // stored in windowWillEnterFullScreen: which always gets called.
ASLogNotice(@"Failed to ENTER full-screen, restoring window frame...");
+ fullscreenEnabled = NO;
[window setAlphaValue:1];
[window setStyleMask:([window styleMask] & ~NSFullScreenWindowMask)];
[[vimView tabBarControl] setStyleNamed:@"Metal"];
@@ -1212,9 +1219,11 @@ - (void)window:(NSWindow *)window
- (void)windowDidFailToExitFullScreen:(NSWindow *)window
{
- // TODO: Is this the correct way to deal with this message?
+ // TODO: Is this the correct way to deal with this message? Are we still
+ // in full-screen at this point?
ASLogNotice(@"Failed to EXIT full-screen, maximizing window...");
+ fullscreenEnabled = YES;
[window setAlphaValue:1];
[window setStyleMask:([window styleMask] | NSFullScreenWindowMask)];
[[vimView tabBarControl] setStyleNamed:@"Unified"];

0 comments on commit 871d6fb

Please sign in to comment.