[PATCH] winemac.drv: Implement systray version 1-3 notifications.

Stefan Dösinger stefan at codeweavers.com
Thu May 11 06:15:46 CDT 2017


Signed-off-by: Stefan Dösinger <stefan at codeweavers.com>

---

I am  not sure how to handle NOTIFY_VERSION_4. The click events do not contain
a coordinate and I don't know how to read the position of the icon. The first
issue is probably trivial to handle by assuming a fixed coordinate because the
icon isn't all that big anyway. The latter is a larger problem because a wrong
coordinate could cause an app to show a popup in the wrong place. Also on dual
screen setups there are two copies of the status bar and two icon copies. Pick
the wrong one and things go bad as well.
---
 dlls/winemac.drv/systray.c | 48 ++++++++++++++++++++++++++++++++--------------
 1 file changed, 34 insertions(+), 14 deletions(-)

diff --git a/dlls/winemac.drv/systray.c b/dlls/winemac.drv/systray.c
index 16d2e6c0fa..fb7044438d 100644
--- a/dlls/winemac.drv/systray.c
+++ b/dlls/winemac.drv/systray.c
@@ -46,6 +46,7 @@ struct tray_icon
     WCHAR               tiptext[128];       /* tooltip text */
     DWORD               state;              /* state flags */
     macdrv_status_item  status_item;
+    UINT                version;
 };
 
 static struct list icon_list = LIST_INIT(icon_list);
@@ -263,6 +264,15 @@ int CDECL wine_notify_icon(DWORD msg, NOTIFYICONDATAW *data)
     case 0xdead:  /* Wine extension: owner window has died */
         cleanup_icons(data->hWnd);
         break;
+    case NIM_SETVERSION:
+        if ((icon = get_icon(data->hWnd, data->uID)))
+        {
+            icon->version = data->uVersion;
+            if (icon->version >= NOTIFY_VERSION_4)
+                FIXME("Unhandled NOTIFY_VERSION %u", data->uVersion);
+            ret = TRUE;
+        }
+        break;
     default:
         FIXME("unhandled tray message: %u\n", msg);
         break;
@@ -270,6 +280,21 @@ int CDECL wine_notify_icon(DWORD msg, NOTIFYICONDATAW *data)
     return ret;
 }
 
+static BOOL notify_owner(struct tray_icon *icon, UINT msg)
+{
+    WPARAM wp = icon->id;
+    LPARAM lp = msg;
+
+    TRACE("posting msg 0x%04x to hwnd %p id 0x%x\n", msg, icon->owner, icon->id);
+    if (!PostMessageW(icon->owner, icon->callback_message, wp, lp) &&
+        (GetLastError() == ERROR_INVALID_WINDOW_HANDLE))
+    {
+        WARN("window %p was destroyed, removing icon 0x%x\n", icon->owner, icon->id);
+        delete_icon( icon );
+        return FALSE;
+    }
+    return TRUE;
+}
 
 /***********************************************************************
  *              macdrv_status_item_mouse_button
@@ -313,13 +338,15 @@ void macdrv_status_item_mouse_button(const macdrv_event *event)
                 return;
             }
 
-            TRACE("posting msg 0x%04x to hwnd %p id 0x%x\n", msg, icon->owner, icon->id);
-            if (!PostMessageW(icon->owner, icon->callback_message, icon->id, msg) &&
-                GetLastError() == ERROR_INVALID_WINDOW_HANDLE)
-            {
-                WARN("window %p was destroyed, removing icon 0x%x\n", icon->owner, icon->id);
-                delete_icon(icon);
+            if (!notify_owner(icon, msg))
                 return;
+
+            if (icon->version)
+            {
+                if (msg == WM_LBUTTONUP)
+                    notify_owner(icon, NIN_SELECT);
+                else if (msg == WM_RBUTTONUP)
+                    notify_owner(icon, WM_CONTEXTMENU);
             }
 
             break;
@@ -343,14 +370,7 @@ void macdrv_status_item_mouse_move(const macdrv_event *event)
     {
         if (icon->status_item == event->status_item_mouse_move.item)
         {
-            if (!PostMessageW(icon->owner, icon->callback_message, icon->id, WM_MOUSEMOVE) &&
-                GetLastError() == ERROR_INVALID_WINDOW_HANDLE)
-            {
-                WARN("window %p was destroyed, removing icon 0x%x\n", icon->owner, icon->id);
-                delete_icon(icon);
-                return;
-            }
-
+            notify_owner(icon, WM_MOUSEMOVE);
             break;
         }
     }
-- 
2.11.0 (Apple Git-81)




More information about the wine-patches mailing list