Ken Thomases : winemac: Dispatch key events directly to window to be sure to get key-up events.

Alexandre Julliard julliard at winehq.org
Fri Jun 28 15:02:29 CDT 2013


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

Author: Ken Thomases <ken at codeweavers.com>
Date:   Thu Jun 27 21:16:35 2013 -0500

winemac: Dispatch key events directly to window to be sure to get key-up events.

For keys pressed in combination with Command, -[NSApplication sendEvent:]
simply doesn't pass the key-up event through to the window.

---

 dlls/winemac.drv/cocoa_app.m    |    6 ++++++
 dlls/winemac.drv/cocoa_window.h |    2 ++
 dlls/winemac.drv/cocoa_window.m |   15 +--------------
 3 files changed, 9 insertions(+), 14 deletions(-)

diff --git a/dlls/winemac.drv/cocoa_app.m b/dlls/winemac.drv/cocoa_app.m
index 25081db..461472b 100644
--- a/dlls/winemac.drv/cocoa_app.m
+++ b/dlls/winemac.drv/cocoa_app.m
@@ -1692,6 +1692,12 @@ int macdrv_err_on;
             [self handleScrollWheel:anEvent];
             ret = mouseCaptureWindow != nil;
         }
+        else if (type == NSKeyDown || type == NSKeyUp)
+        {
+            WineWindow* window = (WineWindow*)[anEvent window];
+            if ([window isKindOfClass:[WineWindow class]])
+                [window postKeyEvent:anEvent];
+        }
 
         return ret;
     }
diff --git a/dlls/winemac.drv/cocoa_window.h b/dlls/winemac.drv/cocoa_window.h
index c5a630f..e0e581b 100644
--- a/dlls/winemac.drv/cocoa_window.h
+++ b/dlls/winemac.drv/cocoa_window.h
@@ -68,4 +68,6 @@
     - (NSInteger) minimumLevelForActive:(BOOL)active;
     - (void) updateFullscreen;
 
+    - (void) postKeyEvent:(NSEvent *)theEvent;
+
 @end
diff --git a/dlls/winemac.drv/cocoa_window.m b/dlls/winemac.drv/cocoa_window.m
index d0ee81f..da97e6a 100644
--- a/dlls/winemac.drv/cocoa_window.m
+++ b/dlls/winemac.drv/cocoa_window.m
@@ -1182,24 +1182,11 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers)
         }
     }
 
-    - (void) sendEvent:(NSEvent*)event
-    {
-        /* NSWindow consumes certain key-down events as part of Cocoa's keyboard
-           interface control.  For example, Control-Tab switches focus among
-           views.  We want to bypass that feature, so directly route key-down
-           events to -keyDown:. */
-        if ([event type] == NSKeyDown)
-            [[self firstResponder] keyDown:event];
-        else
-            [super sendEvent:event];
-    }
-
 
     /*
      * ---------- NSResponder method overrides ----------
      */
-    - (void) keyDown:(NSEvent *)theEvent { [self postKeyEvent:theEvent]; }
-    - (void) keyUp:(NSEvent *)theEvent   { [self postKeyEvent:theEvent]; }
+    - (void) keyDown:(NSEvent *)theEvent { /* Need an implementation to avoid beeps */ }
 
     - (void) flagsChanged:(NSEvent *)theEvent
     {




More information about the wine-cvs mailing list