Sort tasks on taskbar (disabled, work in progress) - issue 478
git-svn-id: http://tint2.googlecode.com/svn/trunk@740 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
This commit is contained in:
committed by
mrovi9000@gmail.com
parent
1a41159142
commit
5376e09963
@@ -63,7 +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);
|
||||
window_get_coordinates(win, &new_tsk.win_x, &new_tsk.win_y, &new_tsk.win_w, &new_tsk.win_h);
|
||||
|
||||
// allocate only one title and one icon
|
||||
// even with task_on_all_desktop and with task_on_all_panel
|
||||
@@ -92,6 +92,10 @@ Task *add_task (Window win)
|
||||
new_tsk2->area.parent = tskbar;
|
||||
new_tsk2->win = new_tsk.win;
|
||||
new_tsk2->desktop = new_tsk.desktop;
|
||||
new_tsk2->win_x = new_tsk.win_x;
|
||||
new_tsk2->win_y = new_tsk.win_y;
|
||||
new_tsk2->win_w = new_tsk.win_w;
|
||||
new_tsk2->win_h = new_tsk.win_h;
|
||||
new_tsk2->current_state = -1; // to update the current state later in set_task_state...
|
||||
if (new_tsk2->desktop == ALLDESKTOP && server.desktop != j) {
|
||||
// hide ALLDESKTOP task on non-current desktop
|
||||
@@ -116,7 +120,7 @@ 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);
|
||||
sort_taskbar_for_win(win);
|
||||
|
||||
if (panel_mode == MULTI_DESKTOP) {
|
||||
Panel *panel = new_tsk2->area.panel;
|
||||
|
||||
@@ -66,6 +66,8 @@ typedef struct {
|
||||
// These may not be up-to-date
|
||||
int win_x;
|
||||
int win_y;
|
||||
int win_w;
|
||||
int win_h;
|
||||
} Task;
|
||||
|
||||
|
||||
|
||||
@@ -412,6 +412,8 @@ void visible_taskbar(void *p)
|
||||
|
||||
gint compare_tasks(Task *a, Task *b, Taskbar *taskbar)
|
||||
{
|
||||
int a_horiz_c, a_vert_c, b_horiz_c, b_vert_c;
|
||||
|
||||
if (a == b)
|
||||
return 0;
|
||||
if (taskbarname_enabled) {
|
||||
@@ -420,10 +422,14 @@ gint compare_tasks(Task *a, Task *b, Taskbar *taskbar)
|
||||
if (b == taskbar->area.list->data)
|
||||
return 1;
|
||||
}
|
||||
if (a->win_x != b->win_x) {
|
||||
return a->win_x - b->win_x;
|
||||
a_horiz_c = a->win_x + a->win_w / 2;
|
||||
b_horiz_c = b->win_x + b->win_w / 2;
|
||||
a_vert_c = a->win_y + a->win_h / 2;
|
||||
b_vert_c = b->win_y + b->win_h / 2;
|
||||
if (a_horiz_c != b_horiz_c) {
|
||||
return a_horiz_c - b_horiz_c;
|
||||
}
|
||||
return a->win_y - b->win_y;
|
||||
return a_vert_c - b_vert_c;
|
||||
}
|
||||
|
||||
int taskbar_needs_sort(Taskbar *taskbar)
|
||||
@@ -455,3 +461,26 @@ void sort_tasks(Taskbar *taskbar)
|
||||
panel_refresh = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void sort_taskbar_for_win(Window win)
|
||||
{
|
||||
if (sort_tasks_method == TASKBAR_SORT_POSITION) {
|
||||
GPtrArray* task_group = task_get_tasks(win);
|
||||
if (task_group) {
|
||||
int i;
|
||||
Task* tsk0 = g_ptr_array_index(task_group, 0);
|
||||
if (tsk0) {
|
||||
window_get_coordinates(win, &tsk0->win_x, &tsk0->win_y, &tsk0->win_w, &tsk0->win_h);
|
||||
}
|
||||
for (i = 0; i < task_group->len; ++i) {
|
||||
Task* tsk = g_ptr_array_index(task_group, i);
|
||||
tsk->win_x = tsk0->win_x;
|
||||
tsk->win_y = tsk0->win_y;
|
||||
tsk->win_w = tsk0->win_w;
|
||||
tsk->win_h = tsk0->win_h;
|
||||
sort_tasks(tsk->area.parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,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_taskbar_for_win(Window win);
|
||||
void sort_tasks(Taskbar *taskbar);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user