Remove primary_monitor_first and add primary as a possible monitor value (issue #614)

This commit is contained in:
o9000 2017-06-22 19:56:47 +02:00
parent cd33e5b274
commit 521ffbfaaf
8 changed files with 62 additions and 77 deletions

View file

@ -3,6 +3,8 @@
- Taskbar: new config option taskbar_hide_different_desktop - Taskbar: new config option taskbar_hide_different_desktop
- Battery: new config option bat1_format and bat2_format - Battery: new config option bat1_format and bat2_format
- Battery: new config option battery_full_cmd - 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 2017-06-11 0.14.6
- Fixes: - Fixes:

View file

@ -258,11 +258,11 @@ gradient_id_pressed = 2
For example, `panel_items = STC` will show the systray, the taskbar and the clock (from left to right). 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` * The first monitor is `1`
* Use `panel_monitor = all` to get a separate panel per monitor * 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) ![](images/panel_padding.jpg)
@ -473,7 +473,7 @@ The action semantics:
* `systray_icon_asb = alpha (0 to 100) saturation (-100 to 100) brightness (-100 to 100)` : Adjust the systray icons color and transparency. * `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)* * `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)*

View file

@ -135,27 +135,36 @@ int get_task_status(char *status)
int config_get_monitor(char *monitor) int config_get_monitor(char *monitor)
{ {
if (strcmp(monitor, "all") != 0) { if (strcmp(monitor, "primary") == 0) {
char *endptr; for (int i = 0; i < server.num_monitors; ++i) {
int ret_int = strtol(monitor, &endptr, 10); if (server.monitors[i].primary)
if (*endptr == 0) return i;
return ret_int - 1; }
else { return 0;
// monitor specified by name, not by index }
int i, j; if (strcmp(monitor, "all") == 0) {
for (i = 0; i < server.num_monitors; ++i) { return -1;
if (server.monitors[i].names == 0) }
// xrandr can't identify monitors char *endptr;
continue; int ret_int = strtol(monitor, &endptr, 10);
j = 0; if (*endptr == 0)
while (server.monitors[i].names[j] != 0) { return ret_int - 1;
if (strcmp(monitor, server.monitors[i].names[j++]) == 0) else {
return i; // 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; return -1;
} }
@ -381,8 +390,6 @@ void add_entry(char *key, char *value)
/* Panel */ /* Panel */
else if (strcmp(key, "panel_monitor") == 0) { else if (strcmp(key, "panel_monitor") == 0) {
panel_config.monitor = config_get_monitor(value); 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) { } else if (strcmp(key, "panel_shrink") == 0) {
panel_shrink = atoi(value); panel_shrink = atoi(value);
} else if (strcmp(key, "panel_size") == 0) { } else if (strcmp(key, "panel_size") == 0) {
@ -1116,7 +1123,7 @@ void add_entry(char *key, char *value)
systray.saturation = atoi(value2); systray.saturation = atoi(value2);
systray.brightness = atoi(value3); systray.brightness = atoi(value3);
} else if (strcmp(key, "systray_monitor") == 0) { } 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) { } else if (strcmp(key, "systray_name_filter") == 0) {
if (systray_hide_name_filter) if (systray_hide_name_filter)
free(systray_hide_name_filter); free(systray_hide_name_filter);

View file

@ -31,8 +31,6 @@
Server server; Server server;
gboolean primary_monitor_first = FALSE;
void server_catch_error(Display *d, XErrorEvent *ev) void server_catch_error(Display *d, XErrorEvent *ev)
{ {
} }
@ -268,13 +266,6 @@ int compare_monitor_pos(const void *monitor1, const void *monitor2)
const Monitor *m1 = (const Monitor *)monitor1; const Monitor *m1 = (const Monitor *)monitor1;
const Monitor *m2 = (const Monitor *)monitor2; 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) { if (m1->x < m2->x) {
return -1; return -1;
} else if (m1->x > m2->x) { } else if (m1->x > m2->x) {

View file

@ -576,9 +576,6 @@ void init_X11_pre_config()
void init_X11_post_config() void init_X11_post_config()
{ {
if (primary_monitor_first)
sort_monitors();
server_init_visual(); server_init_visual();
gboolean need_sigchld = FALSE; gboolean need_sigchld = FALSE;

View file

@ -31,7 +31,7 @@ GtkWidget *panel_window_name, *disable_transparency;
GtkWidget *panel_mouse_effects; GtkWidget *panel_mouse_effects;
GtkWidget *mouse_hover_icon_opacity, *mouse_hover_icon_saturation, *mouse_hover_icon_brightness; 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 *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; GtkListStore *panel_items, *all_items;
GtkWidget *panel_items_view, *all_items_view; GtkWidget *panel_items_view, *all_items_view;
@ -477,6 +477,7 @@ void create_panel(GtkWidget *parent)
gtk_table_attach(GTK_TABLE(table), panel_combo_monitor, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); gtk_table_attach(GTK_TABLE(table), panel_combo_monitor, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0);
col++; col++;
gtk_combo_box_append_text(GTK_COMBO_BOX(panel_combo_monitor), _("All")); 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), _("1"));
gtk_combo_box_append_text(GTK_COMBO_BOX(panel_combo_monitor), _("2")); gtk_combo_box_append_text(GTK_COMBO_BOX(panel_combo_monitor), _("2"));
gtk_combo_box_append_text(GTK_COMBO_BOX(panel_combo_monitor), _("3")); gtk_combo_box_append_text(GTK_COMBO_BOX(panel_combo_monitor), _("3"));
@ -486,24 +487,6 @@ void create_panel(GtkWidget *parent)
gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_monitor), 0); 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); 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++; row++;
col = 2; col = 2;
label = gtk_label_new(_("Length")); label = gtk_label_new(_("Length"));
@ -5169,6 +5152,7 @@ void create_systemtray(GtkWidget *parent)
gtk_widget_show(systray_monitor); gtk_widget_show(systray_monitor);
gtk_table_attach(GTK_TABLE(table), systray_monitor, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); gtk_table_attach(GTK_TABLE(table), systray_monitor, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0);
col++; 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), _("1"));
gtk_combo_box_append_text(GTK_COMBO_BOX(systray_monitor), _("2")); gtk_combo_box_append_text(GTK_COMBO_BOX(systray_monitor), _("2"));
gtk_combo_box_append_text(GTK_COMBO_BOX(systray_monitor), _("3")); gtk_combo_box_append_text(GTK_COMBO_BOX(systray_monitor), _("3"));

View file

@ -19,7 +19,7 @@ extern GtkWidget *panel_window_name, *disable_transparency;
extern GtkWidget *panel_mouse_effects; extern GtkWidget *panel_mouse_effects;
extern GtkWidget *mouse_hover_icon_opacity, *mouse_hover_icon_saturation, *mouse_hover_icon_brightness; 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 *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 }; enum { itemsColName = 0, itemsColValue, itemsNumCols };
extern GtkListStore *panel_items, *all_items; extern GtkListStore *panel_items, *all_items;

View file

@ -326,17 +326,15 @@ void config_write_panel(FILE *fp)
fprintf(fp, "\n"); fprintf(fp, "\n");
fprintf(fp, "panel_monitor = "); 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"); fprintf(fp, "all");
} else if (gtk_combo_box_get_active(GTK_COMBO_BOX(panel_combo_monitor)) == 1) {
fprintf(fp, "primary");
} else { } 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, "\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); fprintf(fp, "panel_shrink = %d\n", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(panel_shrink)) ? 1 : 0);
fprintf(fp, "autohide = %d\n", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(panel_autohide)) ? 1 : 0); fprintf(fp, "autohide = %d\n", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(panel_autohide)) ? 1 : 0);
@ -632,7 +630,11 @@ void config_write_systray(FILE *fp)
(int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(systray_icon_brightness))); (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(systray_icon_brightness)));
fprintf(fp, "systray_monitor = "); 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, "\n");
fprintf(fp, "systray_name_filter = %s\n", gtk_entry_get_text(GTK_ENTRY(systray_name_filter))); fprintf(fp, "systray_name_filter = %s\n", gtk_entry_get_text(GTK_ENTRY(systray_name_filter)));
@ -1357,20 +1359,20 @@ void add_entry(char *key, char *value)
} else if (strcmp(key, "panel_monitor") == 0) { } else if (strcmp(key, "panel_monitor") == 0) {
if (strcmp(value, "all") == 0) if (strcmp(value, "all") == 0)
gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_monitor), 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); gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_monitor), 1);
else if (strcmp(value, "2") == 0) else if (strcmp(value, "1") == 0)
gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_monitor), 2); gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_monitor), 2);
else if (strcmp(value, "3") == 0) else if (strcmp(value, "2") == 0)
gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_monitor), 3); 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); gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_monitor), 4);
else if (strcmp(value, "5") == 0) else if (strcmp(value, "4") == 0)
gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_monitor), 5); gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_monitor), 5);
else if (strcmp(value, "6") == 0) else if (strcmp(value, "5") == 0)
gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_monitor), 6); gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_monitor), 6);
} else if (strcmp(key, "primary_monitor_first") == 0) { else if (strcmp(value, "6") == 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) { } else if (strcmp(key, "panel_shrink") == 0) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(panel_shrink), atoi(value)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(panel_shrink), atoi(value));
} }
@ -1761,18 +1763,20 @@ void add_entry(char *key, char *value)
} else if (strcmp(key, "systray_icon_size") == 0) { } else if (strcmp(key, "systray_icon_size") == 0) {
gtk_spin_button_set_value(GTK_SPIN_BUTTON(systray_icon_size), atoi(value)); gtk_spin_button_set_value(GTK_SPIN_BUTTON(systray_icon_size), atoi(value));
} else if (strcmp(key, "systray_monitor") == 0) { } 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); gtk_combo_box_set_active(GTK_COMBO_BOX(systray_monitor), 0);
else if (strcmp(value, "2") == 0) else if (strcmp(value, "1") == 0)
gtk_combo_box_set_active(GTK_COMBO_BOX(systray_monitor), 1); gtk_combo_box_set_active(GTK_COMBO_BOX(systray_monitor), 1);
else if (strcmp(value, "3") == 0) else if (strcmp(value, "2") == 0)
gtk_combo_box_set_active(GTK_COMBO_BOX(systray_monitor), 2); 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); gtk_combo_box_set_active(GTK_COMBO_BOX(systray_monitor), 3);
else if (strcmp(value, "5") == 0) else if (strcmp(value, "4") == 0)
gtk_combo_box_set_active(GTK_COMBO_BOX(systray_monitor), 4); gtk_combo_box_set_active(GTK_COMBO_BOX(systray_monitor), 4);
else if (strcmp(value, "6") == 0) else if (strcmp(value, "5") == 0)
gtk_combo_box_set_active(GTK_COMBO_BOX(systray_monitor), 5); 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), 6);
} else if (strcmp(key, "systray_icon_asb") == 0) { } else if (strcmp(key, "systray_icon_asb") == 0) {
extract_values(value, &value1, &value2, &value3); extract_values(value, &value1, &value2, &value3);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(systray_icon_opacity), atoi(value1)); gtk_spin_button_set_value(GTK_SPIN_BUTTON(systray_icon_opacity), atoi(value1));