Ken Thomases : winemac: Implement an APP_DEACTIVATED event.

Alexandre Julliard julliard at winehq.org
Mon Jan 28 13:43:19 CST 2013


Module: wine
Branch: master
Commit: b564d972294fca82f3ebb3edf4600e69adb89f75
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=b564d972294fca82f3ebb3edf4600e69adb89f75

Author: Ken Thomases <ken at codeweavers.com>
Date:   Sun Jan 27 16:19:56 2013 -0600

winemac: Implement an APP_DEACTIVATED event.

---

 dlls/winemac.drv/cocoa_app.m    |   11 +++++++++++
 dlls/winemac.drv/event.c        |    5 +++++
 dlls/winemac.drv/macdrv.h       |    1 +
 dlls/winemac.drv/macdrv_cocoa.h |    1 +
 dlls/winemac.drv/window.c       |   15 +++++++++++++++
 5 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/dlls/winemac.drv/cocoa_app.m b/dlls/winemac.drv/cocoa_app.m
index 54a6d50..7b12185 100644
--- a/dlls/winemac.drv/cocoa_app.m
+++ b/dlls/winemac.drv/cocoa_app.m
@@ -179,7 +179,18 @@ int macdrv_err_on;
      */
     - (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 634fe52..654e691 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 e6c747f..d1b73fe 100644
--- a/dlls/winemac.drv/macdrv.h
+++ b/dlls/winemac.drv/macdrv.h
@@ -121,6 +121,7 @@ extern void macdrv_window_close_requested(HWND hwnd) DECLSPEC_HIDDEN;
 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 2084d78..dcdf91d 100644
--- a/dlls/winemac.drv/macdrv_cocoa.h
+++ b/dlls/winemac.drv/macdrv_cocoa.h
@@ -124,6 +124,7 @@ extern void macdrv_free_displays(struct macdrv_display* displays) DECLSPEC_HIDDE
 
 /* 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 5356687..810d3ae 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());
+    }
+}




More information about the wine-cvs mailing list