taskbar_hide_different_desktop

This commit is contained in:
o9000 2017-06-20 05:06:37 +02:00
parent 2dfcab170d
commit d55f6d7baa
10 changed files with 47 additions and 3 deletions

View file

@ -1,3 +1,7 @@
2017-06-20 master
- Enhancements:
- Taskbar: new config option taskbar_hide_different_desktop
2017-06-11 0.14.6
- Fixes:
- Take into account border width when computing text height

View file

@ -370,6 +370,8 @@ panel_size = 94% 30
* `taskbar_hide_different_monitor = boolean (0 or 1)` : If enabled, the taskbar shows only the tasks from the current monitor. Useful when running different tint2 instances on different monitors, each one having its own config. *(since 0.12)*
* `taskbar_hide_different_desktop = boolean (0 or 1)` : If enabled, the taskbar shows only the tasks from the current desktop. Useful to make multi-desktop taskbars more compact, but still allow desktop switching with mouse click. *(since 0.15)*
* `taskbar_always_show_all_desktop_tasks = boolean (0 or 1)` : Has effect only if `taskbar_mode = multi_desktop`. If enabled, tasks that appear on all desktops are shown on all taskbars. Otherwise, they are shown only on the taskbar of the current desktop. *(since 0.12.4)*
* `taskbar_sort_order = none/title/center` : Specifies the sort order of the tasks on the taskbar. *(since 0.12)*

View file

@ -960,6 +960,8 @@ void add_entry(char *key, char *value)
hide_inactive_tasks = atoi(value);
} else if (strcmp(key, "taskbar_hide_different_monitor") == 0) {
hide_task_diff_monitor = atoi(value);
} else if (strcmp(key, "taskbar_hide_different_desktop") == 0) {
hide_task_diff_desktop = atoi(value);
} else if (strcmp(key, "taskbar_hide_if_empty") == 0) {
hide_taskbar_if_empty = atoi(value);
} else if (strcmp(key, "taskbar_always_show_all_desktop_tasks") == 0) {

View file

@ -624,7 +624,7 @@ void set_task_state(Task *task, TaskState state)
}
}
if (task->current_state != state || hide_task_diff_monitor) {
if (task->current_state != state || hide_task_diff_monitor || hide_task_diff_desktop) {
GPtrArray *task_buttons = get_task_buttons(task->win);
if (task_buttons) {
for (int i = 0; i < task_buttons->len; ++i) {
@ -648,6 +648,10 @@ void set_task_state(Task *task, TaskState state)
hide = TRUE;
}
}
if (hide_task_diff_desktop) {
if (taskbar->desktop != server.desktop)
hide = TRUE;
}
if (get_window_monitor(task->win) != ((Panel *)task->area.panel)->monitor &&
(hide_task_diff_monitor || num_panels > 1)) {
hide = TRUE;

View file

@ -39,6 +39,7 @@ Task *active_task;
Task *task_drag;
gboolean taskbar_enabled;
gboolean taskbar_distribute_size;
gboolean hide_task_diff_desktop;
gboolean hide_inactive_tasks;
gboolean hide_task_diff_monitor;
gboolean hide_taskbar_if_empty;
@ -74,6 +75,7 @@ void default_taskbar()
urgent_list = NULL;
taskbar_enabled = FALSE;
taskbar_distribute_size = FALSE;
hide_task_diff_desktop = FALSE;
hide_inactive_tasks = FALSE;
hide_task_diff_monitor = FALSE;
hide_taskbar_if_empty = FALSE;
@ -535,6 +537,15 @@ void set_taskbar_state(Taskbar *taskbar, TaskbarState state)
for (; l; l = l->next)
schedule_redraw((Area *)l->data);
}
if (taskbar_mode == MULTI_DESKTOP && hide_task_diff_desktop) {
GList *l = taskbar->area.children;
if (taskbarname_enabled)
l = l->next;
for (; l; l = l->next) {
Task *task = (Task *)l->data;
set_task_state(task, task->current_state);
}
}
}
schedule_panel_redraw();
}

View file

