Skip to content
Snippets Groups Projects
Commit 325cc98d authored by Tim Clem's avatar Tim Clem Committed by Alexandre Julliard
Browse files

winemac.drv: Simplify cursor clipping code paths.


Centralizes all clipping behavior into -startClippingCursor: and
-stopClippingCursor.

Signed-off-by: default avatarTim Clem <tclem@codeweavers.com>
Signed-off-by: Alexandre Julliard's avatarAlexandre Julliard <julliard@winehq.org>
parent 0d8428fb
Branches
Tags
No related merge requests found
......@@ -1456,33 +1456,6 @@ - (BOOL) setCursorPosition:(CGPoint)pos
return ret;
}
- (void) activateCursorClipping
{
if (cursorClippingEventTap && !CGEventTapIsEnabled(cursorClippingEventTap))
{
CGEventTapEnable(cursorClippingEventTap, TRUE);
[self setCursorPosition:NSPointToCGPoint([self flippedMouseLocation:[NSEvent mouseLocation]])];
}
}
- (void) deactivateCursorClipping
{
if (cursorClippingEventTap && CGEventTapIsEnabled(cursorClippingEventTap))
{
CGEventTapEnable(cursorClippingEventTap, FALSE);
[warpRecords removeAllObjects];
lastSetCursorPositionTime = [[NSProcessInfo processInfo] systemUptime];
}
}
- (void) updateCursorClippingState
{
if (clippingCursor && [NSApp isActive] && ![windowsBeingDragged count])
[self activateCursorClipping];
else
[self deactivateCursorClipping];
}
- (void) updateWindowsForCursorClipping
{
WineWindow* window;
......@@ -1510,7 +1483,10 @@ - (BOOL) startClippingCursor:(CGRect)rect
clippingCursor = TRUE;
cursorClipRect = rect;
[self updateCursorClippingState];
CGEventTapEnable(cursorClippingEventTap, TRUE);
[self setCursorPosition:NSPointToCGPoint([self flippedMouseLocation:[NSEvent mouseLocation]])];
[self updateWindowsForCursorClipping];
return TRUE;
......@@ -1518,12 +1494,21 @@ - (BOOL) startClippingCursor:(CGRect)rect
- (BOOL) stopClippingCursor
{
CGError err = CGAssociateMouseAndMouseCursorPosition(true);
CGError err;
if (!clippingCursor)
return TRUE;
err = CGAssociateMouseAndMouseCursorPosition(true);
if (err != kCGErrorSuccess)
return FALSE;
clippingCursor = FALSE;
[self updateCursorClippingState];
CGEventTapEnable(cursorClippingEventTap, FALSE);
[warpRecords removeAllObjects];
lastSetCursorPositionTime = [[NSProcessInfo processInfo] systemUptime];
[self updateWindowsForCursorClipping];
return TRUE;
......@@ -1554,7 +1539,6 @@ - (void) window:(WineWindow*)window isBeingDragged:(BOOL)dragged
[windowsBeingDragged addObject:window];
else
[windowsBeingDragged removeObject:window];
[self updateCursorClippingState];
}
- (void) windowWillOrderOut:(WineWindow*)window
......@@ -1584,7 +1568,6 @@ - (void) handleWindowDrag:(WineWindow*)window begin:(BOOL)begin
[windowsBeingDragged removeObject:window];
eventType = WINDOW_DRAG_END;
}
[self updateCursorClippingState];
event = macdrv_create_event(eventType, window);
if (eventType == WINDOW_DRAG_BEGIN)
......@@ -2161,7 +2144,6 @@ - (void) setupObservations
});
}
[windowsBeingDragged removeObject:window];
[self updateCursorClippingState];
}];
if (useDragNotifications) {
......@@ -2305,8 +2287,6 @@ - (void)applicationDidBecomeActive:(NSNotification *)notification
[self setMode:mode forDisplay:[displayID unsignedIntValue]];
}
[self updateCursorClippingState];
[self updateFullscreenWindows];
[self adjustWindowLevels:YES];
......@@ -2349,8 +2329,6 @@ - (void)applicationDidResignActive:(NSNotification *)notification
macdrv_event* event;
WineEventQueue* queue;
[self updateCursorClippingState];
[self invalidateGotFocusEvents];
event = macdrv_create_event(APP_DEACTIVATED, nil);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment