[PATCH 2/5] winemac.drv: Create a protocol to represent a cursor clipping handler.
Tim Clem
tclem at codeweavers.com
Wed Jan 19 13:40:25 CST 2022
Signed-off-by: Tim Clem <tclem at codeweavers.com>
---
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 4ddf2fb3babb..c1ddf079d47e 100644
--- a/dlls/winemac.drv/cocoa_app.h
+++ b/dlls/winemac.drv/cocoa_app.h
@@ -67,8 +67,8 @@
@class WineEventQueue;
- at class WineEventTapClipCursorHandler;
@class WineWindow;
+ at protocol WineClipCursorHandler;
@interface WineApplicationController : NSObject <NSApplicationDelegate>
@@ -121,7 +121,7 @@ @interface WineApplicationController : NSObject <NSApplicationDelegate>
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 b2d54bce9087..ac52a7425dd5 100644
--- a/dlls/winemac.drv/cocoa_app.m
+++ b/dlls/winemac.drv/cocoa_app.m
@@ -1145,10 +1145,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 132527e10396..7ce0529a1575 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) 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
+
+
+ at interface WineEventTapClipCursorHandler : NSObject <WineClipCursorHandler>
+{
+ BOOL clippingCursor;
+ CGRect cursorClipRect;
+ CFMachPortRef cursorClippingEventTap;
+ NSMutableArray* warpRecords;
+ CGPoint synthesizedLocation;
+ NSTimeInterval lastEventTapEventTime;
+}
+
+ at end
--
2.34.1
More information about the wine-devel
mailing list