From: Thierry Lorthiois Date: Sat, 23 Oct 2010 11:16:29 +0000 (+0000) Subject: memorized taskbar pixmap. So we don t redraw taskbar/task when switching desktop. X-Git-Url: https://git.dogcows.com/gitweb?a=commitdiff_plain;h=275fa7c8678c39a1c1f7437de12aac0144f61a85;p=chaz%2Ftint2 memorized taskbar pixmap. So we don t redraw taskbar/task when switching desktop. --- diff --git a/src/config.c b/src/config.c index 15813d7..d2b3414 100644 --- a/src/config.c +++ b/src/config.c @@ -454,15 +454,15 @@ void add_entry (char *key, char *value) 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; + panel_config.g_taskbar.background[TASKBAR_NORMAL] = &g_array_index(backgrounds, Background, id); + if (panel_config.g_taskbar.background[TASKBAR_ACTIVE] == 0) + panel_config.g_taskbar.background[TASKBAR_ACTIVE] = panel_config.g_taskbar.background[TASKBAR_NORMAL]; + //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.background[TASKBAR_ACTIVE] = &g_array_index(backgrounds, Background, id); } else if (strcmp (key, "taskbar_name") == 0) { taskbarname_enabled = atoi (value); diff --git a/src/panel.c b/src/panel.c index 900a317..3971bc8 100644 --- a/src/panel.c +++ b/src/panel.c @@ -530,11 +530,16 @@ void set_panel_background(Panel *p) set_redraw(a); } - // reset task 'state_pix' - int i; + // reset task/taskbar 'state_pix' + int i, k; Taskbar *tskbar; for (i=0 ; i < p->nb_desktop ; i++) { tskbar = &p->taskbar[i]; + for (k=0; kstate_pix[k]) XFreePixmap(server.dsp, tskbar->state_pix[k]); + tskbar->state_pix[k] = 0; + } + tskbar->area.pix = 0; for (l0 = tskbar->area.list; l0 ; l0 = l0->next) { set_task_redraw((Task *)l0->data); } diff --git a/src/taskbar/taskbar.c b/src/taskbar/taskbar.c index 6605b5b..89267f6 100644 --- a/src/taskbar/taskbar.c +++ b/src/taskbar/taskbar.c @@ -99,18 +99,17 @@ 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.background[TASKBAR_NORMAL] == 0) { + panel->g_taskbar.background[TASKBAR_NORMAL] = &g_array_index(backgrounds, Background, 0); + panel->g_taskbar.background[TASKBAR_ACTIVE] = &g_array_index(backgrounds, Background, 0); } - 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._draw_foreground = draw_taskbar; panel->g_taskbar.area.redraw = 1; panel->g_taskbar.area.on_screen = 1; if (panel_horizontal) { @@ -158,11 +157,11 @@ void init_taskbar_panel(void *p) if ((panel->g_task.config_background_mask & (1<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.posy = panel->g_taskbar.area.posy + panel->g_taskbar.background[TASKBAR_NORMAL]->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.posx = panel->g_taskbar.area.posx + panel->g_taskbar.background[TASKBAR_NORMAL]->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; } @@ -200,7 +199,9 @@ void init_taskbar_panel(void *p) memcpy(&tskbar->area, &panel->g_taskbar, sizeof(Area)); tskbar->desktop = j; if (j == server.desktop) - tskbar->area.bg = panel->g_taskbar.bg_active; + tskbar->area.bg = panel->g_taskbar.background[TASKBAR_ACTIVE]; + else + tskbar->area.bg = panel->g_taskbar.background[TASKBAR_NORMAL]; } } @@ -259,6 +260,15 @@ void task_refresh_tasklist () } +void draw_taskbar (void *obj, cairo_t *c) +{ + Taskbar *taskbar = obj; + int state = (taskbar->desktop == server.desktop) ? TASKBAR_ACTIVE : TASKBAR_NORMAL; + + taskbar->state_pix[state] = taskbar->area.pix; +} + + int resize_taskbar(void *obj) { Taskbar *taskbar = (Taskbar*)obj; @@ -286,6 +296,20 @@ int resize_taskbar(void *obj) } +void set_taskbar_state(Taskbar *tskbar, int state) +{ + tskbar->area.bg = panel1[0].g_taskbar.background[state]; + tskbar->area.pix = tskbar->state_pix[state]; + if (tskbar->state_pix[state] == 0) { + tskbar->area.redraw = 1; + GSList *l; + for (l = tskbar->area.list ; l ; l = l->next) + ((Area*)l->data)->redraw = 1; + } + panel_refresh = 1; +} + + void visible_taskbar(void *p) { Panel *panel =(Panel*)p; diff --git a/src/taskbar/taskbar.h b/src/taskbar/taskbar.h index 17a56af..72f0cca 100644 --- a/src/taskbar/taskbar.h +++ b/src/taskbar/taskbar.h @@ -10,6 +10,7 @@ #include "task.h" +enum { TASKBAR_NORMAL, TASKBAR_ACTIVE, TASKBAR_STATE_COUNT }; extern GHashTable* win_to_task_table; extern Task *task_active; extern Task *task_drag; @@ -21,6 +22,8 @@ typedef struct { Area area; int desktop; + int current_state; + Pixmap state_pix[TASKBAR_STATE_COUNT]; // task parameters int text_width; @@ -30,8 +33,9 @@ typedef struct { typedef struct { //always start with area Area area; - Background* bg; - Background* bg_active; + Background* background[TASKBAR_STATE_COUNT]; + //Background* bg; + //Background* bg_active; } Global_taskbar; @@ -44,12 +48,14 @@ void cleanup_taskbar(); void init_taskbar(); void init_taskbar_panel(void *p); +void draw_taskbar (void *obj, cairo_t *c); 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 (); int resize_taskbar(void *obj); +void set_taskbar_state(Taskbar *tskbar, int state); // show/hide taskbar according to current desktop void visible_taskbar(void *p); diff --git a/src/tint.c b/src/tint.c index 529e3cd..b975fec 100644 --- a/src/tint.c +++ b/src/tint.c @@ -513,17 +513,8 @@ void event_property_notify (XEvent *e) 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.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 - panel->taskbar[old_desktop].area.bg = panel->g_taskbar.bg; - panel->taskbar[old_desktop].area.resize = 1; - } - panel->taskbar[server.desktop].area.bg = panel->g_taskbar.bg_active; - panel->taskbar[server.desktop].area.resize = 1; - panel_refresh = 1; - } + set_taskbar_state(&panel->taskbar[old_desktop], TASKBAR_NORMAL); + set_taskbar_state(&panel->taskbar[server.desktop], TASKBAR_ACTIVE); // check ALLDESKTOP task => resize taskbar Taskbar *tskbar; Task *tsk;