all repos — tint2 @ 521ffbfaaf4b665de81af14205075c745bf2f8ad

fork of the tint2 desktop panel for my custom setup - only minimized windows across all desktops for the taskbar

Remove primary_monitor_first and add primary as a possible monitor value (issue #614)
o9000 mrovi9000@gmail.com
commit

521ffbfaaf4b665de81af14205075c745bf2f8ad

parent

cd33e5b274c7912a38798c3366183fe5ad4a8fd5

M ChangeLogChangeLog

@@ -3,6 +3,8 @@ - Enhancements:

- Taskbar: new config option taskbar_hide_different_desktop - Battery: new config option bat1_format and bat2_format - Battery: new config option battery_full_cmd +- Configuration changes: + - Removed primary_monitor_first as it was conflicting with taskbar behavior; use *_monitor = primary instead. 2017-06-11 0.14.6 - Fixes:
M doc/tint2.mddoc/tint2.md

@@ -258,11 +258,11 @@ * `:` adds a separator. You can specify more than one. *(since 0.13.0)*

For example, `panel_items = STC` will show the systray, the taskbar and the clock (from left to right). - * `panel_monitor = monitor (all or 1 or 2 or ...)` : Which monitor tint2 draws the panel on + * `panel_monitor = monitor (all or primary or 1 or 2 or ...)` : Which monitor tint2 draws the panel on * The first monitor is `1` * Use `panel_monitor = all` to get a separate panel per monitor - * `primary_monitor_first = boolean (0 or 1)` : Place the primary monitor before all the other monitors in the list. *(since 0.12.4)* + * `primary_monitor_first = boolean (0 or 1)` : Place the primary monitor before all the other monitors in the list. *(since 0.12.4; removed in 0.15, use `primary` instead)* ![](images/panel_padding.jpg)

@@ -473,7 +473,7 @@ * `systray_icon_size = max_icon_size` : Set the maximum system tray icon size to `number`. Set to `0` for automatic icon sizing.

* `systray_icon_asb = alpha (0 to 100) saturation (-100 to 100) brightness (-100 to 100)` : Adjust the systray icons color and transparency. - * `systray_monitor = integer (1, 2, ...)` : On which monitor to draw the systray. The first monitor is `1`. *(since 0.12)* + * `systray_monitor = integer (1, 2, ...) or primary` : On which monitor to draw the systray. The first monitor is `1`. *(since 0.12)* * `systray_name_filter = string` : Regular expression to identify icon names to be hidden. For example, `^audacious$` will hide icons with the exact name `audacious`, while `aud` will hide any icons having `aud` in the name. *(since 0.13.1)*
M src/config.csrc/config.c

@@ -135,27 +135,36 @@ }

