]> Dogcows Code - chaz/tint2/commitdiff
panel_items : fixed segfault (panel without clock, change number desktop)
authorThierry Lorthiois <lorthiois@bbsoft.fr>
Sat, 18 Sep 2010 18:06:29 +0000 (18:06 +0000)
committerThierry Lorthiois <lorthiois@bbsoft.fr>
Sat, 18 Sep 2010 18:06:29 +0000 (18:06 +0000)
src/launcher/launcher.c
src/panel.c
src/panel.h
src/systray/systraybar.c
src/taskbar/taskbar.c
src/taskbar/taskbar.h
src/tint.c
src/util/area.h

index 75388f1099b24fd9ee9975382610049336b7a8a6..ea456546318be4fd5414353e4388fcae089fc6fa 100644 (file)
@@ -157,7 +157,6 @@ void cleanup_launcher()
 int resize_launcher(void *obj)
 {
        Launcher *launcher = obj;
-       Panel *panel = launcher->area.panel;
        GSList *l;
        int count, icon_size;
        int icons_per_column=1, icons_per_row=1, marging=0;
index a680bb480100af715dc061358784808a0658297b..9754de79ee22b9585ed9eff799c2f8e21dec2b29 100644 (file)
@@ -126,7 +126,7 @@ void cleanup_panel()
 
 void init_panel()
 {
-       int i, j;
+       int i;
        Panel *p;
 
        if (panel_config.monitor > (server.nb_monitor-1)) {
@@ -142,6 +142,7 @@ void init_panel()
 #ifdef ENABLE_BATTERY
        init_battery();
 #endif
+       init_taskbar();
 
        // number of panels (one monitor or 'all' monitors)
        if (panel_config.monitor >= 0)
@@ -172,38 +173,8 @@ void init_panel()
                p->g_taskbar.area.panel = p;
                p->g_task.area.panel = p;
                init_panel_size_and_position(p);
-               // add childs occording to panel_items_order
-               int k;
-               for (k=0 ; k < strlen(panel_items_order) ; k++) {
-                       if (panel_items_order[k] == 'L') {
-                               init_launcher_panel(p);
-                               p->area.list = g_slist_append(p->area.list, &p->launcher);
-                       }
-                       if (panel_items_order[k] == 'T') {
-                               p->nb_desktop = server.nb_desktop;
-                               p->taskbar = calloc(p->nb_desktop, sizeof(Taskbar));
-                               for (j=0 ; j < p->nb_desktop ; j++) {
-                                       p->area.list = g_slist_append(p->area.list, &p->taskbar[j]);
-                               }
-                               //printf("init taskbar\n");
-                       }
-#ifdef ENABLE_BATTERY
-                       if (panel_items_order[k] == 'B') {
-                               init_battery_panel(p);
-                               p->area.list = g_slist_append(p->area.list, &p->battery);
-                       }
-#endif
-                       if (panel_items_order[k] == 'S') {
-                               // TODO : check systray is only on 1 panel
-                               init_systray_panel(p);
-                               p->area.list = g_slist_append(p->area.list, &systray);
-                               refresh_systray = 1;
-                       }
-                       if (panel_items_order[k] == 'C') {
-                               init_clock_panel(p);
-                               p->area.list = g_slist_append(p->area.list, &p->clock);
-                       }
-               }
+               // add childs according to panel_items
+               set_panel_items(p);
 
                // catch some events
                XSetWindowAttributes att = { .colormap=server.colormap, .background_pixel=0, .border_pixel=0 };
@@ -234,7 +205,6 @@ void init_panel()
        }
 
        panel_refresh = 1;
-       init_taskbar();
        visible_object();
        task_refresh_tasklist();
        active_task();
@@ -483,6 +453,45 @@ void update_strut(Panel* p)
 }
 
 
+void set_panel_items(Panel *p)
+{
+       int k, j;
+       
+       if (p->area.list) {
+               g_slist_free(p->area.list);
+               p->area.list = 0;
+       }
+
+       for (k=0 ; k < strlen(panel_items_order) ; k++) {
+               if (panel_items_order[k] == 'L') {
+                       init_launcher_panel(p);
+                       p->area.list = g_slist_append(p->area.list, &p->launcher);
+               }
+               if (panel_items_order[k] == 'T') {
+                       init_taskbar_panel(p);
+                       for (j=0 ; j < p->nb_desktop ; j++)
+                               p->area.list = g_slist_append(p->area.list, &p->taskbar[j]);
+               }
+#ifdef ENABLE_BATTERY
+               if (panel_items_order[k] == 'B') {
+                       init_battery_panel(p);
+                       p->area.list = g_slist_append(p->area.list, &p->battery);
+               }
+#endif
+               if (panel_items_order[k] == 'S') {
+                       // TODO : check systray is only on 1 panel
+                       init_systray_panel(p);
+                       refresh_systray = 1;
+                       p->area.list = g_slist_append(p->area.list, &systray);
+               }
+               if (panel_items_order[k] == 'C') {
+                       init_clock_panel(p);
+                       p->area.list = g_slist_append(p->area.list, &p->clock);
+               }
+       }
+}
+
+
 void set_panel_properties(Panel *p)
 {
        XStoreName (server.dsp, p->main_win, "tint2");
index 67371c92b10d7edd6aca9981d4a130c789d21c9b..083d0f1cf540b89388f3ae39516c9dd389175491 100644 (file)
@@ -137,6 +137,7 @@ void init_panel();
 void init_panel_size_and_position(Panel *panel);
 int  resize_panel(void *obj);
 
+void set_panel_items(Panel *p);
 void set_panel_properties(Panel *p);
 void visible_object();
 
index 4161a6a0ea79f19020e6afd55214366540aca47e..f1eb7c5273c4c9ebfa6fc9d1d877493238b81d5b 100644 (file)
@@ -90,10 +90,6 @@ void init_systray()
                systray.alpha = 100;
                systray.brightness = systray.saturation = 0;
        }
-       systray.area.resize = 1;
-       systray.area.redraw = 1;
-       systray.area.on_screen = 1;
-       refresh_systray = 0;
 }
 
 
