New config option: taskbar sort by LRU/MRU (no config GUI yet) (issue #532)
o9000 mrovi9000@gmail.com
6 files changed,
26 insertions(+),
0 deletions(-)
M
ChangeLog
→
ChangeLog
@@ -2,6 +2,7 @@ 2015-12-05 master
- Enhancements: - Support for NETWM viewports (as in Compiz) (issue #94) - New plugin: executor + - New taskbar sort order: least-recently-used (lru), most-recently-used (mru) 2015-11-12 0.12.3 - Enhancements: - Battery: Multiple batteries are now supported under Linux (issue #139;
M
src/config.c
→
src/config.c
@@ -749,6 +749,10 @@ if (strcmp(value, "center") == 0) {
taskbar_sort_method = TASKBAR_SORT_CENTER; } else if (strcmp(value, "title") == 0) { taskbar_sort_method = TASKBAR_SORT_TITLE; + } else if (strcmp(value, "lru") == 0) { + taskbar_sort_method = TASKBAR_SORT_LRU; + } else if (strcmp(value, "mru") == 0) { + taskbar_sort_method = TASKBAR_SORT_MRU; } else { taskbar_sort_method = TASKBAR_NOSORT; }
M
src/taskbar/task.c
→
src/taskbar/task.c
@@ -552,6 +552,20 @@ {
if (!task || state < 0 || state >= TASK_STATE_COUNT) return; + if (state == TASK_ACTIVE && task->current_state != state) { + clock_gettime(CLOCK_MONOTONIC, &task->last_activation_time); + if (taskbar_sort_method == TASKBAR_SORT_LRU || taskbar_sort_method == TASKBAR_SORT_MRU) { + GPtrArray *task_group = task_get_tasks(task->win); + if (task_group) { + for (int i = 0; i < task_group->len; ++i) { + Task *task1 = g_ptr_array_index(task_group, i); + Taskbar *taskbar = (Taskbar *)task1->area.parent; + sort_tasks(taskbar); + } + } + } + } + if (task->current_state != state || hide_task_diff_monitor) { GPtrArray *task_group = task_get_tasks(task->win); if (task_group) {
M
src/taskbar/task.h
→
src/taskbar/task.h
@@ -74,6 +74,7 @@ int win_x;
int win_y; int win_w; int win_h; + struct timespec last_activation_time; } Task; Task *add_task(Window win);
M
src/taskbar/taskbar.c
→
src/taskbar/taskbar.c
@@ -522,6 +522,10 @@ } else if (taskbar_sort_method == TASKBAR_SORT_CENTER) {
return compare_task_centers(a, b, taskbar); } else if (taskbar_sort_method == TASKBAR_SORT_TITLE) { return compare_task_titles(a, b, taskbar); + } else if (taskbar_sort_method == TASKBAR_SORT_LRU) { + return compare_timespecs(&a->last_activation_time, &b->last_activation_time); + } else if (taskbar_sort_method == TASKBAR_SORT_MRU) { + return -compare_timespecs(&a->last_activation_time, &b->last_activation_time); } return 0; }
M
src/taskbar/taskbar.h
→
src/taskbar/taskbar.h
@@ -21,6 +21,8 @@ typedef enum TaskbarSortMethod {
TASKBAR_NOSORT = 0, TASKBAR_SORT_CENTER, TASKBAR_SORT_TITLE, + TASKBAR_SORT_LRU, + TASKBAR_SORT_MRU, } TaskbarSortMethod; extern GHashTable *win_to_task;