Add option primary_monitor_first (fixes issue #538)
This commit is contained in:
parent
da0c52ecff
commit
7582b9f960
6 changed files with 37 additions and 0 deletions
|
@ -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);
|
||||
|
||||
|
|
11
src/server.c
11
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);
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
#endif
|
||||
#include <glib.h>
|
||||
|
||||
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;
|
||||
|
||||
|
|
|
@ -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"));
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue