Updating branch refs/heads/bluesabre/display-settings to 25abd5f2a6e4105082ffc4aee21ada2d1637a696 (commit) from 400d9bfb60f30e4856d4ffcc75b5f49bece8189f (commit)
commit 25abd5f2a6e4105082ffc4aee21ada2d1637a696 Author: Lionel Le Folgoc <lio...@lefolgoc.net> Date: Wed Oct 17 22:39:12 2012 +0200 Improve "Mirror displays" mode When the checkbox is enabled, all active outputs use the same mode and position. They revert back to their preferred mode when unchecked. Signed-off-by: Simon Steinbeiss <simon.steinbe...@elfenbeinturm.at> dialogs/display-settings/main.c | 19 ++++++-- dialogs/display-settings/xfce-randr.c | 86 +++++++++++++++------------------ dialogs/display-settings/xfce-randr.h | 5 +- 3 files changed, 57 insertions(+), 53 deletions(-) diff --git a/dialogs/display-settings/main.c b/dialogs/display-settings/main.c index bbfe3dd..033c0a4 100644 --- a/dialogs/display-settings/main.c +++ b/dialogs/display-settings/main.c @@ -1095,6 +1095,7 @@ display_setting_mirror_displays_toggled (GtkToggleButton *togglebutton, { GObject *positions, *active_displays; guint n; + RRMode mode; if (!xfce_randr) return; @@ -1107,14 +1108,16 @@ display_setting_mirror_displays_toggled (GtkToggleButton *togglebutton, if (gtk_toggle_button_get_active (togglebutton)) { - /* Activate mirror-mode */ - - /* Apply mirror settings to each monitor */ + /* Activate mirror-mode with a single mode for all of them */ + mode = xfce_randr_clonable_mode (xfce_randr); + /* Apply mirror settings to each output */ for (n = 0; n < xfce_randr->noutput; n++) { if (xfce_randr->mode[n] == None) continue; + if (mode != None) + xfce_randr->mode[n] = mode; xfce_randr->relation[n] = XFCE_RANDR_PLACEMENT_MIRROR; xfce_randr->related_to[n] = active_output; @@ -1130,7 +1133,15 @@ display_setting_mirror_displays_toggled (GtkToggleButton *togglebutton, } else { - /* Deactivate mirror-mode */ + /* Deactivate mirror-mode, use the preferred mode of each output */ + for (n = 0; n < xfce_randr->noutput; n++) + { + xfce_randr->mode[n] = xfce_randr_preferred_mode (xfce_randr, n); + xfce_randr_save_output (xfce_randr, "Default", display_channel, + n, TRUE); + } + + xfce_randr_apply (xfce_randr, "Default", display_channel); /* Re-enable the position comboboxes */ gtk_widget_set_sensitive (GTK_WIDGET (positions), TRUE); diff --git a/dialogs/display-settings/xfce-randr.c b/dialogs/display-settings/xfce-randr.c index b9baaff..c114824 100644 --- a/dialogs/display-settings/xfce-randr.c +++ b/dialogs/display-settings/xfce-randr.c @@ -69,48 +69,6 @@ static gchar *xfce_randr_friendly_name (XfceRandr *randr, -static void -xfce_randr_list_clone_modes (XfceRandr *randr) -{ - GArray *clone_modes; - gint l, n, candidate, found; - guint m; - - clone_modes = g_array_new (TRUE, FALSE, sizeof (RRMode)); - - /* walk all available modes */ - for (n = 0; n < randr->priv->resources->nmode; ++n) - { - candidate = TRUE; - /* walk all connected outputs */ - for (m = 0; m < randr->noutput; ++m) - { - found = FALSE; - /* walk supported modes from this output */ - for (l = 0; l < randr->priv->output_info[m]->nmode; ++l) - { - if (randr->priv->resources->modes[n].id == randr->priv->output_info[m]->modes[l]) - { - found = TRUE; - break; - } - } - - /* if it is not present in one output, forget it */ - candidate &= found; - } - - /* common to all outputs, can be used for clone mode */ - if (candidate) - clone_modes = g_array_append_val (clone_modes, randr->priv->resources->modes[n].id); - } - - /* return a "normal" array (last value -> None) */ - randr->clone_modes = (RRMode *) g_array_free (clone_modes, FALSE); -} - - - static Rotation xfce_randr_get_safe_rotations (XfceRandr *randr, Display *xdisplay, @@ -365,9 +323,6 @@ xfce_randr_populate (XfceRandr *randr, randr->friendly_name[m] = xfce_randr_friendly_name (randr, m); } - /* clone modes: same RRModes present for all outputs */ - xfce_randr_list_clone_modes (randr); - /* calculate relations from positions */ xfce_randr_guess_relations (randr); } @@ -448,7 +403,6 @@ xfce_randr_cleanup (XfceRandr *randr) /* free the settings */ g_free (randr->friendly_name); - g_free (randr->clone_modes); g_free (randr->mode); g_free (randr->priv->modes); g_free (randr->rotation); @@ -767,6 +721,46 @@ xfce_randr_preferred_mode (XfceRandr *randr, +RRMode +xfce_randr_clonable_mode (XfceRandr *randr) +{ + gint l, n, candidate, found; + guint m; + + g_return_val_if_fail (randr != NULL, None); + + /* walk all available modes */ + for (n = 0; n < randr->priv->resources->nmode; ++n) + { + candidate = TRUE; + /* walk all connected outputs */ + for (m = 0; m < randr->noutput; ++m) + { + found = FALSE; + /* walk supported modes from this output */ + for (l = 0; l < randr->priv->output_info[m]->nmode; ++l) + { + if (randr->priv->resources->modes[n].id == randr->priv->output_info[m]->modes[l]) + { + found = TRUE; + break; + } + } + + /* if it is not present in one output, forget it */ + candidate &= found; + } + + /* common to all outputs, can be used for clone mode */ + if (candidate) + return randr->priv->resources->modes[n].id; + } + + return None; +} + + + const XfceRRMode * xfce_randr_get_modes (XfceRandr *randr, guint output, diff --git a/dialogs/display-settings/xfce-randr.h b/dialogs/display-settings/xfce-randr.h index 87eaa3d..2a5ba4c 100644 --- a/dialogs/display-settings/xfce-randr.h +++ b/dialogs/display-settings/xfce-randr.h @@ -68,9 +68,6 @@ struct _XfceRandr /* number of connected outputs */ guint noutput; - /* modes common to all connected outputs */ - RRMode *clone_modes; - /* selected settings for all connected outputs */ RRMode *mode; Rotation *rotation; @@ -114,6 +111,8 @@ const XfceRRMode *xfce_randr_find_mode_by_id (XfceRandr *randr, RRMode xfce_randr_preferred_mode (XfceRandr *randr, guint output); +RRMode xfce_randr_clonable_mode (XfceRandr *randr); + const XfceRRMode *xfce_randr_get_modes (XfceRandr *randr, guint output, gint *nmode); _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org https://mail.xfce.org/mailman/listinfo/xfce4-commits