int config_get_monitor(char *monitor) { - if (strcmp(monitor, "all") != 0) { - char *endptr; - int ret_int = strtol(monitor, &endptr, 10); - if (*endptr == 0) - return ret_int - 1; - else { - // monitor specified by name, not by index - int i, j; - for (i = 0; i < server.num_monitors; ++i) { - if (server.monitors[i].names == 0) - // xrandr can't identify monitors - continue; - j = 0; - while (server.monitors[i].names[j] != 0) { - if (strcmp(monitor, server.monitors[i].names[j++]) == 0) - return i; - } + if (strcmp(monitor, "primary") == 0) { + for (int i = 0; i < server.num_monitors; ++i) { + if (server.monitors[i].primary) + return i; + } + return 0; + } + if (strcmp(monitor, "all") == 0) { + return -1; + } + char *endptr; + int ret_int = strtol(monitor, &endptr, 10); + if (*endptr == 0) + return ret_int - 1; + else { + // monitor specified by name, not by index + int i, j; + for (i = 0; i < server.num_monitors; ++i) { + if (server.monitors[i].names == 0) + // xrandr can't identify monitors + continue; + j = 0; + while (server.monitors[i].names[j] != 0) { + if (strcmp(monitor, server.monitors[i].names[j++]) == 0) + return i; } } } - // monitor == "all" or monitor not found or xrandr can't identify monitors + + // monitor not found or xrandr can't identify monitors => all return -1; }

@@ -381,8 +390,6 @@

/* Panel */ else if (strcmp(key, "panel_monitor") == 0) { panel_config.monitor = config_get_monitor(value); - } else if (strcmp(key, "primary_monitor_first") == 0) { - primary_monitor_first = atoi(value); } else if (strcmp(key, "panel_shrink") == 0) { panel_shrink = atoi(value); } else if (strcmp(key, "panel_size") == 0) {

@@ -1116,7 +1123,7 @@ systray.alpha = atoi(value1);

systray.saturation = atoi(value2); systray.brightness = atoi(value3); } else if (strcmp(key, "systray_monitor") == 0) { - systray_monitor = atoi(value) - 1; + systray_monitor = MAX(0, config_get_monitor(value)); } else if (strcmp(key, "systray_name_filter") == 0) { if (systray_hide_name_filter) free(systray_hide_name_filter);
M src/server.csrc/server.c

@@ -31,8 +31,6 @@ #include "window.h"

Server server; -gboolean primary_monitor_first = FALSE; - void server_catch_error(Display *d, XErrorEvent *ev) { }

@@ -267,13 +265,6 @@ int compare_monitor_pos(const void *monitor1, const void *monitor2)

{ const Monitor *m1 = (const Monitor *)monitor1; const Monitor *m2 = (const Monitor *)monitor2; - - if (primary_monitor_first) { - if (m1->primary && !m2->primary) - return -1; - if (!m1->primary && m2->primary) - return 1; - } if (m1->x < m2->x) { return -1;
M src/tint.csrc/tint.c

@@ -576,9 +576,6 @@ }

void init_X11_post_config() { - if (primary_monitor_first) - sort_monitors(); - server_init_visual(); gboolean need_sigchld = FALSE;
M src/tint2conf/properties.csrc/tint2conf/properties.c

@@ -31,7 +31,7 @@ GtkWidget *panel_window_name, *disable_transparency;

GtkWidget *panel_mouse_effects; GtkWidget *mouse_hover_icon_opacity, *mouse_hover_icon_saturation, *mouse_hover_icon_brightness; GtkWidget *mouse_pressed_icon_opacity, *mouse_pressed_icon_saturation, *mouse_pressed_icon_brightness; -GtkWidget *panel_primary_monitor_first, *panel_shrink; +GtkWidget *panel_shrink; GtkListStore *panel_items, *all_items; GtkWidget *panel_items_view, *all_items_view;

@@ -477,6 +477,7 @@ gtk_widget_show(panel_combo_monitor);

gtk_table_attach(GTK_TABLE(table), panel_combo_monitor, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); col++; gtk_combo_box_append_text(GTK_COMBO_BOX(panel_combo_monitor), _("All")); + gtk_combo_box_append_text(GTK_COMBO_BOX(panel_combo_monitor), _("Primary")); gtk_combo_box_append_text(GTK_COMBO_BOX(panel_combo_monitor), _("1")); gtk_combo_box_append_text(GTK_COMBO_BOX(panel_combo_monitor), _("2")); gtk_combo_box_append_text(GTK_COMBO_BOX(panel_combo_monitor), _("3"));

@@ -485,24 +486,6 @@ gtk_combo_box_append_text(GTK_COMBO_BOX(panel_combo_monitor), _("5"));

gtk_combo_box_append_text(GTK_COMBO_BOX(panel_combo_monitor), _("6")); gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_monitor), 0); gtk_tooltips_set_tip(tooltips, panel_combo_monitor, _("The monitor on which the panel is placed"), NULL); - - row++; - col = 2; - label = gtk_label_new(_("Primary monitor first")); - 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++; - - panel_primary_monitor_first = gtk_check_button_new(); - gtk_widget_show(panel_primary_monitor_first); - gtk_table_attach(GTK_TABLE(table), panel_primary_monitor_first, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); - col++; - gtk_tooltips_set_tip(tooltips, - panel_primary_monitor_first, - _("If enabled, the primary monitor will have index 1 in the monitor list even if it is not " - "top-left."), - NULL); row++; col = 2;

@@ -5169,6 +5152,7 @@ systray_monitor = gtk_combo_box_new_text();

gtk_widget_show(systray_monitor); gtk_table_attach(GTK_TABLE(table), systray_monitor, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); col++; + gtk_combo_box_append_text(GTK_COMBO_BOX(systray_monitor), _("Primary")); gtk_combo_box_append_text(GTK_COMBO_BOX(systray_monitor), _("1")); gtk_combo_box_append_text(GTK_COMBO_BOX(systray_monitor), _("2")); gtk_combo_box_append_text(GTK_COMBO_BOX(systray_monitor), _("3"));
M src/tint2conf/properties.hsrc/tint2conf/properties.h

@@ -19,7 +19,7 @@ extern GtkWidget *panel_window_name, *disable_transparency;

extern GtkWidget *panel_mouse_effects; extern GtkWidget *mouse_hover_icon_opacity, *mouse_hover_icon_saturation, *mouse_hover_icon_brightness; extern GtkWidget *mouse_pressed_icon_opacity, *mouse_pressed_icon_saturation, *mouse_pressed_icon_brightness; -extern GtkWidget *panel_primary_monitor_first, *panel_shrink; +extern GtkWidget *panel_shrink; enum { itemsColName = 0, itemsColValue, itemsNumCols }; extern GtkListStore *panel_items, *all_items;
M src/tint2conf/properties_rw.csrc/tint2conf/properties_rw.c

@@ -326,16 +326,14 @@ }

fprintf(fp, "\n"); fprintf(fp, "panel_monitor = "); - if (gtk_combo_box_get_active(GTK_COMBO_BOX(panel_combo_monitor)) == 0) { + if (gtk_combo_box_get_active(GTK_COMBO_BOX(panel_combo_monitor)) <= 0) { fprintf(fp, "all"); + } else if (gtk_combo_box_get_active(GTK_COMBO_BOX(panel_combo_monitor)) == 1) { + fprintf(fp, "primary"); } else { - fprintf(fp, "%d", gtk_combo_box_get_active(GTK_COMBO_BOX(panel_combo_monitor))); + fprintf(fp, "%d", gtk_combo_box_get_active(GTK_COMBO_BOX(panel_combo_monitor)) - 1); } fprintf(fp, "\n"); - - fprintf(fp, - "primary_monitor_first = %d\n", - gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(panel_primary_monitor_first)) ? 1 : 0); fprintf(fp, "panel_shrink = %d\n", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(panel_shrink)) ? 1 : 0);

@@ -632,7 +630,11 @@ (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(systray_icon_saturation)),

(int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(systray_icon_brightness))); fprintf(fp, "systray_monitor = "); - fprintf(fp, "%d", MAX(1, 1 + gtk_combo_box_get_active(GTK_COMBO_BOX(systray_monitor)))); + if (gtk_combo_box_get_active(GTK_COMBO_BOX(systray_monitor)) <= 0) { + fprintf(fp, "primary"); + } else { + fprintf(fp, "%d", MAX(1, gtk_combo_box_get_active(GTK_COMBO_BOX(systray_monitor)))); + } fprintf(fp, "\n"); fprintf(fp, "systray_name_filter = %s\n", gtk_entry_get_text(GTK_ENTRY(systray_name_filter)));

@@ -1357,20 +1359,20 @@ gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_layer), 1);

} else if (strcmp(key, "panel_monitor") == 0) { if (strcmp(value, "all") == 0) gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_monitor), 0); - else if (strcmp(value, "1") == 0) + else if (strcmp(value, "primary") == 0) gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_monitor), 1); + else if (strcmp(value, "1") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_monitor), 2); else if (strcmp(value, "2") == 0) - gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_monitor), 2); - else if (strcmp(value, "3") == 0) gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_monitor), 3); - else if (strcmp(value, "4") == 0) + else if (strcmp(value, "3") == 0) gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_monitor), 4); + else if (strcmp(value, "4") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_monitor), 5); else if (strcmp(value, "5") == 0) - gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_monitor), 5); + gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_monitor), 6); else if (strcmp(value, "6") == 0) - gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_monitor), 6); - } else if (strcmp(key, "primary_monitor_first") == 0) { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(panel_primary_monitor_first), atoi(value)); + gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_monitor), 7); } else if (strcmp(key, "panel_shrink") == 0) { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(panel_shrink), atoi(value)); }

