Hi Everyone,
First, I'd like to apologize for sending those tarballs to wine-devel,
as I've just been advised on IRC that such a practice discourages
reviews. I've attached a text version of the patches in the hopes that
it will get some more exposure. 

Again, sorry for the trouble. :)

James
>From nobody Mon Sep 17 00:00:00 2001
From: James Liggett <[EMAIL PROTECTED]>
Date: Fri Aug 11 13:13:19 2006 -0700
Subject: [PATCH] winex11.drv: Add XEmbed atom definitions to x11drv.h

---

 dlls/winex11.drv/x11drv.h |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

a240428bd9a0e280d852a49611034cd5dc7dbd71
diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h
index e5027c4..a4eb516 100644
--- a/dlls/winex11.drv/x11drv.h
+++ b/dlls/winex11.drv/x11drv.h
@@ -562,6 +562,8 @@ enum x11drv_atoms
     XATOM_DndSelection,
     XATOM__MOTIF_WM_HINTS,
     XATOM__KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR,
+    XATOM__NET_SYSTEM_TRAY_OPCODE,
+    XATOM__NET_SYSTEM_TRAY_S0,
     XATOM__NET_WM_MOVERESIZE,
     XATOM__NET_WM_NAME,
     XATOM__NET_WM_PID,
@@ -570,6 +572,7 @@ enum x11drv_atoms
     XATOM__NET_WM_STATE_FULLSCREEN,
     XATOM__NET_WM_WINDOW_TYPE,
     XATOM__NET_WM_WINDOW_TYPE_UTILITY,
+    XATOM__XEMBED_INFO,
     XATOM_XdndAware,
     XATOM_XdndEnter,
     XATOM_XdndPosition,
-- 
1.2.4

>From nobody Mon Sep 17 00:00:00 2001
From: James Liggett <[EMAIL PROTECTED]>
Date: Fri Aug 11 13:14:46 2006 -0700
Subject: [PATCH] winex11.drv: Added systray atom names to x11drv.h.

---

 dlls/winex11.drv/x11drv_main.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

