diff --git a/src/config.c b/src/config.c index 46cd3e7..45d1c09 100644 --- a/src/config.c +++ b/src/config.c @@ -294,6 +294,8 @@ void add_entry(char *key, char *value) /* 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_size") == 0) { extract_values(value, &value1, &value2, &value3); diff --git a/src/server.c b/src/server.c index 1c87c8c..2fdf53d 100644 --- a/src/server.c +++ b/src/server.c @@ -31,6 +31,8 @@ Server server; +gboolean primary_monitor_first = FALSE; + void server_catch_error(Display *d, XErrorEvent *ev) { } @@ -261,6 +263,13 @@ 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 (m2->primary && !m1->primary) + return -1; + } + if (m1->x < m2->x) { return -1; } else if (m1->x > m2->x) { @@ -294,6 +303,7 @@ void get_monitors() int num_monitors; XineramaScreenInfo *info = XineramaQueryScreens(server.dsp, &num_monitors); XRRScreenResources *res = XRRGetScreenResourcesCurrent(server.dsp, server.root_win); + RROutput primary_output = XRRGetOutputPrimary(server.dsp, server.root_win); if (res && res->ncrtc >= num_monitors) { // use xrandr to identify monitors (does not work with proprietery nvidia drivers) @@ -323,6 +333,7 @@ void get_monitors() printf("xRandr: Linking output %s with crtc %d\n", output_info->name, i); server.monitors[i].names[j] = g_strdup(output_info->name); XRRFreeOutputInfo(output_info); + server.monitors[i].primary = crtc_info->outputs[j] == primary_output; } server.monitors[i].names[crtc_info->noutput] = NULL; XRRFreeCrtcInfo(crtc_info); diff --git a/src/server.h b/src/server.h index acdcde7..b1076d2 100644 --- a/src/server.h +++ b/src/server.h @@ -18,6 +18,8 @@ #endif #include +extern gboolean primary_monitor_first; + typedef struct Global_atom { Atom _XROOTPMAP_ID; Atom _XROOTMAP_ID; @@ -96,6 +98,7 @@ typedef struct Monitor { int y; int width; int height; + gboolean primary; gchar **names; } Monitor; diff --git a/src/tint2conf/properties.c b/src/tint2conf/properties.c index cdddd40..e382ebc 100644 --- a/src/tint2conf/properties.c +++ b/src/tint2conf/properties.c @@ -37,6 +37,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; GtkListStore *panel_items, *all_items; GtkWidget *panel_items_view, *all_items_view; @@ -1130,6 +1131,20 @@ void create_panel(GtkWidget *parent) 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; label = gtk_label_new(_("Length")); diff --git a/src/tint2conf/properties.h b/src/tint2conf/properties.h index 0275f84..176be76 100644 --- a/src/tint2conf/properties.h +++ b/src/tint2conf/properties.h @@ -17,6 +17,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; enum { itemsColName = 0, diff --git a/src/tint2conf/properties_rw.c b/src/tint2conf/properties_rw.c index 456cbef..62ce795 100644 --- a/src/tint2conf/properties_rw.c +++ b/src/tint2conf/properties_rw.c @@ -228,6 +228,8 @@ void config_write_panel(FILE *fp) } 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, "autohide = %d\n", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(panel_autohide)) ? 1 : 0); fprintf(fp, "autohide_show_timeout = %g\n", gtk_spin_button_get_value(GTK_SPIN_BUTTON(panel_autohide_show_time))); fprintf(fp, "autohide_hide_timeout = %g\n", gtk_spin_button_get_value(GTK_SPIN_BUTTON(panel_autohide_hide_time))); @@ -1022,6 +1024,9 @@ void add_entry(char *key, char *value) 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)); + } /* autohide options */ else if (strcmp(key, "autohide") == 0) {