Tentative to sort tasks on taskbar (disabled) - issue 478
git-svn-id: http://tint2.googlecode.com/svn/trunk@738 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
This commit is contained in:
committed by
mrovi9000@gmail.com
parent
5faf063f96
commit
e113080a0e
@@ -63,6 +63,7 @@ Task *add_task (Window win)
|
||||
new_tsk.desktop = window_get_desktop (win);
|
||||
new_tsk.area.panel = &panel1[monitor];
|
||||
new_tsk.current_state = window_is_iconified(win) ? TASK_ICONIFIED : TASK_NORMAL;
|
||||
window_get_position(win, &new_tsk.win_x, &new_tsk.win_y);
|
||||
|
||||
// allocate only one title and one icon
|
||||
// even with task_on_all_desktop and with task_on_all_panel
|
||||
@@ -115,6 +116,8 @@ Task *add_task (Window win)
|
||||
g_hash_table_insert(win_to_task_table, key, task_group);
|
||||
set_task_state(new_tsk2, new_tsk.current_state);
|
||||
|
||||
sort_tasks(tskbar);
|
||||
|
||||
if (panel_mode == MULTI_DESKTOP) {
|
||||
Panel *panel = new_tsk2->area.panel;
|
||||
panel->area.resize = 1;
|
||||
|
||||
@@ -63,6 +63,9 @@ typedef struct {
|
||||
unsigned int icon_height;
|
||||
char *title;
|
||||
int urgent_tick;
|
||||
// These may not be up-to-date
|
||||
int win_x;
|
||||
int win_y;
|
||||
} Task;
|
||||
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ int taskbar_enabled;
|
||||
int taskbar_distribute_size;
|
||||
int hide_inactive_tasks;
|
||||
int hide_task_diff_monitor;
|
||||
int sort_tasks_method;
|
||||
|
||||
guint win_hash(gconstpointer key) { return (guint)*((Window*)key); }
|
||||
gboolean win_compare(gconstpointer a, gconstpointer b) { return (*((Window*)a) == *((Window*)b)); }
|
||||
@@ -60,6 +61,7 @@ void default_taskbar()
|
||||
taskbar_distribute_size = 0;
|
||||
hide_inactive_tasks = 0;
|
||||
hide_task_diff_monitor = 0;
|
||||
sort_tasks_method = TASKBAR_NOSORT;
|
||||
default_taskbarname();
|
||||
}
|
||||
|
||||
@@ -408,3 +410,48 @@ void visible_taskbar(void *p)
|
||||
panel_refresh = 1;
|
||||
}
|
||||
|
||||
gint compare_tasks(Task *a, Task *b, Taskbar *taskbar)
|
||||
{
|
||||
if (a == b)
|
||||
return 0;
|
||||
if (taskbarname_enabled) {
|
||||
if (a == taskbar->area.list->data)
|
||||
return -1;
|
||||
if (b == taskbar->area.list->data)
|
||||
return 1;
|
||||
}
|
||||
if (a->win_x != b->win_x) {
|
||||
return a->win_x - b->win_x;
|
||||
}
|
||||
return a->win_y - b->win_y;
|
||||
}
|
||||
|
||||
int taskbar_needs_sort(Taskbar *taskbar)
|
||||
{
|
||||
if (sort_tasks_method == TASKBAR_NOSORT)
|
||||
return 0;
|
||||
|
||||
if (sort_tasks_method == TASKBAR_SORT_POSITION) {
|
||||
GSList *i, *j;
|
||||
for (i = taskbar->area.list, j = i ? i->next : NULL; i && j; i = i->next, j = j->next) {
|
||||
if (compare_tasks(i->data, j->data, taskbar) > 0) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void sort_tasks(Taskbar *taskbar)
|
||||
{
|
||||
if (!taskbar)
|
||||
return;
|
||||
if (!taskbar_needs_sort(taskbar))
|
||||
return;
|
||||
if (sort_tasks_method == TASKBAR_SORT_POSITION) {
|
||||
taskbar->area.list = g_slist_sort_with_data(taskbar->area.list, (GCompareDataFunc)compare_tasks, taskbar);
|
||||
taskbar->area.resize = 1;
|
||||
panel_refresh = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@ extern int taskbar_enabled;
|
||||
extern int taskbar_distribute_size;
|
||||
extern int hide_inactive_tasks;
|
||||
extern int hide_task_diff_monitor;
|
||||
enum { TASKBAR_NOSORT, TASKBAR_SORT_POSITION };
|
||||
extern int sort_tasks_method;
|
||||
|
||||
typedef struct {
|
||||
// always start with area
|
||||
@@ -74,6 +76,7 @@ void set_taskbar_state(Taskbar *tskbar, int state);
|
||||
// show/hide taskbar according to current desktop
|
||||
void visible_taskbar(void *p);
|
||||
|
||||
void sort_tasks(Taskbar *taskbar);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user