@@ -111,6 +107,18 @@ void init_systray_panel(void *p)
        }
        systray.area.parent = p;
        systray.area.panel = p;
+       
+       GSList *l;
+       int count = 0;
+       for (l = systray.list_icons; l ; l = l->next) {
+               if (!((TrayWindow*)l->data)->hide)
+                       count++;
+       }
+       if (count == 0)
+               systray.area.on_screen = 0;
+       else 
+               systray.area.on_screen = 1;
+       refresh_systray = 0;
 }
 
 
@@ -195,26 +203,20 @@ int resize_systray(void *obj)
        //printf("count %d\n", count);
 
        if (panel_horizontal) {
-               if (!count) systray.area.width = 0;
-               else {
-                       int height = sysbar->area.height - 2*sysbar->area.bg->border.width - 2*sysbar->area.paddingy;
-                       // here icons_per_column always higher than 0
-                       icons_per_column = (height+sysbar->area.paddingx) / (icon_size+sysbar->area.paddingx);
-                       marging = height - (icons_per_column-1)*(icon_size+sysbar->area.paddingx) - icon_size;
-                       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);
-               }
+               int height = sysbar->area.height - 2*sysbar->area.bg->border.width - 2*sysbar->area.paddingy;
+               // here icons_per_column always higher than 0
+               icons_per_column = (height+sysbar->area.paddingx) / (icon_size+sysbar->area.paddingx);
+               marging = height - (icons_per_column-1)*(icon_size+sysbar->area.paddingx) - icon_size;
+               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);
        }
        else {
-               if (!count) systray.area.height = 0;
-               else {
-                       int width = sysbar->area.width - 2*sysbar->area.bg->border.width - 2*sysbar->area.paddingy;
-                       // here icons_per_row always higher than 0
-                       icons_per_row = (width+sysbar->area.paddingx) / (icon_size+sysbar->area.paddingx);
-                       marging = width - (icons_per_row-1)*(icon_size+sysbar->area.paddingx) - icon_size;
-                       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);
-               }
+               int width = sysbar->area.width - 2*sysbar->area.bg->border.width - 2*sysbar->area.paddingy;
+               // here icons_per_row always higher than 0
+               icons_per_row = (width+sysbar->area.paddingx) / (icon_size+sysbar->area.paddingx);
+               marging = width - (icons_per_row-1)*(icon_size+sysbar->area.paddingx) - icon_size;
+               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);
        }
        return 1;
 }
