*add* multiple tasks can be urgent now

git-svn-id: http://tint2.googlecode.com/svn/trunk@264 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
This commit is contained in:
Andreas.Fink85
2009-11-11 20:09:34 +00:00
parent 9f4e539f0b
commit e966c20f75
5 changed files with 71 additions and 18 deletions

View File

@@ -52,8 +52,7 @@ int panel_refresh;
Task *task_active; Task *task_active;
Task *task_drag; Task *task_drag;
Task *task_urgent; GSList *urgent_list;
int tick_urgent;
int max_tick_urgent; int max_tick_urgent;
// panel's initial config // panel's initial config
@@ -239,7 +238,7 @@ void cleanup_panel()
task_active = 0; task_active = 0;
task_drag = 0; task_drag = 0;
task_urgent = 0; urgent_list = 0;
cleanup_taskbar(); cleanup_taskbar();
int i; int i;

View File

@@ -50,7 +50,7 @@ extern int panel_refresh;
extern Task *task_active; extern Task *task_active;
extern Task *task_drag; extern Task *task_drag;
extern Task *task_urgent; extern GSList *urgent_list;
extern int tick_urgent; extern int tick_urgent;
extern int max_tick_urgent; extern int max_tick_urgent;

View File

@@ -391,9 +391,8 @@ void active_task()
if (XGetTransientForHint(server.dsp, w1, &w2) != 0) if (XGetTransientForHint(server.dsp, w1, &w2) != 0)
if (w2) tsk2 = task_get_task(w2); if (w2) tsk2 = task_get_task(w2);
} }
if (task_urgent == tsk2) { if ( is_urgent(tsk2) ) {
init_precision(); del_urgent(tsk2);
task_urgent = 0;
} }
// put active state on all task (multi_desktop) // put active state on all task (multi_desktop)
if (tsk2) { 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;
}

View File

@@ -70,5 +70,9 @@ void get_icon (Task *tsk);
void get_title(Task *tsk); void get_title(Task *tsk);
void active_task(); void active_task();
void add_urgent(Task *tsk);
void del_urgent(Task *tsk);
int is_urgent(Task *tsk);
#endif #endif

View File

@@ -519,9 +519,7 @@ void event_property_notify (XEvent *e)
// Demand attention // Demand attention
else if (at == server.atom._NET_WM_STATE) { else if (at == server.atom._NET_WM_STATE) {
if (window_is_urgent (win)) { if (window_is_urgent (win)) {
task_urgent = tsk; add_urgent(tsk);
tick_urgent = 0;
time_precision = 1;
} }
if (window_is_skip_taskbar(win)) { if (window_is_skip_taskbar(win)) {
remove_task( tsk ); remove_task( tsk );
@@ -592,9 +590,7 @@ void event_property_notify (XEvent *e)
else if (at == server.atom.WM_HINTS) { else if (at == server.atom.WM_HINTS) {
XWMHints* wmhints = XGetWMHints(server.dsp, win); XWMHints* wmhints = XGetWMHints(server.dsp, win);
if (wmhints && wmhints->flags & XUrgencyHint) { if (wmhints && wmhints->flags & XUrgencyHint) {
task_urgent = tsk; add_urgent(tsk);
tick_urgent = 0;
time_precision = 1;
} }
XFree(wmhints); XFree(wmhints);
} }
@@ -674,12 +670,15 @@ void event_timer()
time_clock.tv_sec -= time_clock.tv_sec % time_precision; time_clock.tv_sec -= time_clock.tv_sec % time_precision;
// urgent task // urgent task
if (task_urgent) { GSList* urgent_task = urgent_list;
if (tick_urgent < max_tick_urgent) { while (urgent_task) {
task_urgent->area.is_active = !task_urgent->area.is_active; Task_urgent* t = urgent_task->data;
task_urgent->area.redraw = 1; if ( t->tick < max_tick_urgent) {
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 // update battery