diff --git a/dlls/winemac.drv/cocoa_app.m b/dlls/winemac.drv/cocoa_app.m index 54a6d50bfe1..7b121851485 100644 --- a/dlls/winemac.drv/cocoa_app.m +++ b/dlls/winemac.drv/cocoa_app.m @@ -179,7 +179,18 @@ - (void) windowRejectedFocusEvent:(const macdrv_event*)event */ - (void)applicationDidResignActive:(NSNotification *)notification { + macdrv_event event; + WineEventQueue* queue; + [self invalidateGotFocusEvents]; + + event.type = APP_DEACTIVATED; + event.window = NULL; + + [eventQueuesLock lock]; + for (queue in eventQueues) + [queue postEvent:&event]; + [eventQueuesLock unlock]; } - (void)applicationWillFinishLaunching:(NSNotification *)notification diff --git a/dlls/winemac.drv/event.c b/dlls/winemac.drv/event.c index 634fe5264ed..654e691cc7b 100644 --- a/dlls/winemac.drv/event.c +++ b/dlls/winemac.drv/event.c @@ -32,6 +32,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(event); static const char *dbgstr_event(int type) { static const char * const event_names[] = { + "APP_DEACTIVATED", "MOUSE_BUTTON", "WINDOW_CLOSE_REQUESTED", "WINDOW_FRAME_CHANGED", @@ -58,6 +59,7 @@ static macdrv_event_mask get_event_mask(DWORD mask) if (mask & QS_POSTMESSAGE) { + event_mask |= event_mask_for_type(APP_DEACTIVATED); event_mask |= event_mask_for_type(WINDOW_CLOSE_REQUESTED); event_mask |= event_mask_for_type(WINDOW_FRAME_CHANGED); event_mask |= event_mask_for_type(WINDOW_GOT_FOCUS); @@ -85,6 +87,9 @@ void macdrv_handle_event(macdrv_event *event) switch (event->type) { + case APP_DEACTIVATED: + macdrv_app_deactivated(); + break; case MOUSE_BUTTON: macdrv_mouse_button(hwnd, event); break; diff --git a/dlls/winemac.drv/macdrv.h b/dlls/winemac.drv/macdrv.h index e6c747fd06d..d1b73fea4d0 100644 --- a/dlls/winemac.drv/macdrv.h +++ b/dlls/winemac.drv/macdrv.h @@ -121,6 +121,7 @@ static inline RECT rect_from_cgrect(CGRect cgrect) extern void macdrv_window_frame_changed(HWND hwnd, CGRect frame) DECLSPEC_HIDDEN; extern void macdrv_window_got_focus(HWND hwnd, const macdrv_event *event) DECLSPEC_HIDDEN; extern void macdrv_window_lost_focus(HWND hwnd, const macdrv_event *event) DECLSPEC_HIDDEN; +extern void macdrv_app_deactivated(void) DECLSPEC_HIDDEN; extern void macdrv_mouse_button(HWND hwnd, const macdrv_event *event) DECLSPEC_HIDDEN; diff --git a/dlls/winemac.drv/macdrv_cocoa.h b/dlls/winemac.drv/macdrv_cocoa.h index 2084d78fef9..dcdf91d2b1e 100644 --- a/dlls/winemac.drv/macdrv_cocoa.h +++ b/dlls/winemac.drv/macdrv_cocoa.h @@ -124,6 +124,7 @@ /* event */ enum { + APP_DEACTIVATED, MOUSE_BUTTON, WINDOW_CLOSE_REQUESTED, WINDOW_FRAME_CHANGED, diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c index 5356687b86b..810d3aeb201 100644 --- a/dlls/winemac.drv/window.c +++ b/dlls/winemac.drv/window.c @@ -1469,3 +1469,18 @@ void macdrv_window_lost_focus(HWND hwnd, const macdrv_event *event) if (hwnd == GetForegroundWindow()) SendMessageW(hwnd, WM_CANCELMODE, 0, 0); } + + +/*********************************************************************** + * macdrv_app_deactivated + * + * Handler for APP_DEACTIVATED events. + */ +void macdrv_app_deactivated(void) +{ + if (GetActiveWindow() == GetForegroundWindow()) + { + TRACE("setting fg to desktop\n"); + SetForegroundWindow(GetDesktopWindow()); + } +}