@@ -433,6 +435,9 @@ gboolean add_icon(Window id)
        traywin->depth = attr.depth;
        traywin->damage = 0;
 
+       if (systray.area.on_screen == 0)
+               systray.area.on_screen = 1;
+
        if (systray.sort == 3)
                systray.list_icons = g_slist_prepend(systray.list_icons, traywin);
        else if (systray.sort == 2)
@@ -488,6 +493,17 @@ void remove_icon(TrayWindow *traywin)
                stop_timeout(traywin->render_timeout);
        g_free(traywin);
 
+       // check empty systray
+       int count = 0;
+       GSList *l;
+       for (l = systray.list_icons; l ; l = l->next) {
+               if (!((TrayWindow*)l->data)->hide)
+                       count++;
+       }
+       if (count == 0) {
+               systray.area.on_screen = 0;
+               systray.area.width = 0;
+       }
        // changed in systray force resize on panel
        Panel *panel = systray.area.panel;
        panel->area.resize = 1;
index 02cfbb0d076279c136ac83bfde13ca86eae4bb78..2b505dfeab06a32837eebf3fb4145b4020b01b1e 100644 (file)
@@ -46,128 +46,6 @@ guint win_hash(gconstpointer key) { return (guint)*((Window*)key); }
 gboolean win_compare(gconstpointer a, gconstpointer b) { return (*((Window*)a) == *((Window*)b)); }
 void free_ptr_array(gpointer data) { g_ptr_array_free(data, 1); }
 
