Module: wine Branch: master Commit: 5d8e6852978a3f0cc4edfdaa0ca78e76a5a0070c URL: http://source.winehq.org/git/wine.git/?a=commit;h=5d8e6852978a3f0cc4edfdaa0c...
Author: Ken Thomases ken@codeweavers.com Date: Sun Feb 24 22:53:37 2013 -0600
winemac: Request mouse move events when our window is active even when cursor is outside it.
---
dlls/winemac.drv/cocoa_app.m | 17 ++++++++++++++++- dlls/winemac.drv/cocoa_window.m | 3 +++ 2 files changed, 19 insertions(+), 1 deletions(-)
diff --git a/dlls/winemac.drv/cocoa_app.m b/dlls/winemac.drv/cocoa_app.m index 7e22221..47ec05c 100644 --- a/dlls/winemac.drv/cocoa_app.m +++ b/dlls/winemac.drv/cocoa_app.m @@ -565,7 +565,22 @@ int macdrv_err_on; { WineWindow* targetWindow;
- targetWindow = (WineWindow*)[anEvent window]; + /* Because of the way -[NSWindow setAcceptsMouseMovedEvents:] works, the + event indicates its window is the main window, even if the cursor is + over a different window. Find the actual WineWindow that is under the + cursor and post the event as being for that window. */ + if (type == NSMouseMoved) + { + CGPoint cgpoint = CGEventGetLocation([anEvent CGEvent]); + NSPoint point = [self flippedMouseLocation:NSPointFromCGPoint(cgpoint)]; + NSInteger windowUnderNumber; + + windowUnderNumber = [NSWindow windowNumberAtPoint:point + belowWindowWithWindowNumber:0]; + targetWindow = (WineWindow*)[self windowWithWindowNumber:windowUnderNumber]; + } + else + targetWindow = (WineWindow*)[anEvent window];
if ([targetWindow isKindOfClass:[WineWindow class]]) { diff --git a/dlls/winemac.drv/cocoa_window.m b/dlls/winemac.drv/cocoa_window.m index b8bc79d..204a0bc 100644 --- a/dlls/winemac.drv/cocoa_window.m +++ b/dlls/winemac.drv/cocoa_window.m @@ -273,6 +273,7 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers) [window disableCursorRects]; [window setShowsResizeIndicator:NO]; [window setHasShadow:wf->shadow]; + [window setAcceptsMouseMovedEvents:YES]; [window setColorSpace:[NSColorSpace genericRGBColorSpace]]; [window setDelegate:window]; window.hwnd = hwnd; @@ -283,6 +284,8 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers) return nil; [contentView setAutoresizesSubviews:NO];
+ /* We use tracking areas in addition to setAcceptsMouseMovedEvents:YES + because they give us mouse moves in the background. */ trackingArea = [[[NSTrackingArea alloc] initWithRect:[contentView bounds] options:(NSTrackingMouseMoved | NSTrackingActiveAlways |