Module: wine Branch: master Commit: 1c049e5031ff6ca3dc2ee874493aa6e685e8e9c2 URL: http://source.winehq.org/git/wine.git/?a=commit;h=1c049e5031ff6ca3dc2ee87449...
Author: Ken Thomases ken@codeweavers.com Date: Thu Oct 17 23:45:52 2013 -0500
winemac: Restore app cursor settings when cursor moves back into an app window.
The code had previously set the cursor back to the standard arrow and unhid it when it left all app windows. Now it restores the cursor image that the app set and re-hides it if necessary when it moves back over any app window.
---
dlls/winemac.drv/cocoa_app.h | 3 ++ dlls/winemac.drv/cocoa_app.m | 80 ++++++++++++++++++++++++++++++++--------- 2 files changed, 65 insertions(+), 18 deletions(-)
diff --git a/dlls/winemac.drv/cocoa_app.h b/dlls/winemac.drv/cocoa_app.h index a398bf1..07a4bc8 100644 --- a/dlls/winemac.drv/cocoa_app.h +++ b/dlls/winemac.drv/cocoa_app.h @@ -73,7 +73,10 @@ enum { NSArray* cursorFrames; int cursorFrame; NSTimer* cursorTimer; + NSCursor* cursor; + BOOL cursorIsCurrent; BOOL cursorHidden; + BOOL clientWantsCursorHidden;
BOOL clippingCursor; CGRect cursorClipRect; diff --git a/dlls/winemac.drv/cocoa_app.m b/dlls/winemac.drv/cocoa_app.m index 92e16ff..e888a50 100644 --- a/dlls/winemac.drv/cocoa_app.m +++ b/dlls/winemac.drv/cocoa_app.m @@ -80,6 +80,7 @@ int macdrv_err_on; @property (readwrite, copy, nonatomic) NSEvent* lastFlagsChanged; @property (copy, nonatomic) NSArray* cursorFrames; @property (retain, nonatomic) NSTimer* cursorTimer; +@property (retain, nonatomic) NSCursor* cursor; @property (retain, nonatomic) NSImage* applicationIcon; @property (readonly, nonatomic) BOOL inputSourceIsInputMethod; @property (retain, nonatomic) WineWindow* mouseCaptureWindow; @@ -96,7 +97,7 @@ int macdrv_err_on;
@synthesize keyboardType, lastFlagsChanged; @synthesize applicationIcon; - @synthesize cursorFrames, cursorTimer; + @synthesize cursorFrames, cursorTimer, cursor; @synthesize mouseCaptureWindow;
+ (void) initialize @@ -172,6 +173,7 @@ int macdrv_err_on;
- (void) dealloc { + [cursor release]; [screenFrameCGRects release]; [applicationIcon release]; [warpRecords release]; @@ -785,21 +787,69 @@ int macdrv_err_on; return ([originalDisplayModes count] > 0 || displaysCapturedForFullscreen); }
+ - (void) updateCursor + { + if (lastTargetWindow) + { + if (clientWantsCursorHidden && !cursorHidden) + { + [NSCursor hide]; + cursorHidden = TRUE; + } + + if (!cursorIsCurrent) + { + [cursor set]; + cursorIsCurrent = TRUE; + } + + if (!clientWantsCursorHidden && cursorHidden) + { + [NSCursor unhide]; + cursorHidden = FALSE; + } + } + else + { + if (cursorIsCurrent) + { + [[NSCursor arrowCursor] set]; + cursorIsCurrent = FALSE; + } + if (cursorHidden) + { + [NSCursor unhide]; + cursorHidden = FALSE; + } + } + } + - (void) hideCursor { - if (!cursorHidden) + if (!clientWantsCursorHidden) { - [NSCursor hide]; - cursorHidden = TRUE; + clientWantsCursorHidden = TRUE; + [self updateCursor]; } }
- (void) unhideCursor { - if (cursorHidden) + if (clientWantsCursorHidden) { - [NSCursor unhide]; - cursorHidden = FALSE; + clientWantsCursorHidden = FALSE; + [self updateCursor]; + } + } + + - (void) setCursor:(NSCursor*)newCursor + { + if (newCursor != cursor) + { + [cursor release]; + cursor = [newCursor retain]; + cursorIsCurrent = FALSE; + [self updateCursor]; } }
@@ -810,15 +860,12 @@ int macdrv_err_on; NSImage* image = [[NSImage alloc] initWithCGImage:cgimage size:NSZeroSize]; CFDictionaryRef hotSpotDict = (CFDictionaryRef)[frame objectForKey:@"hotSpot"]; CGPoint hotSpot; - NSCursor* cursor;
if (!CGPointMakeWithDictionaryRepresentation(hotSpotDict, &hotSpot)) hotSpot = CGPointZero; - cursor = [[NSCursor alloc] initWithImage:image hotSpot:NSPointFromCGPoint(hotSpot)]; + self.cursor = [[[NSCursor alloc] initWithImage:image hotSpot:NSPointFromCGPoint(hotSpot)] autorelease]; [image release]; - [cursor set]; [self unhideCursor]; - [cursor release]; }
- (void) nextCursorFrame:(NSTimer*)theTimer @@ -1466,12 +1513,10 @@ int macdrv_err_on;
lastTargetWindow = targetWindow; } - else if (lastTargetWindow) - { - [[NSCursor arrowCursor] set]; - [self unhideCursor]; + else lastTargetWindow = nil; - } + + [self updateCursor]; }
- (void) handleMouseButton:(NSEvent*)theEvent @@ -2247,9 +2292,8 @@ void macdrv_set_cursor(CFStringRef name, CFArrayRef frames) { OnMainThreadAsync(^{ WineApplicationController* controller = [WineApplicationController sharedController]; - NSCursor* cursor = [NSCursor performSelector:sel]; [controller setCursorWithFrames:nil]; - [cursor set]; + controller.cursor = [NSCursor performSelector:sel]; [controller unhideCursor]; }); }