From d8cccf5928815125256004858faad46519b732d3 Mon Sep 17 00:00:00 2001 From: Simon Steinbeiss Date: Mon, 27 Feb 2017 23:33:01 +0100 Subject: [PATCH] Add support for XRandR's primary monitor feature (Bug #9338) If there is no output name set in xfconf it behaves like before, i.e. "Automatic" mode. However if the driver does not return a monitor name it now falls back to the primary display. --- panel/panel-preferences-dialog.c | 5 ++++- panel/panel-window.c | 14 +++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/panel/panel-preferences-dialog.c b/panel/panel-preferences-dialog.c index 7a93e24..f700b18 100644 --- a/panel/panel-preferences-dialog.c +++ b/panel/panel-preferences-dialog.c @@ -490,8 +490,11 @@ panel_preferences_dialog_bindings_update (PanelPreferencesDialog *dialog) || !panel_str_is_empty (output_name)) { gtk_list_store_insert_with_values (GTK_LIST_STORE (store), &iter, n++, - OUTPUT_NAME, NULL, + OUTPUT_NAME, "Automatic", OUTPUT_TITLE, _("Automatic"), -1); + gtk_list_store_insert_with_values (GTK_LIST_STORE (store), &iter, n++, + OUTPUT_NAME, "Primary", + OUTPUT_TITLE, _("Primary"), -1); if (panel_str_is_empty (output_name)) { gtk_combo_box_set_active_iter (GTK_COMBO_BOX (object), &iter); diff --git a/panel/panel-window.c b/panel/panel-window.c index 3f27da3..2d4cb49 100644 --- a/panel/panel-window.c +++ b/panel/panel-window.c @@ -2084,16 +2084,24 @@ panel_window_screen_layout_changed (GdkScreen *screen, } else { - if (panel_str_is_empty (window->output_name)) + if (g_strcmp0 (window->output_name, "Automatic") == 0 + || window->output_name == NULL) { - normal_monitor_positioning: - /* get the monitor geometry based on the panel position */ monitor_num = gdk_screen_get_monitor_at_point (screen, window->base_x, window->base_y); gdk_screen_get_monitor_geometry (screen, monitor_num, &a); panel_return_if_fail (a.width > 0 && a.height > 0); } + else if (g_strcmp0 (window->output_name, "Primary") == 0) + { + normal_monitor_positioning: + /* get the primary monitor */ + monitor_num = gdk_screen_get_primary_monitor (screen); + + gdk_screen_get_monitor_geometry (screen, monitor_num, &a); + panel_return_if_fail (a.width > 0 && a.height > 0); + } else { /* check if we've stored the monitor number in the config or -- 2.9.3