75a3460ffbde801bed93236996d4b952e8ba4a1a
diff --git a/dlls/winex11.drv/x11drv_main.c b/dlls/winex11.drv/x11drv_main.c
index 41d45a6..0403b5d 100644
--- a/dlls/winex11.drv/x11drv_main.c
+++ b/dlls/winex11.drv/x11drv_main.c
@@ -125,6 +125,8 @@ static const char * const atom_names[NB_
     "DndSelection",
     "_MOTIF_WM_HINTS",
     "_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR",
+    "_NET_SYSTEM_TRAY_OPCODE",
+    "_NET_SYSTEM_TRAY_S0",
     "_NET_WM_MOVERESIZE",
     "_NET_WM_NAME",
     "_NET_WM_PID",
@@ -133,6 +135,7 @@ static const char * const atom_names[NB_
     "_NET_WM_STATE_FULLSCREEN",
     "_NET_WM_WINDOW_TYPE",
     "_NET_WM_WINDOW_TYPE_UTILITY",
+    "_XEMBED_INFO",
     "XdndAware",
     "XdndEnter",
     "XdndPosition",
-- 
1.2.4

>From nobody Mon Sep 17 00:00:00 2001
From: James Liggett <[EMAIL PROTECTED]>
Date: Fri Aug 11 13:17:20 2006 -0700
Subject: [PATCH] winex11.drv: Dynamically create systray atom names based on the screen
we're running on.

---

 dlls/winex11.drv/x11drv_main.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

46ca62dd8ed65dbdd658490430ca14847d8274f9
diff --git a/dlls/winex11.drv/x11drv_main.c b/dlls/winex11.drv/x11drv_main.c
index 0403b5d..9d375e9 100644
--- a/dlls/winex11.drv/x11drv_main.c
+++ b/dlls/winex11.drv/x11drv_main.c
@@ -104,6 +104,7 @@ static char input_style[20];
     ((ch) == 'n' || (ch) == 'N' || (ch) == 'f' || (ch) == 'F' || (ch) == '0')
 
 Atom X11DRV_Atoms[NB_XATOMS - FIRST_XATOM];
+Atom systray_atom;
 
 static const char * const atom_names[NB_XATOMS - FIRST_XATOM] =
 {
@@ -419,6 +420,16 @@ static BOOL process_attach(void)
     }
 
     XInternAtoms( display, (char **)atom_names, NB_XATOMS - FIRST_XATOM, False, X11DRV_Atoms );
+    
+    if (DefaultScreen( display ) == 0)
+        systray_atom = x11drv_atom(_NET_SYSTEM_TRAY_S0);
+    else
+    {
+        char systray_buffer[29]; /* strlen(_NET_SYSTEM_TRAY_S4294967295)+1 */
+        sprintf( systray_buffer, "_NET_SYSTEM_TRAY_S%d", DefaultScreen( display ) );
+        systray_atom = XInternAtom( display, systray_buffer, False );
+    }
+
 
     if (TRACE_ON(synchronous)) XSynchronize( display, True );
 
-- 
1.2.4

>From nobody Mon Sep 17 00:00:00 2001
From: James Liggett <[EMAIL PROTECTED]>
Date: Fri Aug 11 13:19:10 2006 -0700
Subject: [PATCH] winex11.drv: Add system tray docking message defines to window.c

---

 dlls/winex11.drv/window.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

035068f80b65110c6ba249920e73f5446bec6b08
diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c
index 2bc90a7..0b87c52 100644
--- a/dlls/winex11.drv/window.c
+++ b/dlls/winex11.drv/window.c
@@ -58,6 +58,11 @@ static const char icon_window_prop[]  = 
 static const char managed_prop[]      = "__wine_x11_managed";
 static const char visual_id_prop[]    = "__wine_x11_visual_id";
 
+/* for XDG systray icons */
+#define SYSTEM_TRAY_REQUEST_DOCK    0
+#define SYSTEM_TRAY_BEGIN_MESSAGE   1
+#define SYSTEM_TRAY_CANCEL_MESSAGE  2
+
 /***********************************************************************
  *		is_window_managed
  *
-- 
1.2.4

>From nobody Mon Sep 17 00:00:00 2001
From: James Liggett <[EMAIL PROTECTED]>
Date: Sat Aug 12 22:48:43 2006 -0700
Subject: [PATCH] winex11.drv: Add function X11DRV_get_systray to get the XEmbed system
tray running on the current display, if there is one.

---

 dlls/winex11.drv/window.c |   16 +++++++++++++++-
 dlls/winex11.drv/x11drv.h |    3 +++
 2 files changed, 18 insertions(+), 1 deletions(-)

e2e6a834aee885b5212a201194ab98a99fa50613
diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c
index 0b87c52..076755d 100644
--- a/dlls/winex11.drv/window.c
+++ b/dlls/winex11.drv/window.c
@@ -331,6 +331,21 @@ static void set_size_hints( Display *dis
     }
 }
 
+/***********************************************************************
+ *              X11DRV_get_systray_window
+ *
+ * Get the owner of the XEMBED systray, if any
+ */
+Window X11DRV_get_systray_window( Display *display )
+{
+    Window systray_window;
+    
+    wine_tsx11_lock();
+    systray_window = XGetSelectionOwner( display, systray_atom );
+    wine_tsx11_unlock();
+    
+    return systray_window;
+}
 
 /***********************************************************************
  *              get_process_name
@@ -363,7 +378,6 @@ static char *get_process_name(void)
     return name;
 }
 
-
 /***********************************************************************
  *              X11DRV_set_wm_hints
  *
diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h
index a4eb516..92781fd 100644
--- a/dlls/winex11.drv/x11drv.h
+++ b/dlls/winex11.drv/x11drv.h
@@ -598,6 +598,7 @@ enum x11drv_atoms
 };
 
 extern Atom X11DRV_Atoms[NB_XATOMS - FIRST_XATOM];
+extern Atom systray_atom;
 
 #define x11drv_atom(name) (X11DRV_Atoms[XATOM_##name - FIRST_XATOM])
 
@@ -702,4 +703,6 @@ LPDDHALMODEINFO X11DRV_Settings_SetHandl
 
 extern void X11DRV_DDHAL_SwitchMode(DWORD dwModeIndex, LPVOID fb_addr, LPVIDMEM fb_mem);
 
+Window X11DRV_get_systray_window(Display *display);
+
 #endif  /* __WINE_X11DRV_H */
-- 
1.2.4

>From nobody Mon Sep 17 00:00:00 2001
From: James Liggett <[EMAIL PROTECTED]>
Date: Sat Aug 12 22:55:52 2006 -0700
Subject: [PATCH] winex11.drv: Add XEmbed systray icon docking code.

---

 dlls/winex11.drv/window.c |   75 ++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 66 insertions(+), 9 deletions(-)

442b5c322094179893d4558fae5ab731e6d85f51
diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c
index 076755d..3e41904 100644
--- a/dlls/winex11.drv/window.c
+++ b/dlls/winex11.drv/window.c
@@ -296,6 +296,69 @@ static void set_icon_hints( Display *dis
     }
 }
 
+/***********************************************************************
+ *              systray_dock_window
+ *
+ * Docks the given X window with the NETWM system tray.
+ */
+static void systray_dock_window( Display *display, struct x11drv_win_data *data )
+{
+    Window systray_window = X11DRV_get_systray_window( display );
+
+    TRACE("Docking tray icon %p\n", data->hwnd);
+
+    if (systray_window != None)
+    {
+        XEvent ev;
+        unsigned long info[2];
+
+        /* set XEMBED protocol data on the window */
+        info[0] = 0; /* protocol version */
+        info[1] = 1; /* mapped = true */
+        
+        wine_tsx11_lock();
+        XChangeProperty( display, data->whole_window,
+                         x11drv_atom(_XEMBED_INFO),
+                         x11drv_atom(_XEMBED_INFO), 32, PropModeReplace,
+                         (unsigned char*)info, 2 );
+        wine_tsx11_unlock();
+    
+        /* send the docking request message */
+        ZeroMemory( &ev, sizeof(ev) ); 
+        ev.xclient.type = ClientMessage;
+        ev.xclient.window = systray_window;
+        ev.xclient.message_type = x11drv_atom( _NET_SYSTEM_TRAY_OPCODE );
+        ev.xclient.format = 32;
+        ev.xclient.data.l[0] = CurrentTime;
+        ev.xclient.data.l[1] = SYSTEM_TRAY_REQUEST_DOCK;
+        ev.xclient.data.l[2] = data->whole_window;
+        ev.xclient.data.l[3] = 0;
+        ev.xclient.data.l[4] = 0;
+        
+        wine_tsx11_lock();
+        XSendEvent( display, systray_window, False, NoEventMask, &ev );
+        wine_tsx11_unlock();
+
+    }
+    else
+    {
+        int val = 1;
+
+        /* fall back to he KDE hints if the WM doesn't support XEMBED'ed
+         * systrays */
+        wine_tsx11_lock();
+        XChangeProperty( display, data->whole_window, 
+                         x11drv_atom(KWM_DOCKWINDOW),
+                         x11drv_atom(KWM_DOCKWINDOW), 32, PropModeReplace,
+                         (unsigned char*)&val, 1 );
+        XChangeProperty( display, data->whole_window,
+                         x11drv_atom(_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR),
+                         XA_WINDOW, 32, PropModeReplace,
+                         (unsigned char*)&data->whole_window, 1 );
+       wine_tsx11_unlock();
+    }
+}
+
 
 /***********************************************************************
  *              set_size_hints
@@ -439,16 +502,10 @@ void X11DRV_set_wm_hints( Display *displ
 
     /* size hints */
     set_size_hints( display, data, style );
-
-    /* systray properties (KDE only for now) */
+    
+    /* Dock system tray icons */
     if (ex_style & WS_EX_TRAYWINDOW)
-    {
-        int val = 1;
-        XChangeProperty( display, data->whole_window, x11drv_atom(KWM_DOCKWINDOW),
-                         x11drv_atom(KWM_DOCKWINDOW), 32, PropModeReplace, (unsigned char*)&val, 1 );
-        XChangeProperty( display, data->whole_window, x11drv_atom(_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR),
-                         XA_WINDOW, 32, PropModeReplace, (unsigned char*)&data->whole_window, 1 );
-    }
+        systray_dock_window( display, data );
 
     /* set the WM_CLIENT_MACHINE and WM_LOCALE_NAME properties */
     XSetWMProperties(display, data->whole_window, NULL, NULL, NULL, 0, NULL, NULL, NULL);
-- 
1.2.4

>From nobody Mon Sep 17 00:00:00 2001
From: James Liggett <[EMAIL PROTECTED]>
Date: Fri Aug 11 15:19:27 2006 -0700
Subject: [PATCH] server: Add window extended styles field to set_window_pos reply.

We need to check to see if we're operating on tray windows. Tray
windows cannot be mapped by Wine if we're using XEmbed system trays. If
we call XMapWindow on tray windows and attempt to dock with a tray, we may
unexpectedly see the tray window become visible as a child of the
root window when it shouldn't be. For more information, see:

http://standards.freedesktop.org/xembed-spec/latest/ar01s04.html
(cherry picked from d39b2c28938602866dde0103c9d139801e392060 commit)

---

 server/protocol.def |    1 +
 server/window.c     |    1 +
 2 files changed, 2 insertions(+), 0 deletions(-)

7a4aa3f7882af453c35594969b66ebdea02be053
diff --git a/server/protocol.def b/server/protocol.def
index 0d014dd..b450c64 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -1948,6 +1948,7 @@ enum message_type
     VARARG(valid,rectangles);     /* valid rectangles from WM_NCCALCSIZE */
 @REPLY
     unsigned int   new_style;     /* new window style */
+    unsigned int   ex_style;      /* extended window style */
 @END
 
 
diff --git a/server/window.c b/server/window.c
index 91930d0..af657ee 100644
--- a/server/window.c
+++ b/server/window.c
@@ -1707,6 +1707,7 @@ DECL_HANDLER(set_window_pos)
     if (!visible_rect) visible_rect = &req->window;
     set_window_pos( win, previous, flags, &req->window, &req->client, visible_rect, valid_rects );
     reply->new_style = win->style;
+    reply->ex_style = win->ex_style;
 }
 
 
