]> Dogcows Code - chaz/tint2/blobdiff - src/systray/systraybar.c
applied patch from yarin.kaul (issue 52)
[chaz/tint2] / src / systray / systraybar.c
index 18c1f22e97ed3e4523316d85f75e6274704812da..232f174b1311124225d0d6e89f5ba678b6c060fd 100644 (file)
@@ -37,7 +37,7 @@ GSList *icons;
 #define SYSTEM_TRAY_CANCEL_MESSAGE  2
 
 // selection window
-Window net_sel_win = None;
+Window net_sel_win = None, hint_win = None;
 
 // freedesktop specification doesn't allow multi systray
 Systraybar systray;
@@ -45,23 +45,14 @@ Systraybar systray;
 
 void init_systray()
 {
-       cleanup_systray();
-
        Panel *panel = &panel1[0];
        systray.area.parent = panel;
        systray.area.panel = panel;
        systray.area._draw_foreground = draw_systray;
        systray.area._resize = resize_systray;
 
-       if (systray.area.on_screen) {
-               if (XGetSelectionOwner(server.dsp, server.atom._NET_SYSTEM_TRAY_SCREEN) != None) {
-                       fprintf(stderr, "tint2 : another systray is running\n");
-                       systray.area.on_screen = 0;
-               }
-       }
-
        if (systray.area.on_screen)
-               systray.area.on_screen = net_init();
+               systray.area.on_screen = init_net();
 
        if (!systray.area.on_screen)
                return;
@@ -75,6 +66,8 @@ void init_systray()
        systray.area.posx = panel->area.width - panel->area.paddingxlr - panel->area.pix.border.width - systray.area.width;
        if (panel->clock.area.on_screen)
                systray.area.posx -= (panel->clock.area.width + panel->area.paddingx);
+       if (panel->battery.area.on_screen)
+               systray.area.posx -= (panel->battery.area.width + panel->area.paddingx);
 
        systray.area.redraw = 1;
 }
@@ -94,10 +87,7 @@ void cleanup_systray()
 
        free_area(&systray.area);
 
-       if (net_sel_win != None) {
-               XDestroyWindow(server.dsp, net_sel_win);
-               net_sel_win = None;
-       }
+       cleanup_net();
 }
 
 
@@ -109,13 +99,13 @@ void draw_systray(void *obj, cairo_t *c, int active)
        GSList *l;
        int icon_size;
 
+       printf("draw_systray %d %d\n", systray.area.posx, systray.area.width);
        icon_size = sysbar->area.height - (2 * sysbar->area.pix.border.width) - (2 * sysbar->area.paddingy);
        for (l = systray.list_icons; l ; l = l->next) {
                traywin = (TrayWindow*)l->data;
 
-               printf("draw_systray %d %d\n", systray.area.posx, systray.area.width);
                // watch for the icon trying to resize itself!
-               XSelectInput(server.dsp, traywin->id, StructureNotifyMask);
+               XSelectInput(server.dsp, traywin->id, StructureNotifyMask|ResizeRedirectMask);
 
                // position and size the icon window
                XMoveResizeWindow(server.dsp, traywin->id, traywin->x, traywin->y, icon_size, icon_size);
@@ -153,6 +143,8 @@ void resize_systray(void *obj)
        systray.area.posx = panel->area.width - panel->area.pix.border.width - panel->area.paddingxlr - systray.area.width;
        if (panel->clock.area.on_screen)
                systray.area.posx -= (panel->clock.area.width + panel->area.paddingx);
+       if (panel->battery.area.on_screen)
+               systray.area.posx -= (panel->battery.area.width + panel->area.paddingx);
 
        systray.area.redraw = 1;
 
@@ -170,9 +162,39 @@ void resize_systray(void *obj)
        printf("resize_systray %d %d\n", systray.area.posx, systray.area.width);
 }
 
+/*
+void create_hint_win()
+{
+   XWMHints hints;
+   XClassHint classhints;
+       Panel *panel = systray.area.panel;
+
+       hint_win = XCreateSimpleWindow(server.dsp, server.root_win, 0, 0, 1, 1, 0, 0, 0);
+
+       hints.flags = StateHint | WindowGroupHint | IconWindowHint;
+       hints.initial_state = WithdrawnState;
+       hints.window_group = hint_win;
+       hints.icon_window = panel->main_win;
+
+       classhints.res_name = "docker";
+       classhints.res_class = "Docker";
+
+       XSetWMProperties(server.dsp, hint_win, NULL, NULL, NULL, 0,
+                                                NULL, &hints, &classhints);
 
-int net_init()
+       XMapWindow(server.dsp, hint_win);
+}
+*/
+
+int init_net()
 {
+       if (XGetSelectionOwner(server.dsp, server.atom._NET_SYSTEM_TRAY_SCREEN) != None) {
+               fprintf(stderr, "tint2 : another systray is running\n");
+               return 0;
+       }
+
+       //create_hint_win();
+
        // init systray protocol
    net_sel_win = XCreateSimpleWindow(server.dsp, server.root_win, -1, -1, 1, 1, 0, 0, 0);
 
@@ -202,7 +224,14 @@ int net_init()
 }
 
 
-//int width, height;
+void cleanup_net()
+{
+       if (net_sel_win != None) {
+               XDestroyWindow(server.dsp, net_sel_win);
+               net_sel_win = None;
+       }
+}
+
 
 /*
 void fix_geometry()
This page took 0.023399 seconds and 4 git commands to generate.