Add option to hide tasks from different monitors when panel_monitor = x (issue 196)

git-svn-id: http://tint2.googlecode.com/svn/trunk@736 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
This commit is contained in:
o9000 2015-03-21 09:49:10 +00:00 committed by mrovi9000@gmail.com
parent a2de8d6e53
commit c900bc24b2
8 changed files with 40 additions and 10 deletions

View file

@ -500,6 +500,9 @@ void add_entry (char *key, char *value)
else if (strcmp (key, "taskbar_hide_inactive_tasks") == 0) {
hide_inactive_tasks = atoi (value);
}
else if (strcmp (key, "taskbar_hide_different_monitor") == 0) {
hide_task_diff_monitor = atoi (value);
}
/* Task */
else if (strcmp (key, "task_text") == 0)

View file

@ -524,7 +524,7 @@ void set_task_state(Task *tsk, int state)
if (tsk == 0 || state < 0 || state >= TASK_STATE_COUNT)
return;
if (tsk->current_state != state) {
if (tsk->current_state != state || hide_task_diff_monitor) {
GPtrArray* task_group = task_get_tasks(tsk->win);
if (task_group) {
int i;
@ -538,12 +538,17 @@ void set_task_state(Task *tsk, int state)
if (state == TASK_ACTIVE && g_slist_find(urgent_list, tsk1))
del_urgent(tsk1);
// Show only the active task
int hide = 0;
if (hide_inactive_tasks) {
if (state != TASK_ACTIVE) {
tsk1->area.on_screen = 0;
} else {
tsk1->area.on_screen = 1;
hide = 1;
}
}
if (window_get_monitor(tsk->win) != ((Panel*)tsk->area.panel)->monitor) {
hide = 1;
}
if (1 - hide != tsk1->area.on_screen) {
tsk1->area.on_screen = 1 - hide;
set_task_redraw(tsk1);
Panel *p = (Panel*)tsk->area.panel;
tsk->area.resize = 1;

View file

@ -44,6 +44,7 @@ Task *task_drag;
int taskbar_enabled;
int taskbar_distribute_size;
int hide_inactive_tasks;
int hide_task_diff_monitor;
guint win_hash(gconstpointer key) { return (guint)*((Window*)key); }
gboolean win_compare(gconstpointer a, gconstpointer b) { return (*((Window*)a) == *((Window*)b)); }
@ -58,6 +59,7 @@ void default_taskbar()
taskbar_enabled = 0;
taskbar_distribute_size = 0;
hide_inactive_tasks = 0;
hide_task_diff_monitor = 0;
default_taskbarname();
}

View file

@ -18,6 +18,7 @@ extern Task *task_drag;
extern int taskbar_enabled;
extern int taskbar_distribute_size;
extern int hide_inactive_tasks;
extern int hide_task_diff_monitor;
typedef struct {
// always start with area

View file

@ -819,12 +819,18 @@ void event_configure_notify (Window win)
}
// 'win' move in another monitor
if (nb_panel == 1) return;
if (nb_panel == 1 && !hide_task_diff_monitor)
return;
Task *tsk = task_get_task (win);
if (!tsk) return;
if (!tsk)
return;
Panel *p = tsk->area.panel;
if (p->monitor != window_get_monitor (win)) {
int monitor = window_get_monitor(win);
if ((hide_task_diff_monitor && p->monitor != monitor && tsk->area.on_screen) ||
(hide_task_diff_monitor && p->monitor == monitor && !tsk->area.on_screen) ||
(p->monitor != monitor && nb_panel > 1)) {
remove_task (tsk);
tsk = add_task (win);
if (win == window_get_active ()) {

View file

@ -41,7 +41,7 @@ GtkWidget *panel_background;
// taskbar
GtkWidget *taskbar_show_desktop, *taskbar_show_name, *taskbar_padding_x, *taskbar_padding_y, *taskbar_spacing;
GtkWidget *taskbar_hide_inactive_tasks;
GtkWidget *taskbar_hide_inactive_tasks, *taskbar_hide_diff_monitor;
GtkWidget *taskbar_name_padding_x, *taskbar_name_inactive_color, *taskbar_name_active_color, *taskbar_name_font;
GtkWidget *taskbar_active_background, *taskbar_inactive_background;
GtkWidget *taskbar_name_active_background, *taskbar_name_inactive_background;
@ -1877,7 +1877,7 @@ void create_taskbar(GtkWidget *parent)
{
GtkWidget *table, *label;
table = gtk_table_new(3, 2, FALSE);
table = gtk_table_new(4, 2, FALSE);
gtk_widget_show(table);
gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0);
gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING);
@ -1910,6 +1910,15 @@ void create_taskbar(GtkWidget *parent)
gtk_widget_show(taskbar_hide_inactive_tasks);
gtk_table_attach(GTK_TABLE(table), taskbar_hide_inactive_tasks, 1, 2, 2, 3, GTK_FILL, 0, 0, 0);
label = gtk_label_new(_("Hide tasks from different monitors"));
gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
gtk_widget_show(label);
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 3, 4, GTK_FILL, 0, 0, 0);
taskbar_hide_diff_monitor = gtk_check_button_new();
gtk_widget_show(taskbar_hide_diff_monitor);
gtk_table_attach(GTK_TABLE(table), taskbar_hide_diff_monitor, 1, 2, 3, 4, GTK_FILL, 0, 0, 0);
change_paragraph(parent);
label = gtk_label_new(_("<b>Taskbar Appearance</b>"));

View file

@ -46,7 +46,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;
extern GtkWidget *taskbar_hide_inactive_tasks, *taskbar_hide_diff_monitor;
extern GtkWidget *taskbar_name_padding_x, *taskbar_name_inactive_color, *taskbar_name_active_color, *taskbar_name_font;
extern GtkWidget *taskbar_active_background, *taskbar_inactive_background;
extern GtkWidget *taskbar_name_active_background, *taskbar_name_inactive_background;

View file

@ -192,6 +192,7 @@ void config_write_taskbar(FILE *fp)
fprintf(fp, "taskbar_active_background_id = %d\n", 1 + gtk_combo_box_get_active(GTK_COMBO_BOX(taskbar_active_background)));
fprintf(fp, "taskbar_name = %d\n", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(taskbar_show_name)) ? 1 : 0);
fprintf(fp, "taskbar_hide_inactive_tasks = %d\n", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(taskbar_hide_inactive_tasks)) ? 1 : 0);
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_name_padding = %d\n",
(int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(taskbar_name_padding_x)));
@ -875,6 +876,9 @@ void add_entry(char *key, char *value)
else if (strcmp(key, "taskbar_hide_inactive_tasks") == 0) {
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_name_padding") == 0) {
extract_values(value, &value1, &value2, &value3);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(taskbar_name_padding_x), atoi(value1));