Taskbar: thumbnails (update every 1s for the active tooltip)
This commit is contained in:
@@ -55,6 +55,7 @@ cairo_surface_t *task_get_thumbnail(void *obj)
|
|||||||
Task *t = (Task *)obj;
|
Task *t = (Task *)obj;
|
||||||
if (!t->thumbnail)
|
if (!t->thumbnail)
|
||||||
task_refresh_thumbnail(t);
|
task_refresh_thumbnail(t);
|
||||||
|
taskbar_start_thumbnail_timer(THUMB_MODE_TOOLTIP_WINDOW);
|
||||||
return t->thumbnail;
|
return t->thumbnail;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -651,7 +652,11 @@ void set_task_state(Task *task, TaskState state)
|
|||||||
|
|
||||||
if (!task->thumbnail)
|
if (!task->thumbnail)
|
||||||
task_refresh_thumbnail(task);
|
task_refresh_thumbnail(task);
|
||||||
taskbar_start_thumbnail_timer(TRUE);
|
if (state == TASK_ACTIVE) {
|
||||||
|
// For active windows, we get the thumbnail twice with a small delay in between.
|
||||||
|
// This is because they sometimes redraw their windows slowly.
|
||||||
|
taskbar_start_thumbnail_timer(THUMB_MODE_ACTIVE_WINDOW);
|
||||||
|
}
|
||||||
|
|
||||||
if (state == TASK_ACTIVE && task->current_state != state) {
|
if (state == TASK_ACTIVE && task->current_state != state) {
|
||||||
clock_gettime(CLOCK_MONOTONIC, &task->last_activation_time);
|
clock_gettime(CLOCK_MONOTONIC, &task->last_activation_time);
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
#include "window.h"
|
#include "window.h"
|
||||||
#include "panel.h"
|
#include "panel.h"
|
||||||
#include "strnatcmp.h"
|
#include "strnatcmp.h"
|
||||||
|
#include "tooltip.h"
|
||||||
|
|
||||||
GHashTable *win_to_task;
|
GHashTable *win_to_task;
|
||||||
|
|
||||||
@@ -111,7 +112,10 @@ void taskbar_save_orderings()
|
|||||||
for (int j = 0; j < panel->num_desktops; j++) {
|
for (int j = 0; j < panel->num_desktops; j++) {
|
||||||
Taskbar *taskbar = &panel->taskbar[j];
|
Taskbar *taskbar = &panel->taskbar[j];
|
||||||
GList *task_order = NULL;
|
GList *task_order = NULL;
|
||||||
for (GList *c = (taskbar->area.children && taskbarname_enabled) ? taskbar->area.children->next : taskbar->area.children; c; c = c->next) {
|
for (GList *c = (taskbar->area.children && taskbarname_enabled) ? taskbar->area.children->next
|
||||||
|
: taskbar->area.children;
|
||||||
|
c;
|
||||||
|
c = c->next) {
|
||||||
Task *t = (Task *)c->data;
|
Task *t = (Task *)c->data;
|
||||||
Window *window = calloc(1, sizeof(Window));
|
Window *window = calloc(1, sizeof(Window));
|
||||||
*window = t->win;
|
*window = t->win;
|
||||||
@@ -306,7 +310,8 @@ void init_taskbar_panel(void *p)
|
|||||||
if (!panel->g_task.background[j])
|
if (!panel->g_task.background[j])
|
||||||
panel->g_task.background[j] = &g_array_index(backgrounds, Background, 0);
|
panel->g_task.background[j] = &g_array_index(backgrounds, Background, 0);
|
||||||
if (panel->g_task.background[j]->border.radius > panel->g_task.area.height / 2) {
|
if (panel->g_task.background[j]->border.radius > panel->g_task.area.height / 2) {
|
||||||
fprintf(stderr, "tint2: task%sbackground_id has a too large rounded value. Please fix your tint2rc\n",
|
fprintf(stderr,
|
||||||
|
"tint2: task%sbackground_id has a too large rounded value. Please fix your tint2rc\n",
|
||||||
j == 0 ? "_" : j == 1 ? "_active_" : j == 2 ? "_iconified_" : "_urgent_");
|
j == 0 ? "_" : j == 1 ? "_active_" : j == 2 ? "_iconified_" : "_urgent_");
|
||||||
g_array_append_val(backgrounds, *panel->g_task.background[j]);
|
g_array_append_val(backgrounds, *panel->g_task.background[j]);
|
||||||
panel->g_task.background[j] = &g_array_index(backgrounds, Background, backgrounds->len - 1);
|
panel->g_task.background[j] = &g_array_index(backgrounds, Background, backgrounds->len - 1);
|
||||||
@@ -358,14 +363,18 @@ void init_taskbar_panel(void *p)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
init_taskbarname_panel(panel);
|
init_taskbarname_panel(panel);
|
||||||
taskbar_start_thumbnail_timer(FALSE);
|
taskbar_start_thumbnail_timer(THUMB_MODE_ALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void taskbar_start_thumbnail_timer(gboolean fast)
|
void taskbar_start_thumbnail_timer(ThumbnailUpdateMode mode)
|
||||||
{
|
{
|
||||||
if (!panel_config.g_task.thumbnail_enabled)
|
if (!panel_config.g_task.thumbnail_enabled)
|
||||||
return;
|
return;
|
||||||
change_timeout(&thumbnail_update_timer, 500, 10 * 1000, taskbar_update_thumbnails, (void*)(long)fast);
|
change_timeout(&thumbnail_update_timer,
|
||||||
|
mode == THUMB_MODE_TOOLTIP_WINDOW ? 1000 : 500,
|
||||||
|
10 * 1000,
|
||||||
|
taskbar_update_thumbnails,
|
||||||
|
(void *)(long)mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void taskbar_init_fonts()
|
void taskbar_init_fonts()
|
||||||
@@ -793,24 +802,33 @@ void update_minimized_icon_positions(void *p)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void taskbar_update_thumbnails(void *fast)
|
void taskbar_update_thumbnails(void *arg)
|
||||||
{
|
{
|
||||||
if (!panel_config.g_task.thumbnail_enabled)
|
if (!panel_config.g_task.thumbnail_enabled)
|
||||||
return;
|
return;
|
||||||
|
ThumbnailUpdateMode mode = (ThumbnailUpdateMode)arg;
|
||||||
double start_time = get_time();
|
double start_time = get_time();
|
||||||
change_timeout(&thumbnail_update_timer, 10 * 1000, 10 * 1000, taskbar_update_thumbnails, NULL);
|
change_timeout(&thumbnail_update_timer, 10 * 1000, 10 * 1000, taskbar_update_thumbnails, NULL);
|
||||||
for (int i = 0; i < num_panels; i++) {
|
for (int i = 0; i < num_panels; i++) {
|
||||||
Panel *panel = &panels[i];
|
Panel *panel = &panels[i];
|
||||||
for (int j = 0; j < panel->num_desktops; j++) {
|
for (int j = 0; j < panel->num_desktops; j++) {
|
||||||
Taskbar *taskbar = &panel->taskbar[j];
|
Taskbar *taskbar = &panel->taskbar[j];
|
||||||
for (GList *c = (taskbar->area.children && taskbarname_enabled) ? taskbar->area.children->next : taskbar->area.children; c; c = c->next) {
|
for (GList *c = (taskbar->area.children && taskbarname_enabled) ? taskbar->area.children->next
|
||||||
|
: taskbar->area.children;
|
||||||
|
c;
|
||||||
|
c = c->next) {
|
||||||
Task *t = (Task *)c->data;
|
Task *t = (Task *)c->data;
|
||||||
if (!fast || t->current_state == TASK_ACTIVE)
|
if (mode == THUMB_MODE_ALL || (mode == THUMB_MODE_ACTIVE_WINDOW && t->current_state == TASK_ACTIVE) ||
|
||||||
|
(mode == THUMB_MODE_TOOLTIP_WINDOW && g_tooltip.mapped && g_tooltip.area == &t->area)) {
|
||||||
task_refresh_thumbnail(t);
|
task_refresh_thumbnail(t);
|
||||||
if (!fast) {
|
if (t->thumbnail && mode == THUMB_MODE_TOOLTIP_WINDOW) {
|
||||||
|
taskbar_start_thumbnail_timer(THUMB_MODE_TOOLTIP_WINDOW);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (mode == THUMB_MODE_ALL) {
|
||||||
double now = get_time();
|
double now = get_time();
|
||||||
if (now - start_time > 0.030) {
|
if (now - start_time > 0.030) {
|
||||||
change_timeout(&thumbnail_update_timer, 10, 10 * 1000, taskbar_update_thumbnails, fast);
|
change_timeout(&thumbnail_update_timer, 10, 10 * 1000, taskbar_update_thumbnails, arg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,12 @@ typedef enum TaskbarSortMethod {
|
|||||||
TASKBAR_SORT_MRU,
|
TASKBAR_SORT_MRU,
|
||||||
} TaskbarSortMethod;
|
} TaskbarSortMethod;
|
||||||
|
|
||||||
|
typedef enum ThumbnailUpdateMode {
|
||||||
|
THUMB_MODE_ACTIVE_WINDOW = 0,
|
||||||
|
THUMB_MODE_TOOLTIP_WINDOW,
|
||||||
|
THUMB_MODE_ALL
|
||||||
|
} ThumbnailUpdateMode;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
Area area;
|
Area area;
|
||||||
gchar *name;
|
gchar *name;
|
||||||
@@ -72,7 +78,7 @@ void init_taskbar_panel(void *p);
|
|||||||
|
|
||||||
gboolean resize_taskbar(void *obj);
|
gboolean resize_taskbar(void *obj);
|
||||||
void taskbar_default_font_changed();
|
void taskbar_default_font_changed();
|
||||||
void taskbar_start_thumbnail_timer(gboolean fast);
|
void taskbar_start_thumbnail_timer(ThumbnailUpdateMode mode);
|
||||||
|
|
||||||
// Reloads the entire list of tasks from the window manager and recreates the task buttons.
|
// Reloads the entire list of tasks from the window manager and recreates the task buttons.
|
||||||
void taskbar_refresh_tasklist();
|
void taskbar_refresh_tasklist();
|
||||||
|
|||||||
Reference in New Issue
Block a user