]> Dogcows Code - chaz/tint2/blobdiff - src/systray/systraybar.c
order of panel items : position of each object is update by layering engine (area)
[chaz/tint2] / src / systray / systraybar.c
index 9592fdc9e58c2b416a37e2163e39e323f3d10b78..4161a6a0ea79f19020e6afd55214366540aca47e 100644 (file)
@@ -116,6 +116,53 @@ void init_systray_panel(void *p)
 
 void draw_systray(void *obj, cairo_t *c)
 {
+       // TODO : position and size the icon window when position of systray is known
+       Systraybar *sysbar = obj;
+       Panel *panel = sysbar->area.panel;
+       int i, posx, posy, marging=3, icons_per_column=1, icons_per_row=1;
+       int icon_size = 24;
+       int start = panel->area.bg->border.width + panel->area.paddingy + systray.area.bg->border.width + systray.area.paddingy +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 = icon_size;
+               traywin->height = icon_size;
+               if (panel_horizontal) {
+                       if (i % icons_per_column)
+                               posy += icon_size + sysbar->area.paddingx;
+                       else {
+                               posy = start;
+                               posx += (icon_size + systray.area.paddingx);
+                       }
+               }
+               else {
+                       if (i % icons_per_row)
+                               posx += icon_size + systray.area.paddingx;
+                       else {
+                               posx = start;
+                               posy += (icon_size + systray.area.paddingx);
+                       }
+               }
+
+               // position and size the icon window
+               XMoveResizeWindow(server.dsp, traywin->id, traywin->x, traywin->y, icon_size, icon_size);
+               XResizeWindow(server.dsp, traywin->tray_id, icon_size, 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);
@@ -129,8 +176,6 @@ void draw_systray(void *obj, cairo_t *c)
 int resize_systray(void *obj)
 {
        Systraybar *sysbar = obj;
-       Panel *panel = sysbar->area.panel;
-       TrayWindow *traywin;
        GSList *l;
        int count, icon_size;
        int icons_per_column=1, icons_per_row=1, marging=0;
@@ -159,14 +204,6 @@ int resize_systray(void *obj)
                        icons_per_row = count / icons_per_column + (count%icons_per_column != 0);
                        systray.area.width = (2 * systray.area.bg->border.width) + (2 * systray.area.paddingxlr) + (icon_size * icons_per_row) + ((icons_per_row-1) * systray.area.paddingx);
                }
-
-               systray.area.posx = panel->area.width - panel->area.bg->border.width - panel->area.paddingxlr - systray.area.width;
-               if (panel->clock.area.on_screen)
-                       systray.area.posx -= (panel->clock.area.width + panel->area.paddingx);
-#ifdef ENABLE_BATTERY
-               if (panel->battery.area.on_screen)
-                       systray.area.posx -= (panel->battery.area.width + panel->area.paddingx);
-#endif
        }
        else {
                if (!count) systray.area.height = 0;
@@ -178,55 +215,6 @@ int resize_systray(void *obj)
                        icons_per_column = count / icons_per_row+ (count%icons_per_row != 0);
                        systray.area.height = (2 * systray.area.bg->border.width) + (2 * systray.area.paddingxlr) + (icon_size * icons_per_column) + ((icons_per_column-1) * systray.area.paddingx);
                }
-
-               systray.area.posy = panel->area.bg->border.width + panel->area.paddingxlr;
-               if (panel->clock.area.on_screen)
-                       systray.area.posy += (panel->clock.area.height + panel->area.paddingx);
-#ifdef ENABLE_BATTERY
-               if (panel->battery.area.on_screen)
-                       systray.area.posy += (panel->battery.area.height + panel->area.paddingx);
-#endif
-       }
-
-       int i, posx, posy;
-       int start = panel->area.bg->border.width + panel->area.paddingy + systray.area.bg->border.width + systray.area.paddingy +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;
-       }
-
-       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 = icon_size;
-               traywin->height = icon_size;
-               if (panel_horizontal) {
-                       if (i % icons_per_column)
-                               posy += icon_size + sysbar->area.paddingx;
-                       else {
-                               posy = start;
-                               posx += (icon_size + systray.area.paddingx);
-                       }
-               }
-               else {
-                       if (i % icons_per_row)
-                               posx += icon_size + systray.area.paddingx;
-                       else {
-                               posx = start;
-                               posy += (icon_size + systray.area.paddingx);
-                       }
-               }
-
-               // position and size the icon window
-               XMoveResizeWindow(server.dsp, traywin->id, traywin->x, traywin->y, icon_size, icon_size);
-               XResizeWindow(server.dsp, traywin->tray_id, icon_size, icon_size);
        }
        return 1;
 }
This page took 0.019426 seconds and 4 git commands to generate.