From af2690ab0664a9dfbad69fd6905d3a15dc8a499a Mon Sep 17 00:00:00 2001 From: Ken Thomases Date: Mon, 24 Apr 2017 13:07:09 -0500 Subject: [PATCH] winemac: Add a category on NSEvent to simplify checking if the Command key (and only that modifier) is pressed for an event. Signed-off-by: Ken Thomases Signed-off-by: Alexandre Julliard --- 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 6d1473ae5f3..f13e496db86 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 4d814a2f04c..72ff8f9c6d4 100644 --- a/dlls/winemac.drv/cocoa_event.h +++ b/dlls/winemac.drv/cocoa_event.h @@ -28,6 +28,12 @@ }; +@interface NSEvent (WineExtensions) + + (BOOL) wine_commandKeyDown; + - (BOOL) wine_commandKeyDown; +@end + + @class WineWindow; diff --git a/dlls/winemac.drv/cocoa_event.m b/dlls/winemac.drv/cocoa_event.m index 08a706fd8ba..40066ffda5e 100644 --- a/dlls/winemac.drv/cocoa_event.m +++ b/dlls/winemac.drv/cocoa_event.m @@ -40,6 +40,26 @@ static const OSType WineHotKeySignature = 'Wine'; +@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]); + } + +@end + + @interface MacDrvEvent : NSObject { @public