[Xfce4-commits] <xfce4-settings:master> Whent the stored resolution	is None, really disable the output
    Nick Schermer 
    noreply at xfce.org
       
    Sat Aug 28 23:02:13 CEST 2010
    
    
  
Updating branch refs/heads/master
         to efdbd4cb8c5410940dcefb67006c19e2669a9da5 (commit)
       from 5f5cec30beab5981f95911cabc7079fde9b80ef2 (commit)
commit efdbd4cb8c5410940dcefb67006c19e2669a9da5
Author: Lionel Le Folgoc <mrpouit at gmail.com>
Date:   Sat Jun 5 23:10:54 2010 +0200
    Whent the stored resolution is None, really disable the output
    
    The correct way to disable an output is apparently to remove it from the list
    of outputs connected to the selected CRTC.
 xfce4-settings-helper/displays.c |   28 ++++++++++++++++++++++++++--
 1 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/xfce4-settings-helper/displays.c b/xfce4-settings-helper/displays.c
index 8bb79b8..c9b3e1d 100644
--- a/xfce4-settings-helper/displays.c
+++ b/xfce4-settings-helper/displays.c
@@ -174,7 +174,7 @@ xfce_displays_helper_channel_apply (XfceDisplaysHelper *helper,
     GdkWindow          *root_window;
     XRRScreenResources *resources;
     gchar               property[512];
-    gint                l, m, n, num_outputs, output_rot;
+    gint                l, m, n, num_outputs, output_rot, noutput;
 #ifdef HAS_RANDR_ONE_POINT_THREE
     gint                is_primary;
 #endif
@@ -186,6 +186,7 @@ xfce_displays_helper_channel_apply (XfceDisplaysHelper *helper,
     gdouble             rate;
     RRMode              mode;
     Rotation            rot;
+    RROutput           *outputs;
 
     /* flush x and trap errors */
     gdk_flush ();
@@ -294,10 +295,33 @@ 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;
+                    }
+
                     if (XRRSetCrtcConfig (xdisplay, resources, output_info->crtc,
                                           crtc_info->timestamp, crtc_info->x, crtc_info->y,
-                                          mode, rot, crtc_info->outputs, crtc_info->noutput) != Success)
+                                          mode, rot, outputs, noutput) != Success)
                         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