[PATCH 03/10] winemac: Add a category on NSEvent to simplify checking if the Command key (and only that modifier) is pressed for an event.

Ken Thomases ken at codeweavers.com
Mon Apr 24 13:07:09 CDT 2017


Signed-off-by: Ken Thomases <ken at codeweavers.com>
---
 dlls/winemac.drv/cocoa_app.m   |  2 +-
 dlls/winemac.drv/cocoa_event.h |  6 ++++++
 dlls/winemac.drv/cocoa_event.m | 20 ++++++++++++++++++++
 3 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/dlls/winemac.drv/cocoa_app.m b/dlls/winemac.drv/cocoa_app.m
index 6d1473a..f13e496 100644
--- a/dlls/winemac.drv/cocoa_app.m
+++ b/dlls/winemac.drv/cocoa_app.m
@@ -1653,7 +1653,7 @@ - (void) handleMouseButton:(NSEvent*)theEvent
 
         if ([window isKindOfClass:[WineWindow class]] &&
             type == NSLeftMouseDown &&
-            (([theEvent modifierFlags] & (NSShiftKeyMask | NSControlKeyMask| NSAlternateKeyMask | NSCommandKeyMask)) != NSCommandKeyMask))
+            ![theEvent wine_commandKeyDown])
         {
             NSWindowButton windowButton;
 
diff --git a/dlls/winemac.drv/cocoa_event.h b/dlls/winemac.drv/cocoa_event.h
index 4d814a2..72ff8f9 100644
--- a/dlls/winemac.drv/cocoa_event.h
+++ b/dlls/winemac.drv/cocoa_event.h
@@ -28,6 +28,12 @@
 };
 
 
+ at interface NSEvent (WineExtensions)
+    + (BOOL) wine_commandKeyDown;
+    - (BOOL) wine_commandKeyDown;
+ at end
+
+
 @class WineWindow;
 
 
diff --git a/dlls/winemac.drv/cocoa_event.m b/dlls/winemac.drv/cocoa_event.m
index 08a706f..40066ff 100644
--- a/dlls/winemac.drv/cocoa_event.m
+++ b/dlls/winemac.drv/cocoa_event.m
@@ -40,6 +40,26 @@
 static const OSType WineHotKeySignature = 'Wine';
 
 
+ at implementation NSEvent (WineExtensions)
+
+    static BOOL wine_commandKeyDown(NSUInteger flags)
+    {
+        return ((flags & (NSShiftKeyMask | NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask)) == NSCommandKeyMask);
+    }
+
+    + (BOOL) wine_commandKeyDown
+    {
+        return wine_commandKeyDown([self modifierFlags]);
+    }
+
+    - (BOOL) wine_commandKeyDown
+    {
+        return wine_commandKeyDown([self modifierFlags]);
+    }
+
+ at end
+
+
 @interface MacDrvEvent : NSObject
 {
 @public
-- 
2.10.2




More information about the wine-patches mailing list