Ok I created some new patches. (I decided to break it up this time. They
can be applied in any order) Thanks for helping test this! :) If you
have any feedback, please let me know...If they work out OK I will post
them to wine-patches again.

James

On Wed, 2005-11-09 at 11:07 +0530, Vijay Kiran Kamuju wrote:
> could you please send a new patch as per latest cvs or 0.9
> I would like to test this patch.
> with 0.9 its not applying properly
> Thanks,
> Vijay
> 
> On 10/27/05, James Liggett <[EMAIL PROTECTED]> wrote:
> > On Wed, 2005-10-19 at 14:33 +0200, Alexandre Julliard wrote:
> >
> > > I'm afraid it's too big a change to get in at this point. Besides,
> > > there are still problems with that patch.
> > Now that 0.9 is released and the freeze is over, can you please tell me
> > what the problems are so I can fix them?
> >
> > Thanks,
> > James
> >
> >
> >
> >
? systray_files
? xembed-systray.patch
Index: systray.c
===================================================================
RCS file: /home/wine/wine/dlls/shell32/systray.c,v
retrieving revision 1.32
diff -u -r1.32 systray.c
--- systray.c	8 Nov 2005 19:57:27 -0000	1.32
+++ systray.c	9 Nov 2005 08:07:26 -0000
@@ -117,8 +117,18 @@
 	if (ptrayItem->notifyIcon.hIcon) {
 	  hdc = BeginPaint(hWnd, &ps);
 	  GetClientRect(hWnd, &rc);
-	  if (!DrawIconEx(hdc, rc.left+ICON_BORDER, rc.top+ICON_BORDER, ptrayItem->notifyIcon.hIcon,
-			  ICON_SIZE, ICON_SIZE, 0, 0, DI_DEFAULTSIZE|DI_NORMAL)) {
+	  
+		/* Draw icon centered in docked window */
+		if (!DrawIconEx(hdc, 
+										(rc.left + 2), 
+										((rc.bottom - ICON_SIZE) / 2), 
+										ptrayItem->notifyIcon.hIcon,
+			  						ICON_SIZE, 
+										ICON_SIZE, 
+										0, 
+										0, 
+										DI_DEFAULTSIZE|DI_NORMAL)) 
+		{
 	    ERR("Paint(SystrayWindow %p) failed -> removing SystrayItem %p\n", hWnd, ptrayItem);
 	    SYSTRAY_Delete(&ptrayItem->notifyIcon);
 	  }
@@ -201,7 +211,7 @@
   wc.hInstance     = 0;
   wc.hIcon         = 0;
   wc.hCursor       = LoadCursorW(0, (LPWSTR)IDC_ARROW);
-  wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
+  wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
   wc.lpszMenuName  = NULL;
   wc.lpszClassName = WineSystrayW;
 
@@ -215,7 +225,6 @@
 
 static BOOL SYSTRAY_ItemInit(SystrayItem *ptrayItem)
 {
-  RECT rect;
   static const WCHAR WineSystrayW[] = { 'W','i','n','e','S','y','s','t','r','a','y',0 };
   static const WCHAR Wine_SystrayW[] = { 'W','i','n','e','-','S','y','s','t','r','a','y',0 };
 
@@ -228,11 +237,6 @@
     }
   }
 
-  /* Initialize the window size. */
-  rect.left   = 0;
-  rect.top    = 0;
-  rect.right  = ICON_SIZE+2*ICON_BORDER;
-  rect.bottom = ICON_SIZE+2*ICON_BORDER;
 
   ZeroMemory( ptrayItem, sizeof(SystrayItem) );
   /* Create tray window for icon. */
@@ -240,7 +244,8 @@
                                 WineSystrayW, Wine_SystrayW,
                                 WS_VISIBLE,
                                 CW_USEDEFAULT, CW_USEDEFAULT,
-                                rect.right-rect.left, rect.bottom-rect.top,
+                                (ICON_SIZE + (2 * ICON_BORDER)), 
+																(ICON_SIZE + (2 * ICON_BORDER)),
                                 0, 0, 0, 0 );
   if ( !ptrayItem->hWnd ) {
     ERR( "CreateWindow(WineSystray) failed\n" );
Index: window.c
===================================================================
RCS file: /home/wine/wine/dlls/x11drv/window.c,v
retrieving revision 1.116
diff -u -r1.116 window.c
--- window.c	22 Aug 2005 09:14:21 -0000	1.116
+++ window.c	9 Nov 2005 08:08:49 -0000
@@ -59,6 +59,11 @@
 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
  *
@@ -351,6 +358,64 @@
 
 
 /***********************************************************************
+ *              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;
+		
+		wine_tsx11_lock();
+		systray_window = XGetSelectionOwner( display, systray_atom );
+		wine_tsx11_unlock();
+
+    TRACE("Docking tray icon %p\n", data->hwnd);
+
+    if (systray_window != None)
+    {
+        XEvent ev;      
+    
+        /* 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 );
+        XSync( display, False );
+				wine_tsx11_unlock();			
+    }
+    else
+    {
+        int val = 1;
+				
+				wine_tsx11_lock();
+        
+			/* fall back to he KDE hints if the WM doesn't support XEMBED'ed
+         * systrays */
+        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();
+    }
+}
+
+/***********************************************************************
  *              X11DRV_set_wm_hints
  *
  * Set the window manager hints for a newly-created window
@@ -402,16 +467,6 @@
     /* size hints */
     set_size_hints( display, data, style );
 
