winemac.drv: Factor common cursor clipping methods into functions.
Signed-off-by: Tim Clem <tclem@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
2e25ba489a
commit
7bd72959a3
|
@ -67,6 +67,29 @@ @implementation WarpRecord
|
||||||
@end;
|
@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
|
@implementation WineEventTapClipCursorHandler
|
||||||
|
|
||||||
@synthesize clippingCursor, cursorClipRect;
|
@synthesize clippingCursor, cursorClipRect;
|
||||||
|
@ -88,18 +111,6 @@ - (void) dealloc
|
||||||
[super 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
|
- (BOOL) warpCursorTo:(CGPoint*)newLocation from:(const CGPoint*)currentLocation
|
||||||
{
|
{
|
||||||
CGPoint oldLocation;
|
CGPoint oldLocation;
|
||||||
|
@ -341,13 +352,14 @@ - (BOOL) stopClippingCursor
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) clipCursorLocation:(CGPoint*)location
|
||||||
|
{
|
||||||
|
clip_cursor_location(cursorClipRect, location);
|
||||||
|
}
|
||||||
|
|
||||||
- (void) setRetinaMode:(int)mode
|
- (void) setRetinaMode:(int)mode
|
||||||
{
|
{
|
||||||
double scale = mode ? 0.5 : 2.0;
|
scale_rect_for_retina_mode(mode, &cursorClipRect);
|
||||||
cursorClipRect.origin.x *= scale;
|
|
||||||
cursorClipRect.origin.y *= scale;
|
|
||||||
cursorClipRect.size.width *= scale;
|
|
||||||
cursorClipRect.size.height *= scale;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
Loading…
Reference in New Issue