@ -49,6 +49,7 @@ typedef struct GlobalTaskbar {
extern gboolean taskbar_enabled;
extern gboolean taskbar_distribute_size;
extern gboolean hide_task_diff_desktop;
extern gboolean hide_inactive_tasks;
extern gboolean hide_task_diff_monitor;
extern gboolean hide_taskbar_if_empty;

View file

@ -917,6 +917,8 @@ void event_button_motion_notify(XEvent *e)
task_drag->desktop = event_taskbar->desktop;
change_window_desktop(task_drag->win, event_taskbar->desktop);
if (hide_task_diff_desktop)
change_desktop(event_taskbar->desktop);
if (taskbar_sort_method != TASKBAR_NOSORT) {
sort_tasks(event_taskbar);

View file

@ -44,7 +44,7 @@ GtkWidget *notebook;
// taskbar
GtkWidget *taskbar_show_desktop, *taskbar_show_name, *taskbar_padding_x, *taskbar_padding_y, *taskbar_spacing;
GtkWidget *taskbar_hide_inactive_tasks, *taskbar_hide_diff_monitor;
GtkWidget *taskbar_hide_inactive_tasks, *taskbar_hide_diff_monitor, *taskbar_hide_diff_desktop;
GtkWidget *taskbar_name_padding_x, *taskbar_name_padding_y, *taskbar_name_inactive_color, *taskbar_name_active_color;
GtkWidget *taskbar_name_font, *taskbar_name_font_set;
GtkWidget *taskbar_active_background, *taskbar_inactive_background;
@ -2651,6 +2651,19 @@ void create_taskbar(GtkWidget *parent)
"This behavior is enabled automatically if the panel monitor is set to 'All'."),
NULL);
col = 2;
row++;
label = gtk_label_new(_("Hide tasks from different desktops"));
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++;
taskbar_hide_diff_desktop = gtk_check_button_new();
gtk_widget_show(taskbar_hide_diff_desktop);
gtk_table_attach(GTK_TABLE(table), taskbar_hide_diff_desktop, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0);
col++;
col = 2;
row++;
label = gtk_label_new(_("Always show all desktop tasks"));

View file

@ -49,7 +49,7 @@ extern GtkWidget *panel_background;
// taskbar
extern GtkWidget *taskbar_show_desktop, *taskbar_show_name, *taskbar_padding_x, *taskbar_padding_y, *taskbar_spacing;
extern GtkWidget *taskbar_hide_inactive_tasks, *taskbar_hide_diff_monitor;
extern GtkWidget *taskbar_hide_inactive_tasks, *taskbar_hide_diff_monitor, *taskbar_hide_diff_desktop;
extern GtkWidget *taskbar_name_padding_x, *taskbar_name_padding_y, *taskbar_name_inactive_color,
*taskbar_name_active_color;
extern GtkWidget *taskbar_name_font, *taskbar_name_font_set;

View file

@ -401,6 +401,9 @@ void config_write_taskbar(FILE *fp)
fprintf(fp,
"taskbar_hide_different_monitor = %d\n",
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(taskbar_hide_diff_monitor)) ? 1 : 0);
fprintf(fp,
"taskbar_hide_different_desktop = %d\n",
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(taskbar_hide_diff_desktop)) ? 1 : 0);
fprintf(fp,
"taskbar_always_show_all_desktop_tasks = %d\n",
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(taskbar_always_show_all_desktop_tasks)) ? 1 : 0);
@ -1551,6 +1554,8 @@ void add_entry(char *key, char *value)
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(taskbar_hide_inactive_tasks), atoi(value));
} else if (strcmp(key, "taskbar_hide_different_monitor") == 0) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(taskbar_hide_diff_monitor), atoi(value));
} else if (strcmp(key, "taskbar_hide_different_desktop") == 0) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(taskbar_hide_diff_desktop), atoi(value));
} else if (strcmp(key, "taskbar_always_show_all_desktop_tasks") == 0) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(taskbar_always_show_all_desktop_tasks), atoi(value));
} else if (strcmp(key, "taskbar_name_padding") == 0) {