]> Dogcows Code - chaz/tint2/commitdiff
*fix* only redraw task on state change, if not already drawn
authorAndreas Fink <andreas.fink85@googlemail.com>
Sat, 9 Jan 2010 09:34:15 +0000 (09:34 +0000)
committerAndreas Fink <andreas.fink85@googlemail.com>
Sat, 9 Jan 2010 09:34:15 +0000 (09:34 +0000)
src/taskbar/task.c
src/taskbar/task.h
src/tint.c

index f69b995ecab21543fa9c45991bca8fa622ac57da..62c84832b3c7c8409a28dadd60cb7c473944e76f 100644 (file)
@@ -90,17 +90,19 @@ Task *add_task (Window win)
                        new_tsk2->area.parent = tskbar;
                        new_tsk2->win = new_tsk.win;
                        new_tsk2->desktop = new_tsk.desktop;
-                       set_task_state(new_tsk2, new_tsk.current_state);
                        if (new_tsk2->desktop == ALLDESKTOP && server.desktop != j) {
                                // hide ALLDESKTOP task on non-current desktop
                                new_tsk2->area.on_screen = 0;
                        }
                        new_tsk2->title = new_tsk.title;
                        new_tsk2->area._get_tooltip_text = task_get_tooltip;
-                       for (k=0; k<TASK_STATE_COUNT; ++k)
+                       for (k=0; k<TASK_STATE_COUNT; ++k) {
                                new_tsk2->icon[k] = new_tsk.icon[k];
+                               new_tsk2->state_pix[k] = 0;
+                       }
                        new_tsk2->icon_width = new_tsk.icon_width;
                        new_tsk2->icon_height = new_tsk.icon_height;
+                       set_task_state(new_tsk2, new_tsk.current_state);
                        tskbar->area.list = g_slist_append(tskbar->area.list, new_tsk2);
                        tskbar->area.resize = 1;
                        //printf("add_task panel %d, desktop %d, task %s\n", i, j, new_tsk2->title);
@@ -130,6 +132,7 @@ void remove_task (Task *tsk)
                        imlib_context_set_image(tsk->icon[k]);
                        imlib_free_image();
                        tsk->icon[k] = 0;
+                       if (tsk->state_pix[k]) XFreePixmap(server.dsp, tsk->state_pix[k]);
                }
        }
 
@@ -191,7 +194,7 @@ void get_title(Task *tsk)
        strcat(title, name);
        if (name) XFree (name);
 
-       tsk->area.redraw = 1;
+       set_task_redraw(tsk);
        if (tsk->title)
                free(tsk->title);
        tsk->title = title;
@@ -215,7 +218,7 @@ void get_icon (Task *tsk)
                        tsk->icon[k] = 0;
                }
        }
-       tsk->area.redraw = 1;
+       set_task_redraw(tsk);
 
        data = server_get_property (tsk->win, server.atom._NET_WM_ICON, XA_CARDINAL, &i);
        if (data) {
@@ -321,6 +324,7 @@ void draw_task_icon (Task *tsk, int text_width)
 void draw_task (void *obj, cairo_t *c)
 {
        Task *tsk = obj;
+       tsk->state_pix[tsk->current_state] = tsk->area.pix;
        PangoLayout *layout;
        Color *config_text;
        int width=0, height;
@@ -466,8 +470,24 @@ void active_task()
 
 void set_task_state(Task *tsk, int state)
 {
-       tsk->current_state = state;
-       tsk->area.bg = panel1[0].g_task.background[state];
+       if (tsk->current_state != state) {
+               tsk->current_state = state;
+               tsk->area.bg = panel1[0].g_task.background[state];
+               tsk->area.pix = tsk->state_pix[state];
+               if (tsk->state_pix[state] == 0)
+                       tsk->area.redraw = 1;
+               panel_refresh = 1;
+       }
+}
+
+
+void set_task_redraw(Task* tsk) {
+       int k;
+       for (k=0; k<TASK_STATE_COUNT; ++k) {
+               if (tsk->state_pix[k]) XFreePixmap(server.dsp, tsk->state_pix[k]);
+               tsk->state_pix[k] = 0;
+       }
+       tsk->area.pix = 0;
        tsk->area.redraw = 1;
 }
 
index 8564868095903006817766cda01b4617be763045..9e637588dc94d9da5cbd5c767b1978002ae2d1ff 100644 (file)
@@ -54,6 +54,7 @@ typedef struct {
        int  desktop;
        int current_state;
        Imlib_Image icon[TASK_STATE_COUNT];
+       Pixmap state_pix[TASK_STATE_COUNT];
        unsigned int icon_width;
        unsigned int icon_height;
        char *title;
@@ -70,6 +71,7 @@ void get_icon (Task *tsk);
 void get_title(Task *tsk);
 void active_task();
 void set_task_state(Task* tsk, int state);
+void set_task_redraw(Task* tsk);
 
 Task *next_task (Task *tsk);
 Task *prev_task (Task *tsk);
index d6f4f1a7de5ecc15d8bb87600d39a62e8a5040bc..7ea802060026b579f3899d0cae84716e257d4c88 100644 (file)
@@ -502,7 +502,7 @@ void event_property_notify (XEvent *e)
                                                tsk2 = l0->data;
                                                if (tsk->win == tsk2->win && tsk != tsk2) {
                                                        tsk2->title = tsk->title;
-                                                       tsk2->area.redraw = 1;
+                                                       set_task_redraw(tsk2);
                                                }
                                        }
                                }
@@ -521,7 +521,7 @@ void event_property_notify (XEvent *e)
                }
                else if (at == server.atom.WM_STATE) {
                        // Iconic state
-                       int state = task_active == tsk ? TASK_ACTIVE : TASK_NORMAL;
+                       int state = tsk->current_state;
                        if (window_is_iconified(win))
                                state = TASK_ICONIFIED;
                        GSList* task_list = task_get_tasks(win);
@@ -548,7 +548,7 @@ void event_property_notify (XEvent *e)
                                        int k=0;
                                        for ( ; k<TASK_STATE_COUNT; ++k)
                                                tsk2->icon[k] = tsk->icon[k];
-                                       tsk2->area.redraw = 1;
+                                       set_task_redraw(tsk2);
                                }
                                l0 = l0->next;
                        }
@@ -630,7 +630,7 @@ void event_configure_notify (Window win)
                        GSList* it = task_list;
                        while (it) {
                                Task *tsk = it->data;
-                               tsk->current_state = TASK_ACTIVE;
+                               set_task_state(tsk, TASK_ACTIVE);
                                task_active = tsk;
                                it = task_list->next;
                        }
This page took 0.025727 seconds and 4 git commands to generate.