]> Dogcows Code - chaz/tint2/commitdiff
detect pid of process owning the systray
authorThierry Lorthiois <lorthiois@bbsoft.fr>
Sun, 30 Aug 2009 16:20:44 +0000 (16:20 +0000)
committerThierry Lorthiois <lorthiois@bbsoft.fr>
Sun, 30 Aug 2009 16:20:44 +0000 (16:20 +0000)
ChangeLog
src/systray/systraybar.c

index 7c49eed89b9b1ecd3dea1d4687d84cbc5ed20b08..27d4567a301ca63a68e20eb2243a757c6c833271 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+2009-08-30
+- detect pid of process owning the systray
+
 2009-08-30
 - added taskbar_active_background_id to change current desktop background.
   warning : this feature have a price on cpu (tint2 redraw all task) when you switch desktop.
index c135077eff6515485f375bd5dc3a0c9455ee017f..c014fd91362e842061b90ac040b451af2389e8b4 100644 (file)
@@ -171,9 +171,30 @@ void resize_systray(void *obj)
 
 int init_net()
 {
+       Window win = XGetSelectionOwner(server.dsp, server.atom._NET_SYSTEM_TRAY_SCREEN);
+
        // freedesktop systray specification
-       if (XGetSelectionOwner(server.dsp, server.atom._NET_SYSTEM_TRAY_SCREEN) != None) {
-               fprintf(stderr, "tint2 : another systray is running\n");
+       if (win != None) {
+               // search pid
+               Atom _NET_WM_PID, actual_type;
+               int actual_format;
+               unsigned long nitems;
+               unsigned long bytes_after;
+               unsigned char *prop;
+               int pid;
+
+               _NET_WM_PID = XInternAtom(server.dsp, "_NET_WM_PID", True);
+               //atom_name = XGetAtomName (dpy,atom);
+
+               int ret = XGetWindowProperty(server.dsp, win, _NET_WM_PID, 0, 1024, False, AnyPropertyType, &actual_type, &actual_format, &nitems, &bytes_after, &prop);
+
+               fprintf(stderr, "tint2 : another systray is running");
+               if (ret == 0) {
+                       pid = prop[1] * 256;
+                       pid += prop[0];
+                       fprintf(stderr, " pid=%d", pid);
+               }
+               fprintf(stderr, "\n");
                return 0;
        }
 
This page took 0.024831 seconds and 4 git commands to generate.