[Xfce4-commits] <xfce4-settings:xrandr-display-settings> Simplify the case when an output has to be disabled

Jérôme Guelfucci noreply at xfce.org
Thu Jun 10 11:28:02 CEST 2010


Updating branch refs/heads/xrandr-display-settings
         to 8e17715cf8074a03ec5ff9d7371ddb6e12d3b3b8 (commit)
       from 0765e3b70ee82cf5bc05ae213fa862d725a1aea6 (commit)

commit 8e17715cf8074a03ec5ff9d7371ddb6e12d3b3b8
Author: Lionel Le Folgoc <mrpouit at gmail.com>
Date:   Tue Jun 8 22:07:33 2010 +0200

    Simplify the case when an output has to be disabled

 xfce4-settings-helper/displays.c |   75 +++++++++++++++++++-------------------
 1 files changed, 38 insertions(+), 37 deletions(-)

diff --git a/xfce4-settings-helper/displays.c b/xfce4-settings-helper/displays.c
index 59ffb83..4c00d51 100644
--- a/xfce4-settings-helper/displays.c
+++ b/xfce4-settings-helper/displays.c
@@ -165,6 +165,24 @@ xfce_displays_helper_finalize (GObject *object)
 
 
 #ifdef HAS_RANDR_ONE_POINT_TWO
+static Status
+xfce_displays_helper_disable_crtc (Display            *xdisplay,
+                                   XRRScreenResources *resources,
+                                   RRCrtc              crtc)
+{
+    g_return_val_if_fail (xdisplay != NULL, RRSetConfigSuccess);
+    g_return_val_if_fail (resources != NULL, RRSetConfigSuccess);
+
+    /* already disabled */
+    if (crtc == None)
+        return RRSetConfigSuccess;
+
+    return XRRSetCrtcConfig (xdisplay, resources, crtc, CurrentTime,
+                             0, 0, None, RR_Rotate_0, NULL, 0);
+}
+
+
+
 static void
 xfce_displays_helper_channel_apply (XfceDisplaysHelper *helper,
                                     const gchar        *scheme)
@@ -176,7 +194,7 @@ xfce_displays_helper_channel_apply (XfceDisplaysHelper *helper,
     gchar               property[512];
     gint                min_width, min_height, max_width, max_height;
     gint                mm_width, mm_height, width, height;
-    gint                j, l, m, n, num_outputs, output_rot, noutput;
+    gint                j, l, m, n, num_outputs, output_rot;
 #ifdef HAS_RANDR_ONE_POINT_THREE
     gint                is_primary;
 #endif
@@ -188,7 +206,6 @@ xfce_displays_helper_channel_apply (XfceDisplaysHelper *helper,
     gdouble             rate;
     RRMode              mode;
     Rotation            rot;
-    RROutput           *outputs;
 
     /* flush x and trap errors */
     gdk_flush ();
@@ -271,6 +288,17 @@ xfce_displays_helper_channel_apply (XfceDisplaysHelper *helper,
                 continue;
             }
 
+            /* outputs that have to be disabled are stored without resolution */
+            if (output_res == NULL)
+            {
+                if (xfce_displays_helper_disable_crtc (xdisplay, resources,
+                                                       output_info->crtc) != RRSetConfigSuccess)
+                    g_warning ("Failed to disable CRTC for output %s.", output_info->name);
+
+                XRRFreeOutputInfo (output_info);
+                break;
+            }
+
             /* walk supported modes */
             mode = None;
             for (l = 0; l < output_info->nmode; ++l)
@@ -303,7 +331,7 @@ xfce_displays_helper_channel_apply (XfceDisplaysHelper *helper,
             }
 
             /* unsupported mode, abort for this output */
-            if (mode == None && output_res != NULL)
+            if (mode == None)
             {
                 XRRFreeOutputInfo (output_info);
                 break;
@@ -324,45 +352,18 @@ xfce_displays_helper_channel_apply (XfceDisplaysHelper *helper,
                 /* check if we really need to do something */
                 if (crtc_info->mode != mode || crtc_info->rotation != rot)
                 {
-                    /* resolution was NULL, so the user wants to disable this output */
-                    if (mode == None)
-                    {
-                        outputs = g_new0 (RROutput, crtc_info->noutput - 1);
-                        noutput = 0;
-                        /* to disable the output, remove it from the list of outputs connected to this crtc */
-                        for (l = 0; l < crtc_info->noutput; ++l)
-                        {
-                            if (crtc_info->outputs[l] == resources->outputs[m])
-                                continue;
-
-                            outputs[noutput++] = crtc_info->outputs[l];
-                        }
-                    }
-                    else
-                    {
-                        noutput = crtc_info->noutput;
-                        outputs = crtc_info->outputs;
-                    }
+                    /* get the "physical sizes" of the output */
+                    mm_width += output_info->mm_width;
+                    mm_height += output_info->mm_height;
 
-                    /* do not change the screen size if the output is going to be disabled */
-                    if (mode != None)
-                    {
-                        /* get the "physical sizes" of the output */
-                        mm_width += output_info->mm_width;
-                        mm_height += output_info->mm_height;
-
-                        /* get the sizes of the mode to enforce */
-                        width += resources->modes[j].width;
-                        height += resources->modes[j].height;
-                    }
+                    /* get the sizes of the mode to enforce */
+                    width += resources->modes[j].width;
+                    height += resources->modes[j].height;
 
                     if (XRRSetCrtcConfig (xdisplay, resources, output_info->crtc,
                                           crtc_info->timestamp, crtc_info->x, crtc_info->y,
-                                          mode, rot, outputs, noutput) != RRSetConfigSuccess)
+                                          mode, rot, crtc_info->outputs, crtc_info->noutput) != RRSetConfigSuccess)
                         g_warning ("Failed to configure %s.", output_info->name);
-
-                    if (mode == None)
-                        g_free (outputs);
                 }
 
                 XRRFreeCrtcInfo (crtc_info);



More information about the Xfce4-commits mailing list