[Xfce4-commits] <xfce4-settings:xrandr-display-settings> Save outputs to xfconf in two passes

Jérôme Guelfucci noreply at xfce.org
Sat Jun 26 21:26:03 CEST 2010


Updating branch refs/heads/xrandr-display-settings
         to 5cec7176b9f4bfb4a422c174176aab369cd9b07d (commit)
       from db1a1b95047fd93c840fa3720a5b944b5e42aa0b (commit)

commit 5cec7176b9f4bfb4a422c174176aab369cd9b07d
Author: Lionel Le Folgoc <mrpouit at gmail.com>
Date:   Sat Jun 26 17:04:39 2010 +0200

    Save outputs to xfconf in two passes
    
    The first pass saves only active outputs, and the second one disabled outputs.
    This improves the active outputs' tracking of the previous commit.

 dialogs/display-settings/xfce-randr.c |   22 +++++++++++++++++++---
 1 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/dialogs/display-settings/xfce-randr.c b/dialogs/display-settings/xfce-randr.c
index 69d137a..25416ad 100644
--- a/dialogs/display-settings/xfce-randr.c
+++ b/dialogs/display-settings/xfce-randr.c
@@ -475,7 +475,7 @@ xfce_randr_save (XfceRandr     *randr,
                  XfconfChannel *channel)
 {
     gchar        property[512];
-    guint        n;
+    guint        n, nsaved;
 
     g_return_if_fail (XFCONF_IS_CHANNEL (channel));
 
@@ -483,13 +483,29 @@ xfce_randr_save (XfceRandr     *randr,
     g_snprintf (property, sizeof (property), "/%s/Layout", scheme);
     xfconf_channel_set_string (channel, property, "Outputs");
 
-    /* save connected outputs */
+    /* first pass: save connected and active outputs */
+    nsaved = 0;
     for (n = 0; n < randr->noutput; ++n)
     {
-        g_snprintf (property, sizeof (property), "Output%u", n);
+        if (randr->mode[n] == None)
+            continue;
+
+        g_snprintf (property, sizeof (property), "Output%u", nsaved++);
+        xfce_randr_save_device (randr, scheme, channel, n, property);
+    }
+
+    /* second pass: save connected and disabled outputs */
+    for (n = 0; n < randr->noutput; ++n)
+    {
+        if (randr->mode[n] != None)
+            continue;
+
+        g_snprintf (property, sizeof (property), "Output%u", nsaved++);
         xfce_randr_save_device (randr, scheme, channel, n, property);
     }
 
+    g_assert_cmpuint (nsaved, ==, randr->noutput);
+
     /* store the number of outputs saved */
     g_snprintf (property, sizeof (property), "/%s/NumOutputs", scheme);
     xfconf_channel_set_int (channel, property, randr->noutput);



More information about the Xfce4-commits mailing list