[Xfce4-commits] <xfce4-settings:master> Store clone modes
Nick Schermer
noreply at xfce.org
Sat Aug 28 23:04:21 CEST 2010
Updating branch refs/heads/master
to eea68a7cb1a5f076bf06802e34983b322100ee48 (commit)
from 9efeb32df1ce7ebd6d7445323edca73e312cbf33 (commit)
commit eea68a7cb1a5f076bf06802e34983b322100ee48
Author: Lionel Le Folgoc <mrpouit at gmail.com>
Date: Tue Jun 15 21:54:18 2010 +0200
Store clone modes
These modes are supported by all connected/active outputs, and therefore can be
used when the user wants to have cloned outputs.
dialogs/display-settings/xfce-randr.c | 54 +++++++++++++++++++++++++++++++++
dialogs/display-settings/xfce-randr.h | 3 ++
2 files changed, 57 insertions(+), 0 deletions(-)
diff --git a/dialogs/display-settings/xfce-randr.c b/dialogs/display-settings/xfce-randr.c
index 8f968dd..f967855 100644
--- a/dialogs/display-settings/xfce-randr.c
+++ b/dialogs/display-settings/xfce-randr.c
@@ -36,6 +36,56 @@
#ifdef HAS_RANDR_ONE_POINT_TWO
+static void
+xfce_randr_get_clone_modes (XfceRandr *randr)
+{
+ GArray *clone_modes;
+ gint l, m, n, candidate, found;
+ guint i;
+
+ clone_modes = g_array_new (FALSE, FALSE, sizeof (RRMode));
+
+ /* walk all available modes */
+ for (n = 0; n < randr->resources->nmode; n++)
+ {
+ candidate = TRUE;
+ /* walk all active outputs */
+ for (m = 0; m < randr->resources->noutput; m++)
+ {
+ if (randr->status[m] == XFCE_OUTPUT_STATUS_NONE)
+ continue;
+
+ found = FALSE;
+ /* walk supported modes from this output */
+ for (l = 0; l < randr->output_info[m]->nmode; l++)
+ {
+ if (randr->resources->modes[n].id == randr->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->resources->modes[n].id);
+ }
+
+ /* return a "normal" array (last value -> None) */
+ randr->clone_modes = g_new0 (RRMode, clone_modes->len + 1);
+
+ for (i = 0; i < clone_modes->len; i++)
+ randr->clone_modes[i] = g_array_index (clone_modes, RRMode, i);
+
+ g_array_free (clone_modes, TRUE);
+}
+
+
+
static Rotation
xfce_randr_get_safe_rotations (XfceRandr *randr,
Display *xdisplay,
@@ -150,6 +200,8 @@ xfce_randr_populate (XfceRandr *randr,
root_window, n);
}
+ xfce_randr_get_clone_modes (randr);
+
return TRUE;
}
@@ -228,6 +280,7 @@ xfce_randr_free (XfceRandr *randr)
XRRFreeScreenResources (randr->resources);
/* free the settings */
+ g_free (randr->clone_modes);
g_free (randr->mode);
g_free (randr->preferred_mode);
g_free (randr->rotation);
@@ -258,6 +311,7 @@ xfce_randr_reload (XfceRandr *randr)
XRRFreeScreenResources (randr->resources);
/* free the settings */
+ g_free (randr->clone_modes);
g_free (randr->mode);
g_free (randr->preferred_mode);
g_free (randr->rotation);
diff --git a/dialogs/display-settings/xfce-randr.h b/dialogs/display-settings/xfce-randr.h
index 9eaae46..1b354b2 100644
--- a/dialogs/display-settings/xfce-randr.h
+++ b/dialogs/display-settings/xfce-randr.h
@@ -96,6 +96,9 @@ struct _XfceRandr
/* selected display layout */
XfceDisplayLayout layout;
+ /* modes common to all enabled outputs */
+ RRMode *clone_modes;
+
/* selected settings for all outputs */
RRMode *mode;
RRMode *preferred_mode;
More information about the Xfce4-commits
mailing list