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

Signed-off-by: Tim Clem <tclem@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Tim Clem 2022-01-19 11:40:25 -08:00 committed by Alexandre Julliard
parent 1c80eb5e5b
commit 2e25ba489a
3 changed files with 26 additions and 12 deletions

View file

@ -67,8 +67,8 @@
@class WineEventQueue;
@class WineEventTapClipCursorHandler;
@class WineWindow;
@protocol WineClipCursorHandler;
@interface WineApplicationController : NSObject <NSApplicationDelegate>
@ -121,7 +121,7 @@ @interface WineApplicationController : NSObject <NSApplicationDelegate>
NSTimeInterval lastSetCursorPositionTime;
WineEventTapClipCursorHandler* clipCursorHandler;
id<WineClipCursorHandler> clipCursorHandler;
NSImage* applicationIcon;

View file

@ -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

View file

@ -21,15 +21,8 @@
#import <AppKit/AppKit.h>
@interface WineEventTapClipCursorHandler : NSObject
{
BOOL clippingCursor;
CGRect cursorClipRect;
CFMachPortRef cursorClippingEventTap;
NSMutableArray* warpRecords;
CGPoint synthesizedLocation;
NSTimeInterval lastEventTapEventTime;
}
@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
@interface WineEventTapClipCursorHandler : NSObject <WineClipCursorHandler>
{
BOOL clippingCursor;
CGRect cursorClipRect;
CFMachPortRef cursorClippingEventTap;
NSMutableArray* warpRecords;
CGPoint synthesizedLocation;
NSTimeInterval lastEventTapEventTime;
}
@end