]> Dogcows Code - chaz/tint2/blobdiff - src/taskbar/taskbar.c
*fix* better internal urgent task handling
[chaz/tint2] / src / taskbar / taskbar.c
index a1be3ec78236220ec049ec53f0ad2a4dd12df247..f7197c13cda0f2597c089c99a053bf5b8eefc1ed 100644 (file)
@@ -169,6 +169,25 @@ Task *task_get_task (Window win)
 }
 
 
+GSList* task_get_tasks(Window win)
+{
+       GSList* l = 0;
+       GSList* it;
+       Task* tsk;
+       int i, j;
+       for (i=0; i<nb_panel; ++i) {
+               for (j=0; j<panel1[i].nb_desktop; ++j) {
+                       for (it=panel1[i].taskbar[j].area.list; it; it=it->next) {
+                               tsk = it->data;
+                               if (win == tsk->win)
+                                       l = g_slist_prepend(l, tsk);
+                       }
+               }
+       }
+       return l;
+}
+
+
 void task_refresh_tasklist ()
 {
        Window *win, active_win;
@@ -180,11 +199,7 @@ void task_refresh_tasklist ()
        if (!win) return;
 
        // Remove any old and set active win
-       active_win = window_get_active ();
-       if (task_active) {
-               task_active->area.is_active = 0;
-               task_active = 0;
-       }
+       active_task();
 
        for (i=0 ; i < nb_panel ; i++) {
                for (j=0 ; j < panel1[i].nb_desktop ; j++) {
@@ -193,11 +208,6 @@ void task_refresh_tasklist ()
                                tsk = l0->data;
                                l0 = l0->next;
 
-                               if (tsk->win == active_win) {
-                                       tsk->area.is_active = 1;
-                                       task_active = tsk;
-                               }
-
                                for (k = 0; k < num_results; k++) {
                                        if (tsk->win == win[k]) break;
                                }
@@ -222,12 +232,16 @@ void resize_taskbar(void *obj)
        Panel *panel = (Panel*)taskbar->area.panel;
        Task *tsk;
        GSList *l;
-       int  task_count;
+       int  task_count, border_width;
 
        //printf("resize_taskbar : posx et width des taches\n");
-
        taskbar->area.redraw = 1;
 
+       if (taskbar->area.is_active && taskbar->area.use_active)
+               border_width = taskbar->area.pix_active.border.width;
+       else
+               border_width = taskbar->area.pix.border.width;
+
        if (panel_horizontal) {
                int  pixel_width, modulo_width=0;
                int  x, taskbar_width;
@@ -236,7 +250,7 @@ void resize_taskbar(void *obj)
                task_count = g_slist_length(taskbar->area.list);
                if (!task_count) pixel_width = panel->g_task.maximum_width;
                else {
-                       taskbar_width = taskbar->area.width - (2 * panel->g_taskbar.pix.border.width) - (2 * panel->g_taskbar.paddingxlr);
+                       taskbar_width = taskbar->area.width - (2 * border_width) - (2 * panel->g_taskbar.paddingxlr);
                        if (task_count>1) taskbar_width -= ((task_count-1) * panel->g_taskbar.paddingx);
 
                        pixel_width = taskbar_width / task_count;
@@ -246,21 +260,17 @@ void resize_taskbar(void *obj)
                                modulo_width = taskbar_width % task_count;
                }
 
-               if ((taskbar->task_width == pixel_width) && (taskbar->task_modulo == modulo_width)) {
-               }
-               else {
-                       taskbar->task_width = pixel_width;
-                       taskbar->task_modulo = modulo_width;
-                       taskbar->text_width = pixel_width - panel->g_task.text_posx - panel->g_task.area.pix.border.width - panel->g_task.area.paddingx;
-               }
+               taskbar->task_width = pixel_width;
+               taskbar->task_modulo = modulo_width;
+               taskbar->text_width = pixel_width - panel->g_task.text_posx - panel->g_task.area.pix.border.width - panel->g_task.area.paddingx;
 
                // change pos_x and width for all tasks
-               x = taskbar->area.posx + taskbar->area.pix.border.width + taskbar->area.paddingxlr;
+               x = taskbar->area.posx + border_width + taskbar->area.paddingxlr;
                for (l = taskbar->area.list; l ; l = l->next) {
                        tsk = l->data;
+                       if (!tsk->area.on_screen) continue;
                        tsk->area.posx = x;
                        tsk->area.width = pixel_width;
-                       tsk->area.redraw = 1;
                        if (modulo_width) {
                                tsk->area.width++;
                                modulo_width--;
@@ -277,7 +287,7 @@ void resize_taskbar(void *obj)
                task_count = g_slist_length(taskbar->area.list);
                if (!task_count) pixel_height = panel->g_task.maximum_height;
                else {
-                       taskbar_height = taskbar->area.height - (2 * panel->g_taskbar.pix.border.width) - (2 * panel->g_taskbar.paddingxlr);
+                       taskbar_height = taskbar->area.height - (2 * border_width) - (2 * panel->g_taskbar.paddingxlr);
                        if (task_count>1) taskbar_height -= ((task_count-1) * panel->g_taskbar.paddingx);
 
                        pixel_height = taskbar_height / task_count;
@@ -287,21 +297,17 @@ void resize_taskbar(void *obj)
                                modulo_height = taskbar_height % task_count;
                }
 
-               if ((taskbar->task_width == pixel_height) && (taskbar->task_modulo == modulo_height)) {
-               }
-               else {
-                       taskbar->task_width = pixel_height;
-                       taskbar->task_modulo = modulo_height;
-                       taskbar->text_width = taskbar->area.width - (2 * panel->g_taskbar.paddingy) - panel->g_task.text_posx - panel->g_task.area.pix.border.width - panel->g_task.area.paddingx;
-               }
+               taskbar->task_width = pixel_height;
+               taskbar->task_modulo = modulo_height;
+               taskbar->text_width = taskbar->area.width - (2 * panel->g_taskbar.paddingy) - panel->g_task.text_posx - panel->g_task.area.pix.border.width - panel->g_task.area.paddingx;
 
                // change pos_y and height for all tasks
-               y = taskbar->area.posy + taskbar->area.pix.border.width + taskbar->area.paddingxlr;
+               y = taskbar->area.posy + border_width + taskbar->area.paddingxlr;
                for (l = taskbar->area.list; l ; l = l->next) {
                        tsk = l->data;
+                       if (!tsk->area.on_screen) continue;
                        tsk->area.posy = y;
                        tsk->area.height = pixel_height;
-                       tsk->area.redraw = 1;
                        if (modulo_height) {
                                tsk->area.height++;
                                modulo_height--;
This page took 0.029659 seconds and 4 git commands to generate.