-void init_taskbar()
-{
-       Panel *panel;
-       int i, j;
-
-       if (win_to_task_table == 0)
-               win_to_task_table = g_hash_table_new_full(win_hash, win_compare, free, free_ptr_array);
-
-       task_active = 0;
-       task_drag = 0;
-
-       for (i=0 ; i < nb_panel ; i++) {
-               panel = &panel1[i];
-
-               if (panel->g_taskbar.bg == 0) {
-                       panel->g_taskbar.bg = &g_array_index(backgrounds, Background, 0);
-                       panel->g_taskbar.area.bg = panel->g_taskbar.bg;
-               }
-               if (panel->g_taskbar.bg_active == 0)
-                       panel->g_taskbar.bg_active = panel->g_taskbar.bg;
-               if (panel->g_task.area.bg == 0)
-                       panel->g_task.area.bg = &g_array_index(backgrounds, Background, 0);
-
-               // taskbar
-               panel->g_taskbar.area.size_mode = SIZE_BY_LAYOUT;
-               panel->g_taskbar.area._resize = resize_taskbar;
-               panel->g_taskbar.area.redraw = 1;
-               panel->g_taskbar.area.on_screen = 1;
-               if (panel_horizontal) {
-                       panel->g_taskbar.area.posy = panel->area.bg->border.width + panel->area.paddingy;
-                       panel->g_taskbar.area.height = panel->area.height - (2 * panel->g_taskbar.area.posy);
-               }
-               else {
-                       panel->g_taskbar.area.posx = panel->area.bg->border.width + panel->area.paddingy;
-                       panel->g_taskbar.area.width = panel->area.width - (2 * panel->g_taskbar.area.posx);
-               }
-
-               // task
-               panel->g_task.area.size_mode = SIZE_BY_LAYOUT;
-               panel->g_task.area._draw_foreground = draw_task;
-               panel->g_task.area.redraw = 1;
-               panel->g_task.area.on_screen = 1;
-               if ((panel->g_task.config_asb_mask & (1<<TASK_NORMAL)) == 0) {
-                       panel->g_task.alpha[TASK_NORMAL] = 100;
-                       panel->g_task.saturation[TASK_NORMAL] = 0;
-                       panel->g_task.brightness[TASK_NORMAL] = 0;
-               }
-               if ((panel->g_task.config_asb_mask & (1<<TASK_ACTIVE)) == 0) {
-                       panel->g_task.alpha[TASK_ACTIVE] = panel->g_task.alpha[TASK_NORMAL];
-                       panel->g_task.saturation[TASK_ACTIVE] = panel->g_task.saturation[TASK_NORMAL];
-                       panel->g_task.brightness[TASK_ACTIVE] = panel->g_task.brightness[TASK_NORMAL];
-               }
-               if ((panel->g_task.config_asb_mask & (1<<TASK_ICONIFIED)) == 0) {
-                       panel->g_task.alpha[TASK_ICONIFIED] = panel->g_task.alpha[TASK_NORMAL];
-                       panel->g_task.saturation[TASK_ICONIFIED] = panel->g_task.saturation[TASK_NORMAL];
-                       panel->g_task.brightness[TASK_ICONIFIED] = panel->g_task.brightness[TASK_NORMAL];
-               }
-               if ((panel->g_task.config_asb_mask & (1<<TASK_URGENT)) == 0) {
-                       panel->g_task.alpha[TASK_URGENT] = panel->g_task.alpha[TASK_ACTIVE];
-                       panel->g_task.saturation[TASK_URGENT] = panel->g_task.saturation[TASK_ACTIVE];
-                       panel->g_task.brightness[TASK_URGENT] = panel->g_task.brightness[TASK_ACTIVE];
-               }
-               if ((panel->g_task.config_font_mask & (1<<TASK_NORMAL)) == 0) panel->g_task.font[TASK_NORMAL] = (Color){{0, 0, 0}, 0};
-               if ((panel->g_task.config_font_mask & (1<<TASK_ACTIVE)) == 0) panel->g_task.font[TASK_ACTIVE] = panel->g_task.font[TASK_NORMAL];
-               if ((panel->g_task.config_font_mask & (1<<TASK_ICONIFIED)) == 0) panel->g_task.font[TASK_ICONIFIED] = panel->g_task.font[TASK_NORMAL];
-               if ((panel->g_task.config_font_mask & (1<<TASK_URGENT)) == 0) panel->g_task.font[TASK_URGENT] = panel->g_task.font[TASK_ACTIVE];
-               if ((panel->g_task.config_font_mask & (1<<TASK_NORMAL)) == 0) panel->g_task.background[TASK_NORMAL] = &g_array_index(backgrounds, Background, 0);
-               if ((panel->g_task.config_background_mask & (1<<TASK_ACTIVE)) == 0) panel->g_task.background[TASK_ACTIVE] = panel->g_task.background[TASK_NORMAL];
-               if ((panel->g_task.config_background_mask & (1<<TASK_ICONIFIED)) == 0) panel->g_task.background[TASK_ICONIFIED] = panel->g_task.background[TASK_NORMAL];
-               if ((panel->g_task.config_background_mask & (1<<TASK_URGENT)) == 0) panel->g_task.background[TASK_URGENT] = panel->g_task.background[TASK_ACTIVE];
-
-               if (panel_horizontal) {
-                       panel->g_task.area.posy = panel->g_taskbar.area.posy + panel->g_taskbar.bg->border.width + panel->g_taskbar.area.paddingy;
-                       panel->g_task.area.height = panel->area.height - (2 * panel->g_task.area.posy);
-               }
-               else {
-                       panel->g_task.area.posx = panel->g_taskbar.area.posx + panel->g_taskbar.bg->border.width + panel->g_taskbar.area.paddingy;
-                       panel->g_task.area.width = panel->area.width - (2 * panel->g_task.area.posx);
-                       panel->g_task.area.height = panel->g_task.maximum_height;
-               }
-
-               int k;
-               for (k=0; k<TASK_STATE_COUNT; ++k) {
-                       if (panel->g_task.background[k]->border.rounded > panel->g_task.area.height/2) {
-                               printf("task%sbackground_id has a too large rounded value. Please fix your tint2rc\n", k==0 ? "_" : k==1 ? "_active_" : k==2 ? "_iconified_" : "_urgent_");
-                               g_array_append_val(backgrounds, *panel->g_task.background[k]);
-                               panel->g_task.background[k] = &g_array_index(backgrounds, Background, backgrounds->len-1);
-                               panel->g_task.background[k]->border.rounded = panel->g_task.area.height/2;
-                       }
-               }
-
-               // compute vertical position : text and icon
-               int height_ink, height;
-               get_text_size(panel->g_task.font_desc, &height_ink, &height, panel->area.height, "TAjpg", 5);
-
-               if (!panel->g_task.maximum_width && panel_horizontal)
-                       panel->g_task.maximum_width = server.monitor[panel->monitor].width;
-
-               panel->g_task.text_posx = panel->g_task.background[0]->border.width + panel->g_task.area.paddingxlr;
-               panel->g_task.text_height = panel->g_task.area.height - (2 * panel->g_task.area.paddingy);
-               if (panel->g_task.icon) {
-                       panel->g_task.icon_size1 = panel->g_task.area.height - (2 * panel->g_task.area.paddingy);
-                       panel->g_task.text_posx += panel->g_task.icon_size1;
-                       panel->g_task.icon_posy = (panel->g_task.area.height - panel->g_task.icon_size1) / 2;
-               }
-               //printf("monitor %d, task_maximum_width %d\n", panel->monitor, panel->g_task.maximum_width);
-
-               Taskbar *tskbar;
-               for (j=0 ; j < panel->nb_desktop ; j++) {
-                       tskbar = &panel->taskbar[j];
-                       memcpy(&tskbar->area, &panel->g_taskbar, sizeof(Area));
-                       tskbar->desktop = j;
-                       if (j == server.desktop && panel->g_taskbar.use_active)
-                               tskbar->area.bg = panel->g_taskbar.bg_active;
-               }
-       }
-}
-
-void taskbar_remove_task(gpointer key, gpointer value, gpointer user_data)
-{
-       remove_task(task_get_task(*(Window*)key));
-}
 
 void default_taskbar()
 {
@@ -204,6 +82,132 @@ void cleanup_taskbar()
 }
 
 
