Tim Clem : winemac.drv: Factor common cursor clipping methods into functions.
Alexandre Julliard
julliard at winehq.org
Fri Jan 21 15:54:49 CST 2022
Module: wine
Branch: master
Commit: 7bd72959a3d686d1f586eacf563adeaaa1a2f3f7
URL: https://source.winehq.org/git/wine.git/?a=commit;h=7bd72959a3d686d1f586eacf563adeaaa1a2f3f7
Author: Tim Clem <tclem at codeweavers.com>
Date: Wed Jan 19 11:40:26 2022 -0800
winemac.drv: Factor common cursor clipping methods into functions.
Signed-off-by: Tim Clem <tclem at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/winemac.drv/cocoa_cursorclipping.m | 46 +++++++++++++++++++++------------
1 file changed, 29 insertions(+), 17 deletions(-)
diff --git a/dlls/winemac.drv/cocoa_cursorclipping.m b/dlls/winemac.drv/cocoa_cursorclipping.m
index 7c0b53e47d9..eaa243ae1a5 100644
--- a/dlls/winemac.drv/cocoa_cursorclipping.m
+++ b/dlls/winemac.drv/cocoa_cursorclipping.m
@@ -67,6 +67,29 @@
@end;
+static void clip_cursor_location(CGRect cursorClipRect, CGPoint *location)
+{
+ if (location->x < CGRectGetMinX(cursorClipRect))
+ location->x = CGRectGetMinX(cursorClipRect);
+ if (location->y < CGRectGetMinY(cursorClipRect))
+ location->y = CGRectGetMinY(cursorClipRect);
+ if (location->x > CGRectGetMaxX(cursorClipRect) - 1)
+ location->x = CGRectGetMaxX(cursorClipRect) - 1;
+ if (location->y > CGRectGetMaxY(cursorClipRect) - 1)
+ location->y = CGRectGetMaxY(cursorClipRect) - 1;
+}
+
+
+static void scale_rect_for_retina_mode(int mode, CGRect *cursorClipRect)
+{
+ double scale = mode ? 0.5 : 2.0;
+ cursorClipRect->origin.x *= scale;
+ cursorClipRect->origin.y *= scale;
+ cursorClipRect->size.width *= scale;
+ cursorClipRect->size.height *= scale;
+}
+
+
@implementation WineEventTapClipCursorHandler
@synthesize clippingCursor, cursorClipRect;
@@ -88,18 +111,6 @@
[super dealloc];
}
- - (void) clipCursorLocation:(CGPoint*)location
- {
- if (location->x < CGRectGetMinX(cursorClipRect))
- location->x = CGRectGetMinX(cursorClipRect);
- if (location->y < CGRectGetMinY(cursorClipRect))
- location->y = CGRectGetMinY(cursorClipRect);
- if (location->x > CGRectGetMaxX(cursorClipRect) - 1)
- location->x = CGRectGetMaxX(cursorClipRect) - 1;
- if (location->y > CGRectGetMaxY(cursorClipRect) - 1)
- location->y = CGRectGetMaxY(cursorClipRect) - 1;
- }
-
- (BOOL) warpCursorTo:(CGPoint*)newLocation from:(const CGPoint*)currentLocation
{
CGPoint oldLocation;
@@ -341,13 +352,14 @@
return TRUE;
}
+ - (void) clipCursorLocation:(CGPoint*)location
+ {
+ clip_cursor_location(cursorClipRect, location);
+ }
+
- (void) setRetinaMode:(int)mode
{
- double scale = mode ? 0.5 : 2.0;
- cursorClipRect.origin.x *= scale;
- cursorClipRect.origin.y *= scale;
- cursorClipRect.size.width *= scale;
- cursorClipRect.size.height *= scale;
+ scale_rect_for_retina_mode(mode, &cursorClipRect);
}
@end
More information about the wine-cvs
mailing list