From: Thierry Lorthiois Date: Sat, 18 Sep 2010 14:58:00 +0000 (+0000) Subject: panel_items : fixed some segfault. X-Git-Url: https://git.dogcows.com/gitweb?a=commitdiff_plain;h=9daa525aab5dfb62788865e4cbe4d92ddf055e93;p=chaz%2Ftint2 panel_items : fixed some segfault. --- diff --git a/src/battery/battery.c b/src/battery/battery.c index 8fd6aa0..086b6d0 100644 --- a/src/battery/battery.c +++ b/src/battery/battery.c @@ -73,17 +73,20 @@ void update_batterys(void* arg) if (battery_state.percentage >= percentage_hide) { if (panel1[i].battery.area.on_screen == 1) { panel1[i].battery.area.on_screen = 0; + panel1[i].area.resize = 1; panel_refresh = 1; } - continue; } else { if (panel1[i].battery.area.on_screen == 0) { panel1[i].battery.area.on_screen = 1; - panel_refresh = 1; + panel1[i].area.resize = 1; } } - panel1[i].battery.area.resize = 1; + if (panel1[i].battery.area.on_screen == 1) { + panel1[i].battery.area.resize = 1; + panel_refresh = 1; + } } } @@ -448,7 +451,6 @@ int resize_battery(void *obj) percentage_width = time_width = 0; battery->area.redraw = 1; - snprintf(buf_bat_percentage, sizeof(buf_bat_percentage), "%d%%", battery_state.percentage); if(battery_state.state == BATTERY_FULL) { strcpy(buf_bat_time, "Full"); diff --git a/src/clock/clock.c b/src/clock/clock.c index 783f7e9..70babb6 100644 --- a/src/clock/clock.c +++ b/src/clock/clock.c @@ -151,8 +151,11 @@ void init_clock_panel(void *p) clock->area._resize = resize_clock; clock->area.resize = 1; clock->area.redraw = 1; - clock->area.on_screen = 1; + // check consistency + if (time1_format == 0) + return; + clock->area.on_screen = 1; strftime(buf_time, sizeof(buf_time), time1_format, clock_gettime_for_tz(time1_timezone)); get_text_size(time1_font_desc, &time_height_ink, &time_height, panel->area.height, buf_time, strlen(buf_time)); if (time2_format) { @@ -167,8 +170,6 @@ void init_clock_panel(void *p) } else { // panel vertical => fixed width, height, posy and posx -// clock->area.posy = panel->area.bg->border.width + panel->area.paddingxlr; -// clock->area.height = (2 * clock->area.paddingxlr) + (time_height + date_height); clock->area.posx = panel->area.bg->border.width + panel->area.paddingy; clock->area.width = panel->area.width - (2 * panel->area.bg->border.width) - (2 * panel->area.paddingy); } @@ -236,7 +237,11 @@ int resize_clock (void *obj) strftime(buf_date, sizeof(buf_date), time2_format, clock_gettime_for_tz(time2_timezone)); // vertical panel doen't adjust width - if (!panel_horizontal) return ret; + if (!panel_horizontal) { +// clock->area.posy = panel->area.bg->border.width + panel->area.paddingxlr; +// clock->area.height = (2 * clock->area.paddingxlr) + (time_height + date_height); + return ret; + } //printf(" resize_clock\n"); cairo_surface_t *cs; diff --git a/src/launcher/launcher.c b/src/launcher/launcher.c index 50d3829..75388f1 100644 --- a/src/launcher/launcher.c +++ b/src/launcher/launcher.c @@ -70,8 +70,12 @@ void init_launcher_panel(void *p) launcher->area._resize = resize_launcher; launcher->area.resize = 1; launcher->area.redraw = 1; - launcher->area.on_screen = 1; + // check consistency + if (launcher->list_apps == NULL) + return; + + launcher->area.on_screen = 1; if (panel_horizontal) { // panel horizonal => fixed height and posy launcher->area.posy = panel->area.bg->border.width + panel->area.paddingy; @@ -149,6 +153,7 @@ void cleanup_launcher() launcher_enabled = 0; } + int resize_launcher(void *obj) { Launcher *launcher = obj; @@ -222,9 +227,6 @@ int resize_launcher(void *obj) icons_per_row = count / icons_per_column + (count%icons_per_column != 0); launcher->area.width = (2 * launcher->area.bg->border.width) + (2 * launcher->area.paddingxlr) + (icon_size * icons_per_row) + ((icons_per_row-1) * launcher->area.paddingx); } - -// launcher->area.posx = panel->area.bg->border.width + panel->area.paddingxlr; - launcher->area.posy = panel->area.bg->border.width; } else { if (!count) launcher->area.height = 0; @@ -236,9 +238,6 @@ int resize_launcher(void *obj) icons_per_column = count / icons_per_row+ (count%icons_per_row != 0); launcher->area.height = (2 * launcher->area.bg->border.width) + (2 * launcher->area.paddingxlr) + (icon_size * icons_per_column) + ((icons_per_column-1) * launcher->area.paddingx); } - - launcher->area.posx = panel->area.bg->border.width; -// launcher->area.posy = panel->area.height - panel->area.bg->border.width - panel->area.paddingxlr - launcher->area.height; } int i, posx, posy; diff --git a/src/util/area.c b/src/util/area.c index ce122a2..460abd9 100644 --- a/src/util/area.c +++ b/src/util/area.c @@ -68,13 +68,6 @@ * 'panel_items = SC' define a panel with just Systray and Clock. * So the tree 'Panel.Area' will have 2 childs (Systray and Clock). * - * 1) ok - * 2) ?? - * 3) ?? - * répartition entre niveau global et niveau local ?? - * size_by_content peut-il modifier redraw=1 en cas de changement ? ou est ce géré par chaque composant ? - * size_by_layout peut-il modifier redraw ? - * ************************************************************/ void rendering(void *obj)