[PATCH 3/5] winemac.drv: Factor common cursor clipping methods into functions.
Tim Clem
tclem at codeweavers.com
Wed Jan 19 13:40:26 CST 2022
Signed-off-by: Tim Clem <tclem at codeweavers.com>
---
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 7c0b53e47d93..eaa243ae1a59 100644
--- a/dlls/winemac.drv/cocoa_cursorclipping.m
+++ b/dlls/winemac.drv/cocoa_cursorclipping.m
@@ -67,6 +67,29 @@ @implementation WarpRecord
@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 @@ - (void) dealloc
[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 @@ - (BOOL) stopClippingCursor
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
--
2.34.1
More information about the wine-devel
mailing list