]> Dogcows Code - chaz/tint2/blobdiff - src/taskbar/task.c
cleanup : remove unneeded title change
[chaz/tint2] / src / taskbar / task.c
index 06fdb84f0013b690c9d8d5fe71e4a4a97e9fa0ab..bdc0fde7b649c12e0333be2e801a63b63c7141c1 100644 (file)
@@ -159,12 +159,12 @@ void remove_task (Task *tsk)
 }
 
 
-void get_title(Task *tsk)
+int get_title(Task *tsk)
 {
        Panel *panel = tsk->area.panel;
        char *title, *name;
 
-       if (!panel->g_task.text && !g_tooltip.enabled) return;
+       if (!panel->g_task.text && !g_tooltip.enabled) return 0;
 
        name = server_get_property (tsk->win, server.atom._NET_WM_VISIBLE_NAME, server.atom.UTF8_STRING, 0);
        if (!name || !strlen(name)) {
@@ -184,9 +184,16 @@ void get_title(Task *tsk)
        else title[0] = 0;
        strcat(title, name);
        if (name) XFree (name);
-
-       if (tsk->title)
-               free(tsk->title);
+       
+       if (tsk->title) {
+               // check unecessary title change
+               if (strcmp(tsk->title, title) == 0) {
+                       free(title);
+                       return 0;
+               }
+               else
+                       free(tsk->title);
+       } 
 
        tsk->title = title;
        GPtrArray* task_group = task_get_tasks(tsk->win);
@@ -198,7 +205,7 @@ void get_title(Task *tsk)
                        set_task_redraw(tsk2);
                }
        }
-       set_task_redraw(tsk);
+       return 1;
 }
 
 
@@ -209,7 +216,7 @@ void get_icon (Task *tsk)
        int i;
        Imlib_Image img = NULL;
        XWMHints *hints = 0;
-       int32_t *data = 0;
+       gulong *data = 0;
 
        int k;
        for (k=0; k<TASK_STATE_COUNT; ++k) {
@@ -224,10 +231,9 @@ void get_icon (Task *tsk)
        if (data) {
                // get ARGB icon
                int w, h;
-               int32_t *tmp_data;
+               gulong *tmp_data;
 
                tmp_data = get_best_icon (data, get_icon_count (data, i), i, &w, &h, panel->g_task.icon_size1);
-
 #ifdef __x86_64__
                DATA32 icon_data[w * h];
                int length = w * h;
@@ -304,7 +310,6 @@ void get_icon (Task *tsk)
                        set_task_redraw(tsk2);
                }
        }
-       set_task_redraw(tsk);
 }
 
 
@@ -343,6 +348,7 @@ void draw_task (void *obj, cairo_t *c)
        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 */
@@ -386,6 +392,19 @@ void draw_task (void *obj, cairo_t *c)
 }
 
 
+void on_change_task (void *obj)
+{
+       Task *tsk = obj;
+       Panel *panel = (Panel*)tsk->area.panel;
+
+       long value[] = { panel->posx+tsk->area.posx, panel->posy+tsk->area.posy, tsk->area.width, tsk->area.height };
+       XChangeProperty (server.dsp, tsk->win, server.atom._NET_WM_ICON_GEOMETRY, XA_CARDINAL, 32, PropModeReplace, (unsigned char*)value, 4);
+       
+       // reset Pixmap when position/size changed
+       set_task_redraw(tsk);
+}
+
+
 Task *next_task(Task *tsk)
 {
        if (tsk == 0)
@@ -444,9 +463,11 @@ void active_task()
        //printf("Change active task %ld\n", w1);
 
        if (w1) {
-               Window w2;
-               if (XGetTransientForHint(server.dsp, w1, &w2) != 0)
-                       if (w2 && !task_get_tasks(w1)) w1 = w2;
+               if (!task_get_tasks(w1)) {
+                       Window w2;
+                       while (XGetTransientForHint(server.dsp, w1, &w2))
+                               w1 = w2;
+               }
                set_task_state((task_active = task_get_task(w1)), TASK_ACTIVE);
        }
 }
This page took 0.023251 seconds and 4 git commands to generate.