winemac: Consolidate the logic for deciding if cursor clipping should be active.

This commit is contained in:
Ken Thomases 2013-12-11 12:50:23 -06:00 committed by Alexandre Julliard
parent e3dd277586
commit cd10a0df5e
1 changed files with 15 additions and 8 deletions

View File

@ -1316,7 +1316,7 @@ - (BOOL) setCursorPosition:(CGPoint)pos
- (void) activateCursorClipping
{
if (clippingCursor)
if (cursorClippingEventTap && !CGEventTapIsEnabled(cursorClippingEventTap))
{
CGEventTapEnable(cursorClippingEventTap, TRUE);
[self setCursorPosition:NSPointToCGPoint([self flippedMouseLocation:[NSEvent mouseLocation]])];
@ -1325,7 +1325,7 @@ - (void) activateCursorClipping
- (void) deactivateCursorClipping
{
if (clippingCursor)
if (cursorClippingEventTap && CGEventTapIsEnabled(cursorClippingEventTap))
{
CGEventTapEnable(cursorClippingEventTap, FALSE);
[warpRecords removeAllObjects];
@ -1333,6 +1333,14 @@ - (void) deactivateCursorClipping
}
}
- (void) updateCursorClippingState
{
if (clippingCursor && [NSApp isActive])
[self activateCursorClipping];
else
[self deactivateCursorClipping];
}
- (BOOL) startClippingCursor:(CGRect)rect
{
CGError err;
@ -1346,8 +1354,7 @@ - (BOOL) startClippingCursor:(CGRect)rect
clippingCursor = TRUE;
cursorClipRect = rect;
if ([NSApp isActive])
[self activateCursorClipping];
[self updateCursorClippingState];
return TRUE;
}
@ -1358,8 +1365,8 @@ - (BOOL) stopClippingCursor
if (err != kCGErrorSuccess)
return FALSE;
[self deactivateCursorClipping];
clippingCursor = FALSE;
[self updateCursorClippingState];
return TRUE;
}
@ -2012,7 +2019,7 @@ - (void)applicationDidBecomeActive:(NSNotification *)notification
}
[latentDisplayModes removeAllObjects];
[self activateCursorClipping];
[self updateCursorClippingState];
[self updateFullscreenWindows];
[self adjustWindowLevels:YES];
@ -2056,6 +2063,8 @@ - (void)applicationDidResignActive:(NSNotification *)notification
macdrv_event* event;
WineEventQueue* queue;
[self updateCursorClippingState];
[self invalidateGotFocusEvents];
event = macdrv_create_event(APP_DEACTIVATED, nil);
@ -2123,8 +2132,6 @@ - (NSApplicationTerminateReply) applicationShouldTerminate:(NSApplication *)send
- (void)applicationWillResignActive:(NSNotification *)notification
{
[self deactivateCursorClipping];
[self adjustWindowLevels:NO];
}