-- 
1.2.4

>From nobody Mon Sep 17 00:00:00 2001
From: James Liggett <[EMAIL PROTECTED]>
Date: Sun Aug 13 18:56:02 2006 -0700
Subject: [PATCH] winex11.drv: Don't call XMapWindow on tray icons in
X11DRV_set_iconic_state if we have an XEmbed systray.

---

 dlls/winex11.drv/window.c |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)

4198b7d680a7a2c4d186293a2c698504200a54f5
diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c
index 3e41904..7e5a5c1 100644
--- a/dlls/winex11.drv/window.c
+++ b/dlls/winex11.drv/window.c
@@ -586,6 +586,7 @@ void X11DRV_set_iconic_state( HWND hwnd 
     RECT rect;
     XWMHints* wm_hints;
     DWORD style = GetWindowLongW( hwnd, GWL_STYLE );
+    DWORD ex_style = GetWindowLongW( hwnd, GWL_EXSTYLE );
     BOOL iconic = (style & WS_MINIMIZE) != 0;
 
     if (!(data = X11DRV_get_win_data( hwnd ))) return;
@@ -602,13 +603,28 @@ void X11DRV_set_iconic_state( HWND hwnd 
     wm_hints->icon_y = rect.top;
     XSetWMHints( display, data->whole_window, wm_hints );
 
+    /* Tray windows cannot be mapped by Wine if we're using XEmbed systrays. 
+     * If we call XMapWindow on tray windows and attempt to dock with a tray, 
+     * we may unexpectedly see the tray window become visible as a child of the
+     * root window when it shouldn't be. In order for docking to work reliably,
+     * the system tray must handle the icon's mapping. 
+     * 
+     * For more information, see:
+     * http://standards.freedesktop.org/xembed-spec/latest/ar01s04.html */
+    
     if (style & WS_VISIBLE)
     {
         if (iconic)
             XIconifyWindow( display, data->whole_window, DefaultScreen(display) );
         else
             if (X11DRV_is_window_rect_mapped( &rect ))
-                XMapWindow( display, data->whole_window );
+            {
+                if ((X11DRV_get_systray_window( display ) == None) ||
+                    (!(ex_style & WS_EX_TRAYWINDOW)))
+                    {
+                        XMapWindow( display, data->whole_window );
+                    }
+            }
     }
 
     XFree(wm_hints);
-- 
1.2.4

>From nobody Mon Sep 17 00:00:00 2001
From: James Liggett <[EMAIL PROTECTED]>
Date: Sun Aug 13 19:01:58 2006 -0700
Subject: [PATCH] winex11.drv: Don't call XMapWindow on tray icons in
X11DRV_SetWindowStyle if we have an XEmbed systray.

---

 dlls/winex11.drv/winpos.c |   21 ++++++++++++++-------
 1 files changed, 14 insertions(+), 7 deletions(-)

3cc9665b8a966ce64cf7a836aa88d777da240296
diff --git a/dlls/winex11.drv/winpos.c b/dlls/winex11.drv/winpos.c
index 3c45fff..e56517b 100644
--- a/dlls/winex11.drv/winpos.c
+++ b/dlls/winex11.drv/winpos.c
@@ -475,12 +475,13 @@ void X11DRV_SetWindowStyle( HWND hwnd, D
 {
     Display *display = thread_display();
     struct x11drv_win_data *data;
-    DWORD new_style, changed;
+    DWORD new_style, ex_style, changed;
 
     if (hwnd == GetDesktopWindow()) return;
     if (!(data = X11DRV_get_win_data( hwnd ))) return;
 
     new_style = GetWindowLongW( hwnd, GWL_STYLE );
+    ex_style = GetWindowLongW( hwnd, GWL_EXSTYLE );
     changed = new_style ^ old_style;
 
     if (changed & WS_VISIBLE)
@@ -489,12 +490,18 @@ void X11DRV_SetWindowStyle( HWND hwnd, D
         {
             if (new_style & WS_VISIBLE)
             {
-                TRACE( "mapping win %p\n", hwnd );
-                X11DRV_sync_window_style( display, data );
-                X11DRV_set_wm_hints( display, data );
-                wine_tsx11_lock();
-                XMapWindow( display, data->whole_window );
-                wine_tsx11_unlock();
+                /* Don't map tray icon windows if we have an XEmbed systray.
+                 * See X11DRV_set_iconic_state for more information */
+                if ((X11DRV_get_systray_window( display ) == None) ||
+                    (!(ex_style & WS_EX_TRAYWINDOW)))
+                {
+                    TRACE( "mapping win %p\n", hwnd );
+                    X11DRV_sync_window_style( display, data );
+                    X11DRV_set_wm_hints( display, data );
+                    wine_tsx11_lock();
+                    XMapWindow( display, data->whole_window );
+                    wine_tsx11_unlock();
+                }
             }
             /* we don't unmap windows, that causes trouble with the window manager */
         }
-- 
1.2.4

>From nobody Mon Sep 17 00:00:00 2001
From: James Liggett <[EMAIL PROTECTED]>
Date: Sun Aug 13 19:21:11 2006 -0700
Subject: [PATCH] winex11.drv: Don't call XMapWindow on tray icons in
X11DRV_SetWindowStyle if we have an XEmbed systray.

---

 dlls/winex11.drv/winpos.c |   24 ++++++++++++++++--------
 1 files changed, 16 insertions(+), 8 deletions(-)

eca26c8856b0e0f7b70f9bf4d42ddc99783cdcc8
diff --git a/dlls/winex11.drv/winpos.c b/dlls/winex11.drv/winpos.c
index e56517b..ee7ab36 100644
--- a/dlls/winex11.drv/winpos.c
+++ b/dlls/winex11.drv/winpos.c
@@ -583,7 +583,7 @@ BOOL X11DRV_set_window_pos( HWND hwnd, H
     struct x11drv_win_data *data;
     RECT new_whole_rect, old_client_rect, old_screen_rect;
     WND *win;
-    DWORD old_style, new_style;
+    DWORD old_style, ex_style, new_style;
     BOOL ret;
 
     if (!(data = X11DRV_get_win_data( hwnd ))) return FALSE;
@@ -639,6 +639,7 @@ BOOL X11DRV_set_window_pos( HWND hwnd, H
         }
         ret = !wine_server_call( req );
         new_style = reply->new_style;
+        ex_style = reply->ex_style;
     }
     SERVER_END_REQ;
 
@@ -709,13 +710,20 @@ BOOL X11DRV_set_window_pos( HWND hwnd, H
             {
                 if (!(old_style & WS_VISIBLE))
                 {
-                    /* window got shown, map it */
-                    TRACE( "mapping win %p\n", hwnd );
-                    X11DRV_sync_window_style( display, data );
-                    X11DRV_set_wm_hints( display, data );
-                    wine_tsx11_lock();
-                    XMapWindow( display, data->whole_window );
-                    wine_tsx11_unlock();
+                    /* Don't map tray icon windows if we have an XEmbed 
+                     * systray. See X11DRV_set_iconic_state for more 
+                     * information. */
+                     if ((X11DRV_get_systray_window( display ) == None) ||
+                         (!(ex_style & WS_EX_TRAYWINDOW)))
+                    {
+                        /* window got shown, map it */
+                        TRACE( "mapping win %p\n", hwnd );
+                        X11DRV_sync_window_style( display, data );
+                        X11DRV_set_wm_hints( display, data );
+                        wine_tsx11_lock();
+                        XMapWindow( display, data->whole_window );
+                        wine_tsx11_unlock();
+                    }
                 }
                 else if ((swp_flags & (SWP_NOSIZE | SWP_NOMOVE)) != (SWP_NOSIZE | SWP_NOMOVE))
                 {
-- 
1.2.4



Reply via email to