-    /* systray properties (KDE only for now) */
-    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 );
-    }
-
     /* set the WM_CLIENT_MACHINE and WM_LOCALE_NAME properties */
     XSetWMProperties(display, data->whole_window, NULL, NULL, NULL, 0, NULL, NULL, NULL);
     /* set the pid. together, these properties are needed so the window manager can kill us if we freeze */
@@ -1027,6 +1082,9 @@
                       newPos.right, newPos.bottom, swFlag );
     }
 
+    if (GetWindowLongW( hwnd, GWL_EXSTYLE ) & WS_EX_TRAYWINDOW)
+        systray_dock_window(display, data);
+
     return TRUE;
 
  failed:
Index: x11drv.h
===================================================================
RCS file: /home/wine/wine/dlls/x11drv/x11drv.h,v
retrieving revision 1.79
diff -u -r1.79 x11drv.h
--- x11drv.h	26 Sep 2005 11:04:12 -0000	1.79
+++ x11drv.h	9 Nov 2005 08:08:50 -0000
@@ -570,6 +570,8 @@
     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_PID,
     XATOM__NET_WM_PING,
@@ -601,6 +603,7 @@
 };
 
 extern Atom X11DRV_Atoms[NB_XATOMS - FIRST_XATOM];
+extern Atom systray_atom;
 
 #define x11drv_atom(name) (X11DRV_Atoms[XATOM_##name - FIRST_XATOM])
 
Index: x11drv_main.c
===================================================================
RCS file: /home/wine/wine/dlls/x11drv/x11drv_main.c,v
retrieving revision 1.112
diff -u -r1.112 x11drv_main.c
--- x11drv_main.c	23 Sep 2005 17:21:32 -0000	1.112
+++ x11drv_main.c	9 Nov 2005 08:08:50 -0000
@@ -105,6 +105,7 @@
     ((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] =
 {
@@ -126,6 +127,8 @@
     "DndSelection",
     "_MOTIF_WM_HINTS",
     "_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR",
+    "_NET_SYSTEM_TRAY_OPCODE",
+    "_NET_SYSTEM_TRAY_S0",
     "_NET_WM_MOVERESIZE",
     "_NET_WM_PID",
     "_NET_WM_PING",
@@ -417,6 +420,15 @@
 
     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 (synchronous) XSynchronize( display, True );
 
     screen_width  = WidthOfScreen( screen );


Reply via email to