From: Ken Thomases Subject: winemac: Update the clipboard when the process activates. Message-Id: <20161209222508.38023-1-ken@codeweavers.com> Date: Fri, 9 Dec 2016 16:25:08 -0600 If another app grabbed the clipboard, that most likely happened while it was active and the Wine process was inactive. Our process being made active again is a good opportunity to check for that. Signed-off-by: Ken Thomases --- Fixes dlls/winemac.drv/cocoa_app.m | 13 +++++++++++++ dlls/winemac.drv/event.c | 5 +++++ dlls/winemac.drv/macdrv.h | 2 ++ dlls/winemac.drv/macdrv_cocoa.h | 3 ++- dlls/winemac.drv/window.c | 12 ++++++++++++ 5 files changed, 34 insertions(+), 1 deletion(-) diff --git a/dlls/winemac.drv/cocoa_app.m b/dlls/winemac.drv/cocoa_app.m index 09c95d0..27ebdc4 100644 --- a/dlls/winemac.drv/cocoa_app.m +++ b/dlls/winemac.drv/cocoa_app.m @@ -2314,6 +2314,19 @@ - (NSApplicationTerminateReply) applicationShouldTerminate:(NSApplication *)send return ret; } + - (void)applicationWillBecomeActive:(NSNotification *)notification + { + macdrv_event* event = macdrv_create_event(APP_ACTIVATED, nil); + event->deliver = 1; + + [eventQueuesLock lock]; + for (WineEventQueue* queue in eventQueues) + [queue postEvent:event]; + [eventQueuesLock unlock]; + + macdrv_release_event(event); + } + - (void)applicationWillResignActive:(NSNotification *)notification { [self adjustWindowLevels:NO]; diff --git a/dlls/winemac.drv/event.c b/dlls/winemac.drv/event.c index 7d3aab3..26d2b64 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_ACTIVATED", "APP_DEACTIVATED", "APP_QUIT_REQUESTED", "DISPLAYS_CHANGED", @@ -104,6 +105,7 @@ static macdrv_event_mask get_event_mask(DWORD mask) if (mask & QS_POSTMESSAGE) { + event_mask |= event_mask_for_type(APP_ACTIVATED); event_mask |= event_mask_for_type(APP_DEACTIVATED); event_mask |= event_mask_for_type(APP_QUIT_REQUESTED); event_mask |= event_mask_for_type(DISPLAYS_CHANGED); @@ -210,6 +212,9 @@ void macdrv_handle_event(const macdrv_event *event) switch (event->type) { + case APP_ACTIVATED: + macdrv_app_activated(); + break; case APP_DEACTIVATED: macdrv_app_deactivated(); break; diff --git a/dlls/winemac.drv/macdrv.h b/dlls/winemac.drv/macdrv.h index a3ded73..bffd555 100644 --- a/dlls/winemac.drv/macdrv.h +++ b/dlls/winemac.drv/macdrv.h @@ -165,6 +165,7 @@ static inline RECT rect_from_cgrect(CGRect cgrect) extern void macdrv_window_frame_changed(HWND hwnd, const macdrv_event *event) 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_activated(void) DECLSPEC_HIDDEN; extern void macdrv_app_deactivated(void) DECLSPEC_HIDDEN; extern void macdrv_app_quit_requested(const macdrv_event *event) DECLSPEC_HIDDEN; extern void macdrv_window_maximize_requested(HWND hwnd) DECLSPEC_HIDDEN; @@ -194,6 +195,7 @@ static inline RECT rect_from_cgrect(CGRect cgrect) extern void macdrv_displays_changed(const macdrv_event *event) DECLSPEC_HIDDEN; +extern void CDECL macdrv_UpdateClipboard(void) DECLSPEC_HIDDEN; extern void macdrv_init_clipboard(void) DECLSPEC_HIDDEN; extern BOOL query_pasteboard_data(HWND hwnd, CFStringRef type) DECLSPEC_HIDDEN; extern void macdrv_lost_pasteboard_ownership(HWND hwnd) DECLSPEC_HIDDEN; diff --git a/dlls/winemac.drv/macdrv_cocoa.h b/dlls/winemac.drv/macdrv_cocoa.h index 21e9565..e016b3e 100644 --- a/dlls/winemac.drv/macdrv_cocoa.h +++ b/dlls/winemac.drv/macdrv_cocoa.h @@ -259,6 +259,7 @@ extern int macdrv_set_display_mode(const struct macdrv_display* display, /* event */ enum { + APP_ACTIVATED, APP_DEACTIVATED, APP_QUIT_REQUESTED, DISPLAYS_CHANGED, @@ -301,7 +302,7 @@ extern int macdrv_set_display_mode(const struct macdrv_display* display, QUIT_REASON_SHUTDOWN, }; -typedef uint32_t macdrv_event_mask; +typedef uint64_t macdrv_event_mask; typedef struct macdrv_event { int refs; diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c index 40aa439..9824d99 100644 --- a/dlls/winemac.drv/window.c +++ b/dlls/winemac.drv/window.c @@ -2279,6 +2279,18 @@ void macdrv_window_lost_focus(HWND hwnd, const macdrv_event *event) /*********************************************************************** + * macdrv_app_activated + * + * Handler for APP_ACTIVATED events. + */ +void macdrv_app_activated(void) +{ + TRACE("\n"); + macdrv_UpdateClipboard(); +} + + +/*********************************************************************** * macdrv_app_deactivated * * Handler for APP_DEACTIVATED events. -- 2.10.2