Tim Clem : winemac.drv: Create a protocol to represent a cursor clipping handler.

Alexandre Julliard julliard at winehq.org
Fri Jan 21 15:54:49 CST 2022


Module: wine
Branch: master
Commit: 2e25ba489a182f0d530a2d29bfd7bb76ae036941
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=2e25ba489a182f0d530a2d29bfd7bb76ae036941

Author: Tim Clem <tclem at codeweavers.com>
Date:   Wed Jan 19 11:40:25 2022 -0800

winemac.drv: Create a protocol to represent a cursor clipping handler.

Signed-off-by: Tim Clem <tclem at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 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 @@ enum {
 
 
 @class WineEventQueue;
- at class WineEventTapClipCursorHandler;
 @class WineWindow;
+ at protocol WineClipCursorHandler;
 
 
 @interface WineApplicationController : NSObject <NSApplicationDelegate>
@@ -121,7 +121,7 @@ enum {
 
     NSTimeInterval lastSetCursorPositionTime;
 
-    WineEventTapClipCursorHandler* clipCursorHandler;
+    id<WineClipCursorHandler> 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 @@ static NSString* WineLocalizedString(unsigned int stringID)
 
         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 <AppKit/AppKit.h>
 
- at interface WineEventTapClipCursorHandler : NSObject
-{
-    BOOL clippingCursor;
-    CGRect cursorClipRect;
-    CFMachPortRef cursorClippingEventTap;
-    NSMutableArray* warpRecords;
-    CGPoint synthesizedLocation;
-    NSTimeInterval lastEventTapEventTime;
-}
+
+ at protocol WineClipCursorHandler <NSObject>
 
 @property (readonly, nonatomic) BOOL clippingCursor;
 @property (readonly, nonatomic) CGRect cursorClipRect;
@@ -41,6 +34,24 @@
 
     - (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
+
+
+ at interface WineEventTapClipCursorHandler : NSObject <WineClipCursorHandler>
+{
+    BOOL clippingCursor;
+    CGRect cursorClipRect;
+    CFMachPortRef cursorClippingEventTap;
+    NSMutableArray* warpRecords;
+    CGPoint synthesizedLocation;
+    NSTimeInterval lastEventTapEventTime;
+}
+
+ at end




More information about the wine-cvs mailing list