Ken Thomases : winemac: Implement simpler way to find front Wine window.

Alexandre Julliard julliard at winehq.org
Fri May 17 14:24:33 CDT 2013


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

Author: Ken Thomases <ken at codeweavers.com>
Date:   Thu May 16 18:43:16 2013 -0500

winemac: Implement simpler way to find front Wine window.

This uses Cocoa and the window server to track windows and their z-order,
which is more reliable than our own tracking.

---

 dlls/winemac.drv/cocoa_app.h    |    1 +
 dlls/winemac.drv/cocoa_app.m    |   37 ++++++++++++++++++++-----------------
 dlls/winemac.drv/cocoa_window.m |    8 ++------
 3 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/dlls/winemac.drv/cocoa_app.h b/dlls/winemac.drv/cocoa_app.h
index 8ed9763..551635d 100644
--- a/dlls/winemac.drv/cocoa_app.h
+++ b/dlls/winemac.drv/cocoa_app.h
@@ -111,6 +111,7 @@ enum {
     - (void) wineWindow:(WineWindow*)window
                 ordered:(NSWindowOrderingMode)order
              relativeTo:(WineWindow*)otherWindow;
+    - (WineWindow*) frontWineWindow;
 
     - (BOOL) handleEvent:(NSEvent*)anEvent;
     - (void) didSendEvent:(NSEvent*)anEvent;
diff --git a/dlls/winemac.drv/cocoa_app.m b/dlls/winemac.drv/cocoa_app.m
index f9363c1..67984cd 100644
--- a/dlls/winemac.drv/cocoa_app.m
+++ b/dlls/winemac.drv/cocoa_app.m
@@ -486,6 +486,19 @@ int macdrv_err_on;
         }
     }
 
+    - (WineWindow*) frontWineWindow
+    {
+        NSNumber* windowNumber;
+        for (windowNumber in [NSWindow windowNumbersWithOptions:NSWindowNumberListAllSpaces])
+        {
+            NSWindow* window = [NSApp windowWithWindowNumber:[windowNumber integerValue]];
+            if ([window isKindOfClass:[WineWindow class]] && [window screen])
+                return (WineWindow*)window;
+        }
+
+        return nil;
+    }
+
     - (void) sendDisplaysChanged:(BOOL)activating
     {
         macdrv_event* event;
@@ -1613,10 +1626,6 @@ int macdrv_err_on;
      */
     - (void)applicationDidBecomeActive:(NSNotification *)notification
     {
-        WineWindow* window;
-        WineWindow* firstMinimized;
-        BOOL anyShowing;
-
         [self activateCursorClipping];
 
         [orderedWineWindows enumerateObjectsWithOptions:NSEnumerationReverse usingBlock:^(id obj, NSUInteger idx, BOOL *stop){
@@ -1625,23 +1634,17 @@ int macdrv_err_on;
                 [window setLevel:[window levelWhenActive]];
         }];
 
-        firstMinimized = nil;
-        anyShowing = FALSE;
-        for (window in orderedWineWindows)
+        if (![self frontWineWindow])
         {
-            if ([window isMiniaturized])
-            {
-                if (!firstMinimized)
-                    firstMinimized = window;
-            }
-            else if ([window isVisible])
+            for (WineWindow* window in [NSApp windows])
             {
-                anyShowing = TRUE;
-                break;
+                if ([window isKindOfClass:[WineWindow class]] && [window isMiniaturized])
+                {
+                    [window deminiaturize:self];
+                    break;
+                }
             }
         }
-        if (!anyShowing && firstMinimized)
-            [firstMinimized deminiaturize:self];
 
         // If a Wine process terminates abruptly while it has the display captured
         // and switched to a different resolution, Mac OS X will uncapture the
diff --git a/dlls/winemac.drv/cocoa_window.m b/dlls/winemac.drv/cocoa_window.m
index 3e60c84..6bc6183 100644
--- a/dlls/winemac.drv/cocoa_window.m
+++ b/dlls/winemac.drv/cocoa_window.m
@@ -1920,12 +1920,8 @@ int macdrv_send_text_input_event(int pressed, unsigned int flags, int repeat, in
         if (![window isKindOfClass:[WineWindow class]])
         {
             window = (WineWindow*)[NSApp mainWindow];
-            if (![window isKindOfClass:[WineWindow class]] && [[NSApp orderedWineWindows] count])
-            {
-                window = [[NSApp orderedWineWindows] objectAtIndex:0];
-                if (![window isKindOfClass:[WineWindow class]])
-                    window = nil;
-            }
+            if (![window isKindOfClass:[WineWindow class]])
+                window = [[WineApplicationController sharedController] frontWineWindow];
         }
 
         if (window)




More information about the wine-cvs mailing list