Module: wine Branch: master Commit: c043587d56e7950a79bd04ffdefe46143b935e48 URL: http://source.winehq.org/git/wine.git/?a=commit;h=c043587d56e7950a79bd04ffde...
Author: Ken Thomases ken@codeweavers.com Date: Tue Oct 8 02:21:34 2013 -0500
winemac: Tell Wine when Cocoa has brought a window to the front.
---
dlls/winemac.drv/cocoa_app.m | 8 ++++++-- dlls/winemac.drv/cocoa_window.h | 3 +++ dlls/winemac.drv/cocoa_window.m | 31 ++++++++++++++++++++++++++++--- dlls/winemac.drv/event.c | 5 +++++ dlls/winemac.drv/macdrv.h | 1 + dlls/winemac.drv/macdrv_cocoa.h | 1 + dlls/winemac.drv/window.c | 12 ++++++++++++ 7 files changed, 56 insertions(+), 5 deletions(-)
diff --git a/dlls/winemac.drv/cocoa_app.m b/dlls/winemac.drv/cocoa_app.m index 9d33e7f..d0cb18d 100644 --- a/dlls/winemac.drv/cocoa_app.m +++ b/dlls/winemac.drv/cocoa_app.m @@ -1629,8 +1629,12 @@ int macdrv_err_on;
macdrv_release_event(event); } - else if (broughtWindowForward && ![window isKeyWindow]) - [self windowGotFocus:window]; + else if (broughtWindowForward) + { + [[window ancestorWineWindow] postBroughtForwardEvent]; + if (![window isKeyWindow]) + [self windowGotFocus:window]; + } }
// Since mouse button events deliver absolute cursor position, the diff --git a/dlls/winemac.drv/cocoa_window.h b/dlls/winemac.drv/cocoa_window.h index 4d43ab6..210299e 100644 --- a/dlls/winemac.drv/cocoa_window.h +++ b/dlls/winemac.drv/cocoa_window.h @@ -73,5 +73,8 @@ - (void) updateFullscreen;
- (void) postKeyEvent:(NSEvent *)theEvent; + - (void) postBroughtForwardEvent; + + - (WineWindow*) ancestorWineWindow;
@end diff --git a/dlls/winemac.drv/cocoa_window.m b/dlls/winemac.drv/cocoa_window.m index 380469c..a48b691 100644 --- a/dlls/winemac.drv/cocoa_window.m +++ b/dlls/winemac.drv/cocoa_window.m @@ -1268,6 +1268,27 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers) } }
+ - (WineWindow*) ancestorWineWindow + { + WineWindow* ancestor = self; + for (;;) + { + WineWindow* parent = (WineWindow*)[ancestor parentWindow]; + if ([parent isKindOfClass:[WineWindow class]]) + ancestor = parent; + else + break; + } + return ancestor; + } + + - (void) postBroughtForwardEvent + { + macdrv_event* event = macdrv_create_event(WINDOW_BROUGHT_FORWARD, self); + [queue postEvent:event]; + macdrv_release_event(event); + } +
/* * ---------- NSWindow method overrides ---------- @@ -1313,12 +1334,13 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers) /* We don't call this. It's the action method of the items in the Window menu. */ - (void) makeKeyAndOrderFront:(id)sender { - if (![self isKeyWindow] && !self.disabled && !self.noActivate) - [[WineApplicationController sharedController] windowGotFocus:self]; - if ([self isMiniaturized]) [self deminiaturize:nil]; [self orderBelow:nil orAbove:nil activate:NO]; + [[self ancestorWineWindow] postBroughtForwardEvent]; + + if (![self isKeyWindow] && !self.disabled && !self.noActivate) + [[WineApplicationController sharedController] windowGotFocus:self]; }
- (void) sendEvent:(NSEvent*)event @@ -1480,6 +1502,9 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers) [controller updateFullscreenWindows]; [controller adjustWindowLevels];
+ if (![self parentWindow]) + [self postBroughtForwardEvent]; + if (!self.disabled && !self.noActivate) { causing_becomeKeyWindow = self; diff --git a/dlls/winemac.drv/event.c b/dlls/winemac.drv/event.c index b9b9778..2b7adb0 100644 --- a/dlls/winemac.drv/event.c +++ b/dlls/winemac.drv/event.c @@ -48,6 +48,7 @@ static const char *dbgstr_event(int type) "RELEASE_CAPTURE", "STATUS_ITEM_MOUSE_BUTTON", "STATUS_ITEM_MOUSE_MOVE", + "WINDOW_BROUGHT_FORWARD", "WINDOW_CLOSE_REQUESTED", "WINDOW_DID_UNMINIMIZE", "WINDOW_FRAME_CHANGED", @@ -111,6 +112,7 @@ static macdrv_event_mask get_event_mask(DWORD mask) { event_mask |= event_mask_for_type(QUERY_EVENT); event_mask |= event_mask_for_type(RELEASE_CAPTURE); + event_mask |= event_mask_for_type(WINDOW_BROUGHT_FORWARD); event_mask |= event_mask_for_type(WINDOW_MINIMIZE_REQUESTED); }
@@ -234,6 +236,9 @@ void macdrv_handle_event(const macdrv_event *event) case STATUS_ITEM_MOUSE_MOVE: macdrv_status_item_mouse_move(event); break; + case WINDOW_BROUGHT_FORWARD: + macdrv_window_brought_forward(hwnd); + break; case WINDOW_CLOSE_REQUESTED: macdrv_window_close_requested(hwnd); break; diff --git a/dlls/winemac.drv/macdrv.h b/dlls/winemac.drv/macdrv.h index 4a7e259..3c56c35 100644 --- a/dlls/winemac.drv/macdrv.h +++ b/dlls/winemac.drv/macdrv.h @@ -162,6 +162,7 @@ extern void macdrv_app_deactivated(void) DECLSPEC_HIDDEN; extern void macdrv_app_quit_requested(const macdrv_event *event) DECLSPEC_HIDDEN; extern void macdrv_window_minimize_requested(HWND hwnd) DECLSPEC_HIDDEN; extern void macdrv_window_did_unminimize(HWND hwnd) DECLSPEC_HIDDEN; +extern void macdrv_window_brought_forward(HWND hwnd) DECLSPEC_HIDDEN; extern BOOL query_resize_end(HWND hwnd) DECLSPEC_HIDDEN; extern BOOL query_resize_start(HWND hwnd) DECLSPEC_HIDDEN; extern BOOL query_min_max_info(HWND hwnd) DECLSPEC_HIDDEN; diff --git a/dlls/winemac.drv/macdrv_cocoa.h b/dlls/winemac.drv/macdrv_cocoa.h index d99a5ec..1a38b56 100644 --- a/dlls/winemac.drv/macdrv_cocoa.h +++ b/dlls/winemac.drv/macdrv_cocoa.h @@ -185,6 +185,7 @@ enum { RELEASE_CAPTURE, STATUS_ITEM_MOUSE_BUTTON, STATUS_ITEM_MOUSE_MOVE, + WINDOW_BROUGHT_FORWARD, WINDOW_CLOSE_REQUESTED, WINDOW_DID_UNMINIMIZE, WINDOW_FRAME_CHANGED, diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c index 6e92d13..b49e347 100644 --- a/dlls/winemac.drv/window.c +++ b/dlls/winemac.drv/window.c @@ -1862,6 +1862,18 @@ done: }
+/*********************************************************************** + * macdrv_window_brought_forward + * + * Handler for WINDOW_BROUGHT_FORWARD events. + */ +void macdrv_window_brought_forward(HWND hwnd) +{ + TRACE("win %p\n", hwnd); + SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); +} + + struct quit_info { HWND *wins; UINT capacity;