]> Dogcows Code - chaz/tint2/commitdiff
*add* multiple tasks can be urgent now
authorAndreas Fink <andreas.fink85@googlemail.com>
Wed, 11 Nov 2009 20:09:34 +0000 (20:09 +0000)
committerAndreas Fink <andreas.fink85@googlemail.com>
Wed, 11 Nov 2009 20:09:34 +0000 (20:09 +0000)
src/panel.c
src/panel.h
src/taskbar/task.c
src/taskbar/task.h
src/tint.c

index 3151be234ed688d363fb51b43d9a88c0f5b7fc11..a84bd763fc5f9cd1c887507aa23838608b9f0793 100644 (file)
@@ -52,8 +52,7 @@ int panel_refresh;
 
 Task *task_active;
 Task *task_drag;
-Task *task_urgent;
-int  tick_urgent;
+GSList *urgent_list;
 int  max_tick_urgent;
 
 // panel's initial config
@@ -239,7 +238,7 @@ void cleanup_panel()
 
        task_active = 0;
        task_drag = 0;
-       task_urgent = 0;
+       urgent_list = 0;
        cleanup_taskbar();
 
        int i;
index 6f762321fbcb3c315130740854183a2368572f2d..30faf5faf11f83c12314a2f36d91c7c4cc9c045c 100644 (file)
@@ -50,7 +50,7 @@ extern int panel_refresh;
 
 extern Task *task_active;
 extern Task *task_drag;
-extern Task *task_urgent;
+extern GSList *urgent_list;
 extern int  tick_urgent;
 extern int  max_tick_urgent;
 
index 0586854d3a07c34e4d2c3e4b19e9940ce99f7217..07db3723068ad0ee6f9d25ea4335fc0f3da8e61c 100644 (file)
@@ -391,9 +391,8 @@ void active_task()
                if (XGetTransientForHint(server.dsp, w1, &w2) != 0)
                        if (w2) tsk2 = task_get_task(w2);
        }
-       if (task_urgent == tsk2) {
-               init_precision();
-               task_urgent = 0;
+       if ( is_urgent(tsk2) ) {
+               del_urgent(tsk2);
        }
        // put active state on all task (multi_desktop)
        if (tsk2) {
@@ -411,3 +410,55 @@ void active_task()
        }
 }
 
+
+void add_urgent(Task *tsk)
+{
+       // first check if task is already in the list and reset the counter
+       GSList* urgent_task = urgent_list;
+       while (urgent_task) {
+               Task_urgent* t = urgent_task->data;
+               if (t->tsk == tsk) {
+                       t->tick = 0;
+                       return;
+               }
+               urgent_task = urgent_task->next;
+       }
+
+       // not yet in the list, so we have to add it
+       Task_urgent* t = malloc(sizeof(Task_urgent));
+       if (!t)
+               return;
+       t->tsk = tsk;
+       t->tick = 0;
+       urgent_list = g_slist_prepend(urgent_list, t);
+       time_precision = 1;
+}
+
+
+void del_urgent(Task *tsk)
+{
+       GSList* urgent_task = urgent_list;
+       while (urgent_task) {
+               Task_urgent* t = urgent_task->data;
+               if (t->tsk == tsk) {
+                       urgent_list = g_slist_remove(urgent_list, t);
+                       free(t);
+                       if (!urgent_list)
+                               init_precision();
+                       return;
+               }
+               urgent_task = urgent_task->next;
+       }
+}
+
+int is_urgent(Task *tsk)
+{
+       GSList* urgent_task = urgent_list;
+       while (urgent_task) {
+               Task_urgent* t = urgent_task->data;
+               if (t->tsk == tsk)
+                       return 1;
+               urgent_task = urgent_task->next;
+       }
+       return 0;
+}
index 492c425ebe1fda38ae608ad6cc85bccc8d856d33..994870e40a2e0c56051e617fcb0dbb6efb4d02db 100644 (file)
@@ -70,5 +70,9 @@ void get_icon (Task *tsk);
 void get_title(Task *tsk);
 void active_task();
 
+void add_urgent(Task *tsk);
+void del_urgent(Task *tsk);
+int is_urgent(Task *tsk);
+
 #endif
 
index d33ea3854ef47f9cbf613b061779bfb501aeea2c..192fa36d01f139a8c03db3441f3cc58852b91bbb 100644 (file)
@@ -519,9 +519,7 @@ void event_property_notify (XEvent *e)
                // Demand attention
                else if (at == server.atom._NET_WM_STATE) {
                        if (window_is_urgent (win)) {
-                               task_urgent = tsk;
-                               tick_urgent = 0;
-                               time_precision = 1;
+                               add_urgent(tsk);
                        }
                        if (window_is_skip_taskbar(win)) {
                                remove_task( tsk );
@@ -592,9 +590,7 @@ void event_property_notify (XEvent *e)
                else if (at == server.atom.WM_HINTS) {
                        XWMHints* wmhints = XGetWMHints(server.dsp, win);
                        if (wmhints && wmhints->flags & XUrgencyHint) {
-                               task_urgent = tsk;
-                               tick_urgent = 0;
-                               time_precision = 1;
+                               add_urgent(tsk);
                        }
                        XFree(wmhints);
                }
@@ -674,12 +670,15 @@ void event_timer()
        time_clock.tv_sec -= time_clock.tv_sec % time_precision;
 
        // urgent task
-       if (task_urgent) {
-               if (tick_urgent < max_tick_urgent) {
-                       task_urgent->area.is_active = !task_urgent->area.is_active;
-                       task_urgent->area.redraw = 1;
-                       tick_urgent++;
+       GSList* urgent_task = urgent_list;
+       while (urgent_task) {
+               Task_urgent* t = urgent_task->data;
+               if ( t->tick < max_tick_urgent) {
+                       t->tsk->area.is_active = !t->tsk->area.is_active;
+                       t->tsk->area.redraw = 1;
+                       t->tick++;
                }
+               urgent_task = urgent_task->next;
        }
 
        // update battery
This page took 0.032428 seconds and 4 git commands to generate.