+void init_taskbar()
+{
+       if (win_to_task_table == 0)
+               win_to_task_table = g_hash_table_new_full(win_hash, win_compare, free, free_ptr_array);
+
+       task_active = 0;
+       task_drag = 0;
+}
+
+
+void init_taskbar_panel(void *p)
+{
+       Panel *panel =(Panel*)p;
+       int j;
+
+       if (panel->g_taskbar.bg == 0) {
+               panel->g_taskbar.bg = &g_array_index(backgrounds, Background, 0);
+               panel->g_taskbar.area.bg = panel->g_taskbar.bg;
+       }
+       if (panel->g_taskbar.bg_active == 0)
+               panel->g_taskbar.bg_active = panel->g_taskbar.bg;
+       if (panel->g_task.area.bg == 0)
+               panel->g_task.area.bg = &g_array_index(backgrounds, Background, 0);
+
+       // taskbar
+       panel->g_taskbar.area.size_mode = SIZE_BY_LAYOUT;
+       panel->g_taskbar.area._resize = resize_taskbar;
+       panel->g_taskbar.area.redraw = 1;
+       panel->g_taskbar.area.on_screen = 1;
+       if (panel_horizontal) {
+               panel->g_taskbar.area.posy = panel->area.bg->border.width + panel->area.paddingy;
+               panel->g_taskbar.area.height = panel->area.height - (2 * panel->g_taskbar.area.posy);
+       }
+       else {
+               panel->g_taskbar.area.posx = panel->area.bg->border.width + panel->area.paddingy;
+               panel->g_taskbar.area.width = panel->area.width - (2 * panel->g_taskbar.area.posx);
+       }
+
+       // task
+       panel->g_task.area.size_mode = SIZE_BY_LAYOUT;
+       panel->g_task.area._draw_foreground = draw_task;
+       panel->g_task.area.redraw = 1;
+       panel->g_task.area.on_screen = 1;
+       if ((panel->g_task.config_asb_mask & (1<<TASK_NORMAL)) == 0) {
+               panel->g_task.alpha[TASK_NORMAL] = 100;
+               panel->g_task.saturation[TASK_NORMAL] = 0;
+               panel->g_task.brightness[TASK_NORMAL] = 0;
+       }
+       if ((panel->g_task.config_asb_mask & (1<<TASK_ACTIVE)) == 0) {
+               panel->g_task.alpha[TASK_ACTIVE] = panel->g_task.alpha[TASK_NORMAL];
+               panel->g_task.saturation[TASK_ACTIVE] = panel->g_task.saturation[TASK_NORMAL];
+               panel->g_task.brightness[TASK_ACTIVE] = panel->g_task.brightness[TASK_NORMAL];
+       }
+       if ((panel->g_task.config_asb_mask & (1<<TASK_ICONIFIED)) == 0) {
+               panel->g_task.alpha[TASK_ICONIFIED] = panel->g_task.alpha[TASK_NORMAL];
+               panel->g_task.saturation[TASK_ICONIFIED] = panel->g_task.saturation[TASK_NORMAL];
+               panel->g_task.brightness[TASK_ICONIFIED] = panel->g_task.brightness[TASK_NORMAL];
+       }
+       if ((panel->g_task.config_asb_mask & (1<<TASK_URGENT)) == 0) {
+               panel->g_task.alpha[TASK_URGENT] = panel->g_task.alpha[TASK_ACTIVE];
+               panel->g_task.saturation[TASK_URGENT] = panel->g_task.saturation[TASK_ACTIVE];
+               panel->g_task.brightness[TASK_URGENT] = panel->g_task.brightness[TASK_ACTIVE];
+       }
+       if ((panel->g_task.config_font_mask & (1<<TASK_NORMAL)) == 0) panel->g_task.font[TASK_NORMAL] = (Color){{0, 0, 0}, 0};
+       if ((panel->g_task.config_font_mask & (1<<TASK_ACTIVE)) == 0) panel->g_task.font[TASK_ACTIVE] = panel->g_task.font[TASK_NORMAL];
+       if ((panel->g_task.config_font_mask & (1<<TASK_ICONIFIED)) == 0) panel->g_task.font[TASK_ICONIFIED] = panel->g_task.font[TASK_NORMAL];
+       if ((panel->g_task.config_font_mask & (1<<TASK_URGENT)) == 0) panel->g_task.font[TASK_URGENT] = panel->g_task.font[TASK_ACTIVE];
+       if ((panel->g_task.config_font_mask & (1<<TASK_NORMAL)) == 0) panel->g_task.background[TASK_NORMAL] = &g_array_index(backgrounds, Background, 0);
+       if ((panel->g_task.config_background_mask & (1<<TASK_ACTIVE)) == 0) panel->g_task.background[TASK_ACTIVE] = panel->g_task.background[TASK_NORMAL];
+       if ((panel->g_task.config_background_mask & (1<<TASK_ICONIFIED)) == 0) panel->g_task.background[TASK_ICONIFIED] = panel->g_task.background[TASK_NORMAL];
+       if ((panel->g_task.config_background_mask & (1<<TASK_URGENT)) == 0) panel->g_task.background[TASK_URGENT] = panel->g_task.background[TASK_ACTIVE];
+
+       if (panel_horizontal) {
+               panel->g_task.area.posy = panel->g_taskbar.area.posy + panel->g_taskbar.bg->border.width + panel->g_taskbar.area.paddingy;
+               panel->g_task.area.height = panel->area.height - (2 * panel->g_task.area.posy);
+       }
+       else {
+               panel->g_task.area.posx = panel->g_taskbar.area.posx + panel->g_taskbar.bg->border.width + panel->g_taskbar.area.paddingy;
+               panel->g_task.area.width = panel->area.width - (2 * panel->g_task.area.posx);
+               panel->g_task.area.height = panel->g_task.maximum_height;
+       }
+
+       for (j=0; j<TASK_STATE_COUNT; ++j) {
+               if (panel->g_task.background[j]->border.rounded > panel->g_task.area.height/2) {
+                       printf("task%sbackground_id has a too large rounded value. Please fix your tint2rc\n", j==0 ? "_" : j==1 ? "_active_" : j==2 ? "_iconified_" : "_urgent_");
+                       g_array_append_val(backgrounds, *panel->g_task.background[j]);
+                       panel->g_task.background[j] = &g_array_index(backgrounds, Background, backgrounds->len-1);
+                       panel->g_task.background[j]->border.rounded = panel->g_task.area.height/2;
+               }
+       }
+
+       // compute vertical position : text and icon
+       int height_ink, height;
+       get_text_size(panel->g_task.font_desc, &height_ink, &height, panel->area.height, "TAjpg", 5);
+
+       if (!panel->g_task.maximum_width && panel_horizontal)
+               panel->g_task.maximum_width = server.monitor[panel->monitor].width;
+
+       panel->g_task.text_posx = panel->g_task.background[0]->border.width + panel->g_task.area.paddingxlr;
+       panel->g_task.text_height = panel->g_task.area.height - (2 * panel->g_task.area.paddingy);
+       if (panel->g_task.icon) {
+               panel->g_task.icon_size1 = panel->g_task.area.height - (2 * panel->g_task.area.paddingy);
+               panel->g_task.text_posx += panel->g_task.icon_size1;
+               panel->g_task.icon_posy = (panel->g_task.area.height - panel->g_task.icon_size1) / 2;
+       }
+       //printf("monitor %d, task_maximum_width %d\n", panel->monitor, panel->g_task.maximum_width);
+
+       Taskbar *tskbar;
+       panel->nb_desktop = server.nb_desktop;
+       panel->taskbar = calloc(server.nb_desktop, sizeof(Taskbar));
+       for (j=0 ; j < panel->nb_desktop ; j++) {
+               tskbar = &panel->taskbar[j];
+               memcpy(&tskbar->area, &panel->g_taskbar, sizeof(Area));
+               tskbar->desktop = j;
+               if (j == server.desktop && panel->g_taskbar.use_active)
+                       tskbar->area.bg = panel->g_taskbar.bg_active;
+       }
+}
+
+
+void taskbar_remove_task(gpointer key, gpointer value, gpointer user_data)
+{
+       remove_task(task_get_task(*(Window*)key));
+}
+
+
 Task *task_get_task (Window win)
 {
        GPtrArray* task_group = task_get_tasks(win);
index 583cd36e9167fee5999db82bde5ec49a06e9c394..6622858378f6954ffad5474aefa3639ad2afbcea 100644 (file)
@@ -44,7 +44,9 @@ void default_taskbar();
 void cleanup_taskbar();
 
 void init_taskbar();
+void init_taskbar_panel(void *p);
 
+void taskbar_remove_task(gpointer key, gpointer value, gpointer user_data);
 Task *task_get_task (Window win);
 GPtrArray* task_get_tasks(Window win);
 void task_refresh_tasklist ();
index fd89b8c468a528467ec22347a4913fee61c19894..2ba8727d05297a8b5188db4e1dcb812773f27e2a 100644 (file)
@@ -490,10 +490,11 @@ void event_property_notify (XEvent *e)
                        server.nb_desktop = server_get_number_of_desktop ();
                        cleanup_taskbar();
                        init_taskbar();
-                       visible_object();
                        for (i=0 ; i < nb_panel ; i++) {
+                               set_panel_items(&panel1[i]);
                                panel1[i].area.resize = 1;
                        }
+                       visible_object();
                        task_refresh_tasklist();
                        active_task();
                        panel_refresh = 1;
@@ -883,7 +884,7 @@ start:
                                                        signal_pending = SIGUSR1;
                                                        break;
                                                }
