Ken Thomases : winemac: Track whether our windows would be visible if the process weren't hidden.

Alexandre Julliard julliard at winehq.org
Tue Dec 31 11:11:45 CST 2013


Module: wine
Branch: master
Commit: ae4732360460914da61bedbed798511882d84719
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=ae4732360460914da61bedbed798511882d84719

Author: Ken Thomases <ken at codeweavers.com>
Date:   Tue Dec 31 01:05:09 2013 -0600

winemac: Track whether our windows would be visible if the process weren't hidden.

The -[NSWindow isVisible] method returns FALSE when the process is hidden,
but that's not what we need to know in some cases.

This fixes full-screen games which minimize their window when they lose
focus.  Command-Tabbing away hides the process.  Because the window was not
visible, the code didn't actually minimize it.  When switching back to the
process, no event was sent to the Wine back-end telling it the window had
been restored, so it never resumed drawing to it.

---

 dlls/winemac.drv/cocoa_window.h |    1 +
 dlls/winemac.drv/cocoa_window.m |   40 +++++++++++++++++++++++++++++++++-----
 2 files changed, 35 insertions(+), 6 deletions(-)

diff --git a/dlls/winemac.drv/cocoa_window.h b/dlls/winemac.drv/cocoa_window.h
index d3a244b..a74f6da 100644
--- a/dlls/winemac.drv/cocoa_window.h
+++ b/dlls/winemac.drv/cocoa_window.h
@@ -33,6 +33,7 @@
     BOOL maximized;
     BOOL fullscreen;
     BOOL pendingMinimize;
+    BOOL savedVisibleState;
     WineWindow* latentParentWindow;
     NSMutableArray* latentChildWindows;
 
diff --git a/dlls/winemac.drv/cocoa_window.m b/dlls/winemac.drv/cocoa_window.m
index 002e359..a025d59 100644
--- a/dlls/winemac.drv/cocoa_window.m
+++ b/dlls/winemac.drv/cocoa_window.m
@@ -543,6 +543,7 @@ static inline NSUInteger adjusted_modifiers_for_option_behavior(NSUInteger modif
         WineWindow* window;
         WineContentView* contentView;
         NSTrackingArea* trackingArea;
+        NSNotificationCenter* nc = [NSNotificationCenter defaultCenter];
 
         [[WineApplicationController sharedController] flipRect:&window_frame];
 
@@ -595,12 +596,21 @@ static inline NSUInteger adjusted_modifiers_for_option_behavior(NSUInteger modif
         [window setContentView:contentView];
         [window setInitialFirstResponder:contentView];
 
-        [[NSNotificationCenter defaultCenter] addObserver:window
-                                                 selector:@selector(updateFullscreen)
-                                                     name:NSApplicationDidChangeScreenParametersNotification
-                                                   object:NSApp];
+        [nc addObserver:window
+               selector:@selector(updateFullscreen)
+                   name:NSApplicationDidChangeScreenParametersNotification
+                 object:NSApp];
         [window updateFullscreen];
 
+        [nc addObserver:window
+               selector:@selector(applicationWillHide)
+                   name:NSApplicationWillHideNotification
+                 object:NSApp];
+        [nc addObserver:window
+               selector:@selector(applicationDidUnhide)
+                   name:NSApplicationDidUnhideNotification
+                 object:NSApp];
+
         return window;
     }
 
@@ -714,9 +724,15 @@ static inline NSUInteger adjusted_modifiers_for_option_behavior(NSUInteger modif
         [self setHasShadow:wf->shadow];
     }
 
+    // Indicates if the window would be visible if the app were not hidden.
+    - (BOOL) wouldBeVisible
+    {
+        return [NSApp isHidden] ? savedVisibleState : [self isVisible];
+    }
+
     - (BOOL) isOrderedIn
     {
-        return [self isVisible] || [self isMiniaturized];
+        return [self wouldBeVisible] || [self isMiniaturized];
     }
 
     - (NSInteger) minimumLevelForActive:(BOOL)active
@@ -827,7 +843,7 @@ static inline NSUInteger adjusted_modifiers_for_option_behavior(NSUInteger modif
             pendingMinimize = FALSE;
             if (state->minimized && ![self isMiniaturized])
             {
-                if ([self isVisible])
+                if ([self wouldBeVisible])
                 {
                     if ([self styleMask] & NSFullScreenWindowMask)
                     {
@@ -1198,6 +1214,7 @@ static inline NSUInteger adjusted_modifiers_for_option_behavior(NSUInteger modif
         }
         else
             [self orderOut:nil];
+        savedVisibleState = FALSE;
         if (wasVisible && wasOnActiveSpace && fullscreen)
             [controller updateFullscreenWindows];
         [controller adjustWindowLevels];
@@ -1637,6 +1654,17 @@ static inline NSUInteger adjusted_modifiers_for_option_behavior(NSUInteger modif
         }
     }
 
+    - (void) applicationWillHide
+    {
+        savedVisibleState = [self isVisible];
+    }
+
+    - (void) applicationDidUnhide
+    {
+        if ([self isVisible])
+            [self becameEligibleParentOrChild];
+    }
+
 
     /*
      * ---------- NSWindowDelegate methods ----------




More information about the wine-cvs mailing list