]> Dogcows Code - chaz/tint2/commitdiff
memorized taskbar pixmap. So we don t redraw taskbar/task when switching desktop.
authorThierry Lorthiois <lorthiois@bbsoft.fr>
Sat, 23 Oct 2010 11:16:29 +0000 (11:16 +0000)
committerThierry Lorthiois <lorthiois@bbsoft.fr>
Sat, 23 Oct 2010 11:16:29 +0000 (11:16 +0000)
src/config.c
src/panel.c
src/taskbar/taskbar.c
src/taskbar/taskbar.h
src/tint.c

index 15813d75b996dbca18a92e1bac879455c9a78109..d2b341481e6ca9a6c1fa90772dc9c3f3b82a7bbf 100644 (file)
@@ -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);
index 900a317004c75445206752a15561ab83f3d21a10..3971bc8021564bd182f5ddea39db7eb9c85dc06c 100644 (file)
@@ -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; k<TASKBAR_STATE_COUNT; ++k) {
+                       if (tskbar->state_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);
                }
index 6605b5befcaf93dadeb45799489f0faad4eb6173..89267f6e591fcc55d5cccfc39f37ac8fae0ee519 100644 (file)
@@ -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<<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.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;
index 17a56af139fe9af28cb3c87798dafcc96ab393e0..72f0cca5134f76f179c216693b774fb2bfc2d45c 100644 (file)
@@ -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);
index 529e3cda0119a3d18bdaa829084bd10aeebcfeed..b975fecf50a987dde7dc7af203efd3b806aaa630 100644 (file)
@@ -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;
This page took 0.033478 seconds and 4 git commands to generate.