Ken Thomases : winemac: Maintain a list of which windows have been "key" ( focused) recently.

Alexandre Julliard julliard at winehq.org
Mon Jan 28 13:43:19 CST 2013


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

Author: Ken Thomases <ken at codeweavers.com>
Date:   Sun Jan 27 16:19:45 2013 -0600

winemac: Maintain a list of which windows have been "key" (focused) recently.

---

 dlls/winemac.drv/cocoa_app.h |    2 ++
 dlls/winemac.drv/cocoa_app.m |   31 ++++++++++++++++++++++++++++++-
 2 files changed, 32 insertions(+), 1 deletions(-)

diff --git a/dlls/winemac.drv/cocoa_app.h b/dlls/winemac.drv/cocoa_app.h
index 0955dea..40f9e9d 100644
--- a/dlls/winemac.drv/cocoa_app.h
+++ b/dlls/winemac.drv/cocoa_app.h
@@ -35,6 +35,8 @@
     NSLock*         eventQueuesLock;
 
     NSTimeInterval eventTimeAdjustment;
+
+    NSMutableArray* keyWindows;
 }
 
     - (void) transformProcessToForeground;
diff --git a/dlls/winemac.drv/cocoa_app.m b/dlls/winemac.drv/cocoa_app.m
index 638e642..c69f09e 100644
--- a/dlls/winemac.drv/cocoa_app.m
+++ b/dlls/winemac.drv/cocoa_app.m
@@ -34,7 +34,9 @@ int macdrv_err_on;
             eventQueues = [[NSMutableArray alloc] init];
             eventQueuesLock = [[NSLock alloc] init];
 
-            if (!eventQueues || !eventQueuesLock)
+            keyWindows = [[NSMutableArray alloc] init];
+
+            if (!eventQueues || !eventQueuesLock || !keyWindows)
             {
                 [self release];
                 return nil;
@@ -45,6 +47,7 @@ int macdrv_err_on;
 
     - (void) dealloc
     {
+        [keyWindows release];
         [eventQueues release];
         [eventQueuesLock release];
         [super dealloc];
@@ -118,6 +121,32 @@ int macdrv_err_on;
         return (eventTime + eventTimeAdjustment) * 1000;
     }
 
+
+    /*
+     * ---------- NSApplicationDelegate methods ----------
+     */
+    - (void)applicationWillFinishLaunching:(NSNotification *)notification
+    {
+        NSNotificationCenter* nc = [NSNotificationCenter defaultCenter];
+
+        [nc addObserverForName:NSWindowDidBecomeKeyNotification
+                        object:nil
+                         queue:nil
+                    usingBlock:^(NSNotification *note){
+            NSWindow* window = [note object];
+            [keyWindows removeObjectIdenticalTo:window];
+            [keyWindows insertObject:window atIndex:0];
+        }];
+
+        [nc addObserverForName:NSWindowWillCloseNotification
+                        object:nil
+                         queue:[NSOperationQueue mainQueue]
+                    usingBlock:^(NSNotification *note){
+            NSWindow* window = [note object];
+            [keyWindows removeObjectIdenticalTo:window];
+        }];
+    }
+
 @end
 
 /***********************************************************************




More information about the wine-cvs mailing list