Taskbar: thumbnails (config, tint2conf and doc)

This commit is contained in:
o9000 2017-11-14 17:09:04 +01:00
parent e5ecc0c15d
commit 87da8c76cc
13 changed files with 74 additions and 8 deletions

View file

@ -481,6 +481,8 @@ panel_size = 94% 30
<li><p><code>task_text = boolean (0 or 1)</code> : Whether to display the task text.</p></li>
<li><p><code>task_centered = boolean (0 or 1)</code> : Whether the task text is centered.</p></li>
<li><p><code>task_tooltip = boolean (0 or 1)</code> : Whether to show tooltips for tasks.</p></li>
<li><p><code>task_thumbnail = boolean (0 or 1)</code> : Whether to show thumbnail tooltips for tasks.</p></li>
<li><p><code>task_thumbnail_size = width</code> : Thumbnail size.</p></li>
<li><p><code>task_maximum_size = width height</code></p>
<ul>
<li><code>width</code> is used with horizontal panels to limit the size of the tasks. Use <code>width = 0</code> to get full taskbar width.</li>

View file

@ -508,6 +508,10 @@ The following options configure the task buttons in the taskbar:
.IP \(bu 2
\fB\fCtask_tooltip = boolean (0 or 1)\fR : Whether to show tooltips for tasks.
.IP \(bu 2
\fB\fCtask_thumbnail = boolean (0 or 1)\fR : Whether to show thumbnail tooltips for tasks.
.IP \(bu 2
\fB\fCtask_thumbnail_size = width\fR : Thumbnail size.
.IP \(bu 2
\fB\fCtask_maximum_size = width height\fR
.RS
.IP \(bu 2

View file

@ -409,6 +409,10 @@ The following options configure the task buttons in the taskbar:
* `task_tooltip = boolean (0 or 1)` : Whether to show tooltips for tasks.
* `task_thumbnail = boolean (0 or 1)` : Whether to show thumbnail tooltips for tasks.
* `task_thumbnail_size = width` : Thumbnail size.
* `task_maximum_size = width height`
* `width` is used with horizontal panels to limit the size of the tasks. Use `width = 0` to get full taskbar width.
* `height` is used with vertical panels.

View file

@ -1091,6 +1091,10 @@ void add_entry(char *key, char *value)
// "tooltip" is deprecated but here for backwards compatibility
else if (strcmp(key, "task_tooltip") == 0 || strcmp(key, "tooltip") == 0)
panel_config.g_task.tooltip_enabled = atoi(value);
else if (strcmp(key, "task_thumbnail") == 0)
panel_config.g_task.thumbnail_enabled = atoi(value);
else if (strcmp(key, "task_thumbnail_size") == 0)
panel_config.g_task.thumbnail_width = MAX(8, atoi(value));
/* Systray */
else if (strcmp(key, "systray_padding") == 0) {

View file

@ -50,6 +50,8 @@ char *task_get_tooltip(void *obj)
cairo_surface_t *task_get_thumbnail(void *obj)
{
if (!panel_config.g_task.thumbnail_enabled)
return NULL;
Task *t = (Task *)obj;
if (!t->thumbnail)
task_refresh_thumbnail(t);
@ -620,12 +622,14 @@ void reset_active_task()
void task_refresh_thumbnail(Task *task)
{
if (!panel_config.g_task.thumbnail_enabled)
return;
if (task->current_state == TASK_ICONIFIED)
return;
double now = get_time();
if (now - task->thumbnail_last_update < 0.1)
return;
cairo_surface_t *thumbnail = get_window_thumbnail(task->win);
cairo_surface_t *thumbnail = get_window_thumbnail(task->win, panel_config.g_task.thumbnail_width);
if (!thumbnail)
return;
if (task->thumbnail)

View file

@ -46,6 +46,8 @@ typedef struct GlobalTask {
Color font[TASK_STATE_COUNT];
int config_font_mask;
gboolean tooltip_enabled;
gboolean thumbnail_enabled;
int thumbnail_width;
} GlobalTask;
// Stores information about a task.

View file

@ -46,7 +46,7 @@ gboolean hide_taskbar_if_empty;
gboolean always_show_all_desktop_tasks;
TaskbarSortMethod taskbar_sort_method;
Alignment taskbar_alignment;
static timeout *thumbnail_update_timer = NULL;
static timeout *thumbnail_update_timer;
static GList *taskbar_task_orderings = NULL;
@ -85,6 +85,7 @@ void default_taskbar()
hide_task_diff_monitor = FALSE;
hide_taskbar_if_empty = FALSE;
always_show_all_desktop_tasks = FALSE;
thumbnail_update_timer = NULL;
taskbar_sort_method = TASKBAR_NOSORT;
taskbar_alignment = ALIGN_LEFT;
default_taskbarname();
@ -362,6 +363,8 @@ void init_taskbar_panel(void *p)
void taskbar_start_thumbnail_timer()
{
if (!panel_config.g_task.thumbnail_enabled)
return;
change_timeout(&thumbnail_update_timer, 100, 10 * 1000, taskbar_update_thumbnails, NULL);
}
@ -792,6 +795,8 @@ void update_minimized_icon_positions(void *p)
void taskbar_update_thumbnails(void *arg)
{
if (!panel_config.g_task.thumbnail_enabled)
return;
for (int i = 0; i < num_panels; i++) {
Panel *panel = &panels[i];
for (int j = 0; j < panel->num_desktops; j++) {

View file

@ -97,7 +97,7 @@ GtkWidget *systray_background, *systray_monitor, *systray_name_filter;
// tooltip
GtkWidget *tooltip_padding_x, *tooltip_padding_y, *tooltip_font, *tooltip_font_set, *tooltip_font_color;
GtkWidget *tooltip_task_show, *tooltip_show_after, *tooltip_hide_after;
GtkWidget *tooltip_task_show, *tooltip_show_after, *tooltip_hide_after, *tooltip_task_thumbnail, *tooltip_task_thumbnail_size;
GtkWidget *clock_format_tooltip, *clock_tmz_tooltip;
GtkWidget *tooltip_background;
@ -3288,6 +3288,36 @@ void create_task(GtkWidget *parent)
"over task buttons."),
NULL);
row++, col = 2;
label = gtk_label_new(_("Thumbnails"));
gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
gtk_widget_show(label);
gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0);
col++;
tooltip_task_thumbnail = gtk_check_button_new();
gtk_widget_show(tooltip_task_thumbnail);
gtk_table_attach(GTK_TABLE(table), tooltip_task_thumbnail, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0);
col++;
gtk_tooltips_set_tip(tooltips,
tooltip_task_thumbnail,
_("If enabled, a tooltip showing the window thumbnail is displayed when the mouse cursor moves "
"over task buttons."),
NULL);
row++, col = 2;
label = gtk_label_new(_("Thumbnail size"));
gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
gtk_widget_show(label);
gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0);
col++;
tooltip_task_thumbnail_size = gtk_spin_button_new_with_range(8, 9000, 1);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(tooltip_task_thumbnail_size), 210);
gtk_widget_show(tooltip_task_thumbnail_size);
gtk_table_attach(GTK_TABLE(table), tooltip_task_thumbnail_size, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0);
col++;
row++, col = 2;
label = gtk_label_new(_("Maximum width"));
gtk_misc_set_alignment(GTK_MISC(label), 0, 0);

View file

@ -105,7 +105,7 @@ extern GtkWidget *systray_background, *systray_monitor, *systray_name_filter;
// tooltip
extern GtkWidget *tooltip_padding_x, *tooltip_padding_y, *tooltip_font, *tooltip_font_set, *tooltip_font_color;
extern GtkWidget *tooltip_task_show, *tooltip_show_after, *tooltip_hide_after;
extern GtkWidget *tooltip_task_show, *tooltip_show_after, *tooltip_hide_after, *tooltip_task_thumbnail, *tooltip_task_thumbnail_size;
extern GtkWidget *clock_format_tooltip, *clock_tmz_tooltip;
extern GtkWidget *tooltip_background;

View file

@ -517,6 +517,11 @@ void config_write_task(FILE *fp)
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(task_font_set)))
fprintf(fp, "task_font = %s\n", gtk_font_button_get_font_name(GTK_FONT_BUTTON(task_font)));
fprintf(fp, "task_tooltip = %d\n", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(tooltip_task_show)) ? 1 : 0);
fprintf(fp, "task_thumbnail = %d\n", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(tooltip_task_thumbnail)) ? 1 : 0);
fprintf(fp,
"task_thumbnail_size = %d\n",
(int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(tooltip_task_thumbnail_size)));
// same for: "" _normal _active _urgent _iconified
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(task_default_color_set))) {
@ -1732,6 +1737,10 @@ void add_entry(char *key, char *value)
else if (strcmp(key, "task_tooltip") == 0 || strcmp(key, "tooltip") == 0) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(tooltip_task_show), atoi(value));
}
else if (strcmp(key, "task_thumbnail") == 0)
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(tooltip_task_thumbnail), atoi(value));
else if (strcmp(key, "task_thumbnail_size") == 0)
gtk_spin_button_set_value(GTK_SPIN_BUTTON(tooltip_task_thumbnail_size), MAX(8, atoi(value1)));
/* Systray */
else if (strcmp(key, "systray") == 0) {

View file

@ -357,7 +357,7 @@ char *get_window_name(Window win)
return result;
}
cairo_surface_t *get_window_thumbnail(Window win)
cairo_surface_t *get_window_thumbnail(Window win, int size)
{
XWindowAttributes wa;
if (!XGetWindowAttributes(server.display, win, &wa))
@ -369,7 +369,7 @@ cairo_surface_t *get_window_thumbnail(Window win)
int tw, th;
double sx, sy;
double ox, oy;
tw = 210;
tw = size;
th = h * tw / w;
if (th > tw * 0.618) {
th = (int)(tw * 0.618);

View file

@ -34,6 +34,6 @@ int get_icon_count(gulong *data, int num);
gulong *get_best_icon(gulong *data, int icon_count, int num, int *iw, int *ih, int best_icon_size);
char *get_window_name(Window win);
cairo_surface_t *get_window_thumbnail(Window win);
cairo_surface_t *get_window_thumbnail(Window win, int size);
#endif

View file

@ -1,4 +1,4 @@
#---- Generated by tint2conf d8b1 ----
#---- Generated by tint2conf aeaf ----
# See https://gitlab.com/o9000/tint2/wikis/Configure for
# full documentation of the configuration options.
#-------------------------------------
@ -115,6 +115,8 @@ urgent_nb_of_blink = 100000
task_maximum_size = 150 35
task_padding = 2 2 4
task_tooltip = 1
task_thumbnail = 0
task_thumbnail_size = 210
task_font_color = #ffffff 100
task_background_id = 2
task_active_background_id = 3