@@ -1761,18 +1763,20 @@ gtk_combo_box_set_active(GTK_COMBO_BOX(systray_icon_order), 2);

} else if (strcmp(key, "systray_icon_size") == 0) { gtk_spin_button_set_value(GTK_SPIN_BUTTON(systray_icon_size), atoi(value)); } else if (strcmp(key, "systray_monitor") == 0) { - if (strcmp(value, "1") == 0) + if (strcmp(value, "primary") == 0) gtk_combo_box_set_active(GTK_COMBO_BOX(systray_monitor), 0); + else if (strcmp(value, "1") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(systray_monitor), 1); else if (strcmp(value, "2") == 0) - gtk_combo_box_set_active(GTK_COMBO_BOX(systray_monitor), 1); - else if (strcmp(value, "3") == 0) gtk_combo_box_set_active(GTK_COMBO_BOX(systray_monitor), 2); - else if (strcmp(value, "4") == 0) + else if (strcmp(value, "3") == 0) gtk_combo_box_set_active(GTK_COMBO_BOX(systray_monitor), 3); + else if (strcmp(value, "4") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(systray_monitor), 4); else if (strcmp(value, "5") == 0) - gtk_combo_box_set_active(GTK_COMBO_BOX(systray_monitor), 4); + gtk_combo_box_set_active(GTK_COMBO_BOX(systray_monitor), 5); else if (strcmp(value, "6") == 0) - gtk_combo_box_set_active(GTK_COMBO_BOX(systray_monitor), 5); + gtk_combo_box_set_active(GTK_COMBO_BOX(systray_monitor), 6); } else if (strcmp(key, "systray_icon_asb") == 0) { extract_values(value, &value1, &value2, &value3); gtk_spin_button_set_value(GTK_SPIN_BUTTON(systray_icon_opacity), atoi(value1));