Module: wine Branch: master Commit: 325cc98d7d3e77faa195e1043e9f6790a783fd1a URL: https://source.winehq.org/git/wine.git/?a=commit;h=325cc98d7d3e77faa195e1043...
Author: Tim Clem tclem@codeweavers.com Date: Tue Oct 19 14:21:09 2021 -0700
winemac.drv: Simplify cursor clipping code paths.
Centralizes all clipping behavior into -startClippingCursor: and -stopClippingCursor.
Signed-off-by: Tim Clem tclem@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/winemac.drv/cocoa_app.m | 52 +++++++++++++------------------------------- 1 file changed, 15 insertions(+), 37 deletions(-)
diff --git a/dlls/winemac.drv/cocoa_app.m b/dlls/winemac.drv/cocoa_app.m index 2d18da7f99a..80625265161 100644 --- a/dlls/winemac.drv/cocoa_app.m +++ b/dlls/winemac.drv/cocoa_app.m @@ -1456,33 +1456,6 @@ static NSString* WineLocalizedString(unsigned int stringID) 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 @@ static NSString* WineLocalizedString(unsigned int stringID)
clippingCursor = TRUE; cursorClipRect = rect; - [self updateCursorClippingState]; + + CGEventTapEnable(cursorClippingEventTap, TRUE); + [self setCursorPosition:NSPointToCGPoint([self flippedMouseLocation:[NSEvent mouseLocation]])]; + [self updateWindowsForCursorClipping];
return TRUE; @@ -1518,12 +1494,21 @@ static NSString* WineLocalizedString(unsigned int stringID)
- (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 @@ static NSString* WineLocalizedString(unsigned int stringID) [windowsBeingDragged addObject:window]; else [windowsBeingDragged removeObject:window]; - [self updateCursorClippingState]; }
- (void) windowWillOrderOut:(WineWindow*)window @@ -1584,7 +1568,6 @@ static NSString* WineLocalizedString(unsigned int stringID) [windowsBeingDragged removeObject:window]; eventType = WINDOW_DRAG_END; } - [self updateCursorClippingState];
event = macdrv_create_event(eventType, window); if (eventType == WINDOW_DRAG_BEGIN) @@ -2161,7 +2144,6 @@ static NSString* WineLocalizedString(unsigned int stringID) }); } [windowsBeingDragged removeObject:window]; - [self updateCursorClippingState]; }];
if (useDragNotifications) { @@ -2305,8 +2287,6 @@ static NSString* WineLocalizedString(unsigned int stringID) [self setMode:mode forDisplay:[displayID unsignedIntValue]]; }
- [self updateCursorClippingState]; - [self updateFullscreenWindows]; [self adjustWindowLevels:YES];
@@ -2349,8 +2329,6 @@ static NSString* WineLocalizedString(unsigned int stringID) macdrv_event* event; WineEventQueue* queue;
- [self updateCursorClippingState]; - [self invalidateGotFocusEvents];
event = macdrv_create_event(APP_DEACTIVATED, nil);