From 2e25ba489a182f0d530a2d29bfd7bb76ae036941 Mon Sep 17 00:00:00 2001 From: Tim Clem Date: Wed, 19 Jan 2022 11:40:25 -0800 Subject: [PATCH] winemac.drv: Create a protocol to represent a cursor clipping handler. Signed-off-by: Tim Clem Signed-off-by: Alexandre Julliard --- dlls/winemac.drv/cocoa_app.h | 4 ++-- dlls/winemac.drv/cocoa_app.m | 5 ++++- dlls/winemac.drv/cocoa_cursorclipping.h | 29 +++++++++++++++++-------- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/dlls/winemac.drv/cocoa_app.h b/dlls/winemac.drv/cocoa_app.h index cf01844dd84..e5caad00a87 100644 --- a/dlls/winemac.drv/cocoa_app.h +++ b/dlls/winemac.drv/cocoa_app.h @@ -67,8 +67,8 @@ @class WineEventQueue; -@class WineEventTapClipCursorHandler; @class WineWindow; +@protocol WineClipCursorHandler; @interface WineApplicationController : NSObject @@ -121,7 +121,7 @@ @interface WineApplicationController : NSObject NSTimeInterval lastSetCursorPositionTime; - WineEventTapClipCursorHandler* clipCursorHandler; + id clipCursorHandler; NSImage* applicationIcon; diff --git a/dlls/winemac.drv/cocoa_app.m b/dlls/winemac.drv/cocoa_app.m index 5443893b835..b0dd36f4abc 100644 --- a/dlls/winemac.drv/cocoa_app.m +++ b/dlls/winemac.drv/cocoa_app.m @@ -1148,10 +1148,13 @@ - (BOOL) setCursorPosition:(CGPoint)pos if ([windowsBeingDragged count]) ret = FALSE; - else if (self.clippingCursor) + else if (self.clippingCursor && [clipCursorHandler respondsToSelector:@selector(setCursorPosition:)]) ret = [clipCursorHandler setCursorPosition:pos]; else { + if (self.clippingCursor) + [clipCursorHandler clipCursorLocation:&pos]; + // Annoyingly, CGWarpMouseCursorPosition() effectively disassociates // the mouse from the cursor position for 0.25 seconds. This means // that mouse movement during that interval doesn't move the cursor diff --git a/dlls/winemac.drv/cocoa_cursorclipping.h b/dlls/winemac.drv/cocoa_cursorclipping.h index 132527e1039..7ce0529a157 100644 --- a/dlls/winemac.drv/cocoa_cursorclipping.h +++ b/dlls/winemac.drv/cocoa_cursorclipping.h @@ -21,15 +21,8 @@ #import -@interface WineEventTapClipCursorHandler : NSObject -{ - BOOL clippingCursor; - CGRect cursorClipRect; - CFMachPortRef cursorClippingEventTap; - NSMutableArray* warpRecords; - CGPoint synthesizedLocation; - NSTimeInterval lastEventTapEventTime; -} + +@protocol WineClipCursorHandler @property (readonly, nonatomic) BOOL clippingCursor; @property (readonly, nonatomic) CGRect cursorClipRect; @@ -41,6 +34,24 @@ - (void) clipCursorLocation:(CGPoint*)location; - (void) setRetinaMode:(int)mode; + @optional + /* If provided, should reposition the cursor as needed given the current + * clipping rect. If not provided, the location will be clipped by + * -clipCursorLocation, and the cursor will be warped normally. + */ - (BOOL) setCursorPosition:(CGPoint)pos; @end + + +@interface WineEventTapClipCursorHandler : NSObject +{ + BOOL clippingCursor; + CGRect cursorClipRect; + CFMachPortRef cursorClippingEventTap; + NSMutableArray* warpRecords; + CGPoint synthesizedLocation; + NSTimeInterval lastEventTapEventTime; +} + +@end