-                                               if (e.xany.window == g_tooltip.window || !systray.area.on_screen)
+                                               if (e.xany.window == g_tooltip.window || !systray_enabled)
                                                        break;
                                                for (it = systray.list_icons; it; it = g_slist_next(it)) {
                                                        if (((TrayWindow*)it->data)->tray_id == e.xany.window) {
@@ -903,7 +904,7 @@ start:
                                                                // Start real_transparency
                                                                signal_pending = SIGUSR1;
                                                }
-                                               if (systray.area.on_screen && e.xclient.message_type == server.atom._NET_SYSTEM_TRAY_OPCODE && e.xclient.format == 32 && e.xclient.window == net_sel_win) {
+                                               if (systray_enabled && e.xclient.message_type == server.atom._NET_SYSTEM_TRAY_OPCODE && e.xclient.format == 32 && e.xclient.window == net_sel_win) {
                                                        net_message(&e.xclient);
                                                }
                                                else if (e.xclient.message_type == server.atom.XdndPosition) {
index b016674ed4f3c97f602addd00252e5a42e42b506..16465b29daeb1d7d5e0f79051842e82b4cac39b8 100644 (file)
@@ -63,7 +63,8 @@ typedef struct {
        // list of child : Area object
        GSList *list;
 
-       // object visible on screen
+       // object visible on screen. 
+       // An object (like systray) could be enabled but hidden (because no tray icon).
        int on_screen;
        // way to calculate the size (SIZE_BY_CONTENT or SIZE_BY_LAYOUT)
        int size_mode;
This page took 0.039454 seconds and 4 git commands to generate.