cleanup code git-svn-id: http://tint2.googlecode.com/svn/trunk@562 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
@@ -237,6 +237,8 @@ battery->area.panel = p;
battery->area._draw_foreground = draw_battery; battery->area.size_mode = SIZE_BY_CONTENT; battery->area._resize = resize_battery; + battery->area.on_screen = 1; + battery->area.resize = 1; }
@@ -451,13 +451,14 @@ else if (strcmp (key, "taskbar_background_id") == 0) {
int id = atoi (value); id = (id < backgrounds->len && id >= 0) ? id : 0; panel_config.g_taskbar.bg = &g_array_index(backgrounds, Background, id); + if (panel_config.g_taskbar.bg_active == 0) + panel_config.g_taskbar.bg_active = panel_config.g_taskbar.bg; panel_config.g_taskbar.area.bg = panel_config.g_taskbar.bg; } else if (strcmp (key, "taskbar_active_background_id") == 0) { int id = atoi (value); id = (id < backgrounds->len && id >= 0) ? id : 0; panel_config.g_taskbar.bg_active = &g_array_index(backgrounds, Background, id); - panel_config.g_taskbar.use_active = 1; } /* Task */
@@ -219,9 +219,10 @@ }
if (panel_autohide) add_timeout(panel_autohide_hide_timeout, 0, autohide_hide, p); + + visible_taskbar(p); } - visible_object(); task_refresh_tasklist(); active_task(); }@@ -300,29 +301,6 @@ }
// printf("panel : posx %d, posy %d, width %d, height %d\n", panel->posx, panel->posy, panel->area.width, panel->area.height); } - -void visible_object() -{ - Panel *panel; - int i, j; - - for (i=0 ; i < nb_panel ; i++) { - panel = &panel1[i]; - - Taskbar *taskbar; - for (j=0 ; j < panel->nb_desktop ; j++) { - taskbar = &panel->taskbar[j]; - if (panel_mode != MULTI_DESKTOP && taskbar->desktop != server.desktop) { - // SINGLE_DESKTOP and not current desktop - taskbar->area.on_screen = 0; - } - else { - taskbar->area.on_screen = 1; - } - } - } - panel_refresh = 1; -} void update_strut(Panel* p) {
@@ -138,7 +138,6 @@ void init_panel_size_and_position(Panel *panel);
void set_panel_items_order(Panel *p); void set_panel_properties(Panel *p); -void visible_object(); // draw background panel void set_panel_background(Panel *p);
@@ -342,6 +342,7 @@ PangoLayout *layout;
Color *config_text; int width=0, height; Panel *panel = (Panel*)tsk->area.panel; + //printf("draw_task %d %d\n", tsk->area.posx, tsk->area.posy); if (panel->g_task.text) { /* Layout */
@@ -198,7 +198,7 @@ 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) + if (j == server.desktop) tskbar->area.bg = panel->g_taskbar.bg_active; } }@@ -266,9 +266,7 @@ Task *tsk;
GSList *l; int task_count, border_width; - //printf("resize_taskbar : posx et width des taches\n"); - taskbar->area.redraw = 1; - +// taskbar->area.redraw = 1; border_width = taskbar->area.bg->border.width; if (panel_horizontal) {@@ -297,7 +295,7 @@ // change pos_x and width for all tasks
for (l = taskbar->area.list; l ; l = l->next) { tsk = l->data; if (!tsk->area.on_screen) continue; - set_task_redraw(tsk); // always redraw task, because the background could have changed (taskbar_active_id) + //set_task_redraw(tsk); // always redraw task, because the background could have changed (taskbar_active_id) tsk->area.width = pixel_width; // TODO : move later (when posx is known) // long value[] = { panel->posx+x, panel->posy, pixel_width, panel->area.height };@@ -335,7 +333,7 @@ // change pos_y and height for all tasks
for (l = taskbar->area.list; l ; l = l->next) { tsk = l->data; if (!tsk->area.on_screen) continue; - set_task_redraw(tsk); // always redraw task, because the background could have changed (taskbar_active_id) + //set_task_redraw(tsk); // always redraw task, because the background could have changed (taskbar_active_id) tsk->area.height = pixel_height; // TODO : move later (when posy is known) // long value[] = { panel->posx, panel->posy+y, panel->area.width, pixel_height };@@ -347,6 +345,27 @@ modulo_height--;
} } } + return 0; } + +void visible_taskbar(void *p) +{ + Panel *panel =(Panel*)p; + int j; + + Taskbar *taskbar; + for (j=0 ; j < panel->nb_desktop ; j++) { + taskbar = &panel->taskbar[j]; + if (panel_mode != MULTI_DESKTOP && taskbar->desktop != server.desktop) { + // SINGLE_DESKTOP and not current desktop + taskbar->area.on_screen = 0; + } + else { + taskbar->area.on_screen = 1; + } + } + panel_refresh = 1; +} +
@@ -34,7 +34,6 @@ //always start with area
Area area; Background* bg; Background* bg_active; - int use_active; } Global_taskbar;@@ -53,6 +52,9 @@ GPtrArray* task_get_tasks(Window win);
void task_refresh_tasklist (); int resize_taskbar(void *obj); + +// show/hide taskbar according to current desktop +void visible_taskbar(void *p); #endif
@@ -494,9 +494,9 @@ init_taskbar();
for (i=0 ; i < nb_panel ; i++) { init_taskbar_panel(&panel1[i]); set_panel_items_order(&panel1[i]); + visible_taskbar(&panel1[i]); panel1[i].area.resize = 1; } - visible_object(); task_refresh_tasklist(); active_task(); panel_refresh = 1;@@ -508,7 +508,7 @@ int old_desktop = server.desktop;
server.desktop = server_get_current_desktop (); for (i=0 ; i < nb_panel ; i++) { Panel *panel = &panel1[i]; - if (panel_mode == MULTI_DESKTOP && panel->g_taskbar.use_active) { + if (panel_mode == MULTI_DESKTOP && panel->g_taskbar.bg != panel->g_taskbar.bg_active) { // redraw both taskbar if (server.nb_desktop > old_desktop) { // can happen if last desktop is deleted and we've been on the last desktop@@ -542,9 +542,8 @@ tsk->area.on_screen = 1;
tskbar->area.resize = 1; } } - } - if (panel_mode != MULTI_DESKTOP) { - visible_object(); + if (panel_mode != MULTI_DESKTOP) + visible_taskbar(panel); } } // Window list
@@ -220,7 +220,6 @@ {
Area *child, *a = (Area*)obj; int size, nb_by_content=0, nb_by_layout=0; - printf("resize_by_layout\n"); if (panel_horizontal) { // detect free size for SIZE_BY_LAYOUT's Area size = a->width - (2 * (a->paddingxlr + a->bg->border.width));
@@ -82,7 +82,8 @@ void *panel;
// each object can overwrite following function void (*_draw_foreground)(void *obj, cairo_t *c); - // calculate size. return '1' if size changed, '0' otherwise. + // update area's content and update size (width/heith). + // return '1' if size changed, '0' otherwise. int (*_resize)(void *obj); void (*_add_child)(void *obj); int (*_remove_child)(void *obj);