]> Dogcows Code - chaz/tint2/blobdiff - src/systray/systraybar.c
rendering engine : _on_change_layout() called when pos/size changed
[chaz/tint2] / src / systray / systraybar.c
index 22fc50ba978a126ee7d328b001f7019d25cfeb72..23d2ab3821d1b58883ed1a0a380dd36a1bea2626 100644 (file)
@@ -61,6 +61,7 @@ void default_systray()
        systray.alpha = 100;
        systray.sort = 3;
        systray.area._draw_foreground = draw_systray;
+       systray.area._on_change_layout = on_change_systray;
        systray.area.size_mode = SIZE_BY_CONTENT;
        systray.area._resize = resize_systray;
 }
@@ -114,52 +115,6 @@ void init_systray_panel(void *p)
 
 void draw_systray(void *obj, cairo_t *c)
 {
-       // here, sysbar's position is defined. so we can calculate position of tray icon.
-       Systraybar *sysbar = obj;
-       Panel *panel = sysbar->area.panel;
-       int i, posx, posy;
-       int start = panel->area.bg->border.width + panel->area.paddingy + systray.area.bg->border.width + systray.area.paddingy +sysbar->marging/2;
-       if (panel_horizontal) {
-               posy = start;
-               posx = systray.area.posx + systray.area.bg->border.width + systray.area.paddingxlr;
-       }
-       else {
-               posx = start;
-               posy = systray.area.posy + systray.area.bg->border.width + systray.area.paddingxlr;
-       }
-
-       TrayWindow *traywin;
-       GSList *l;
-       for (i=1, l = systray.list_icons; l ; i++, l = l->next) {
-               traywin = (TrayWindow*)l->data;
-               if (traywin->hide) continue;
-
-               traywin->y = posy;
-               traywin->x = posx;
-               traywin->width = sysbar->icon_size;
-               traywin->height = sysbar->icon_size;
-               if (panel_horizontal) {
-                       if (i % sysbar->icons_per_column)
-                               posy += sysbar->icon_size + sysbar->area.paddingx;
-                       else {
-                               posy = start;
-                               posx += (sysbar->icon_size + systray.area.paddingx);
-                       }
-               }
-               else {
-                       if (i % sysbar->icons_per_row)
-                               posx += sysbar->icon_size + systray.area.paddingx;
-                       else {
-                               posx = start;
-                               posy += (sysbar->icon_size + systray.area.paddingx);
-                       }
-               }
-
-               // position and size the icon window
-               XMoveResizeWindow(server.dsp, traywin->id, traywin->x, traywin->y, sysbar->icon_size, sysbar->icon_size);
-               XResizeWindow(server.dsp, traywin->tray_id, sysbar->icon_size, sysbar->icon_size);
-       }
-
        if (server.real_transparency || systray.alpha != 100 || systray.brightness != 0 || systray.saturation != 0) {
                if (render_background) XFreePixmap(server.dsp, render_background);
                render_background = XCreatePixmap(server.dsp, server.root_win, systray.area.width, systray.area.height, server.depth);
@@ -210,6 +165,56 @@ int resize_systray(void *obj)
 }
 
 
+void on_change_systray (void *obj)
+{
+       // here, sysbar's position is defined. so we can calculate position of tray icon.
+       Systraybar *sysbar = obj;
+       Panel *panel = sysbar->area.panel;
+       int i, posx, posy;
+       int start = panel->area.bg->border.width + panel->area.paddingy + systray.area.bg->border.width + systray.area.paddingy +sysbar->marging/2;
+       if (panel_horizontal) {
+               posy = start;
+               posx = systray.area.posx + systray.area.bg->border.width + systray.area.paddingxlr;
+       }
+       else {
+               posx = start;
+               posy = systray.area.posy + systray.area.bg->border.width + systray.area.paddingxlr;
+       }
+
+       TrayWindow *traywin;
+       GSList *l;
+       for (i=1, l = systray.list_icons; l ; i++, l = l->next) {
+               traywin = (TrayWindow*)l->data;
+               if (traywin->hide) continue;
+
+               traywin->y = posy;
+               traywin->x = posx;
+               traywin->width = sysbar->icon_size;
+               traywin->height = sysbar->icon_size;
+               if (panel_horizontal) {
+                       if (i % sysbar->icons_per_column)
+                               posy += sysbar->icon_size + sysbar->area.paddingx;
+                       else {
+                               posy = start;
+                               posx += (sysbar->icon_size + systray.area.paddingx);
+                       }
+               }
+               else {
+                       if (i % sysbar->icons_per_row)
+                               posx += sysbar->icon_size + systray.area.paddingx;
+                       else {
+                               posx = start;
+                               posy += (sysbar->icon_size + systray.area.paddingx);
+                       }
+               }
+
+               // position and size the icon window
+               XMoveResizeWindow(server.dsp, traywin->id, traywin->x, traywin->y, sysbar->icon_size, sysbar->icon_size);
+               XResizeWindow(server.dsp, traywin->tray_id, sysbar->icon_size, sysbar->icon_size);
+       }
+}
+
+
 // ***********************************************
 // systray protocol
 
This page took 0.020728 seconds and 4 git commands to generate.