[Xfce4-commits] <xfce4-settings:master> Fix invalid desktop size when disabling a monitor (bug #7413).

Jérôme Guelfucci noreply at xfce.org
Sat Mar 19 14:20:04 CET 2011


Updating branch refs/heads/master
         to 0d6c37017243d5c64f730c093556433c2a0b0ad2 (commit)
       from 5f984a4acb945d5e39c461a3e29cbabfc2a959f4 (commit)

commit 0d6c37017243d5c64f730c093556433c2a0b0ad2
Author: Sean <sean at middleditch.us>
Date:   Sat Mar 19 14:00:36 2011 +0100

    Fix invalid desktop size when disabling a monitor (bug #7413).
    
    Initial patch reworked by Lionel Le Folgoc to only compute the mode size
    for outputs that won't be disabled.

 xfsettingsd/displays.c |   63 +++++++++++++++++++++++++++++++----------------
 1 files changed, 41 insertions(+), 22 deletions(-)

diff --git a/xfsettingsd/displays.c b/xfsettingsd/displays.c
index 5624131..5537aa3 100644
--- a/xfsettingsd/displays.c
+++ b/xfsettingsd/displays.c
@@ -491,6 +491,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, mode_height, mode_width;
+    gint                min_x, min_y;
     gint                l, m, output_rot, nactive;
     guint               n;
     GValue             *value;
@@ -515,6 +516,7 @@ xfce_displays_helper_channel_apply (XfceDisplaysHelper *helper,
 
     /* get the range of screen sizes */
     mm_width = mm_height = width = height = 0;
+    min_x = min_y = 32768;
     if (!XRRGetScreenSizeRange (xdisplay, GDK_WINDOW_XID (root_window),
                                 &min_width, &min_height, &max_width, &max_height))
     {
@@ -690,6 +692,10 @@ xfce_displays_helper_channel_apply (XfceDisplaysHelper *helper,
             pending->y = g_value_get_int (value);
         else
             pending->y = 0;
+
+        /* normalize positions to ensure the upper left corner is at (0,0) */
+        min_x = MIN (min_x, pending->x);
+        min_y = MIN (min_y, pending->y);
     }
 
     /* safety check */
@@ -736,33 +742,42 @@ xfce_displays_helper_channel_apply (XfceDisplaysHelper *helper,
             xfce_displays_helper_set_outputs (crtc, output);
 
             mode_height = mode_width = 0;
-            /* get the sizes of the mode to enforce */
-            for (m = 0; m < resources->nmode; ++m)
+            /* get the sizes of the mode to enforce, but ignore to-be-disabled outputs */
+            if (output->pending->mode != None)
             {
-                /* get the mode info */
-                mode_info = &resources->modes[m];
+                for (m = 0; m < resources->nmode; ++m)
+                {
+                    /* get the mode info */
+                    mode_info = &resources->modes[m];
 
-                /* does the mode info match the mode we seek? */
-                if (mode_info->id != output->pending->mode)
-                    continue;
+                    /* does the mode info match the mode we seek? */
+                    if (mode_info->id != output->pending->mode)
+                        continue;
 
-                /* store the dimensions */
-                mode_height = resources->modes[m].height;
-                mode_width = resources->modes[m].width;
-                break;
-            }
+                    /* store the dimensions */
+                    mode_height = resources->modes[m].height;
+                    mode_width = resources->modes[m].width;
+                    break;
+                }
 
+                /* move the output to a normalized position */
+                if (min_x || min_y)
+                {
+                    output->pending->x -= min_x;
+                    output->pending->y -= min_y;
+                }
 
-            if ((output->pending->rotation & (RR_Rotate_90|RR_Rotate_270)) != 0)
-                xfce_displays_helper_process_screen_size (mode_height, mode_width,
-                                                          output->pending->x,
-                                                          output->pending->y, &width,
-                                                          &height, &mm_width, &mm_height);
-            else
-                xfce_displays_helper_process_screen_size (mode_width, mode_height,
-                                                          output->pending->x,
-                                                          output->pending->y, &width,
-                                                          &height, &mm_width, &mm_height);
+                if ((output->pending->rotation & (RR_Rotate_90|RR_Rotate_270)) != 0)
+                    xfce_displays_helper_process_screen_size (mode_height, mode_width,
+                                                              output->pending->x,
+                                                              output->pending->y, &width,
+                                                              &height, &mm_width, &mm_height);
+                else
+                    xfce_displays_helper_process_screen_size (mode_width, mode_height,
+                                                              output->pending->x,
+                                                              output->pending->y, &width,
+                                                              &height, &mm_width, &mm_height);
+            }
 
             /* check if we really need to do something */
             if (crtc->mode != output->pending->mode
@@ -771,6 +786,8 @@ xfce_displays_helper_channel_apply (XfceDisplaysHelper *helper,
                 || crtc->y != output->pending->y
                 || crtc->noutput != output->pending->noutput)
             {
+                TRACE("Configuring %s: size=%dx%d, pos=%dx%d.", output->info->name, mode_width, mode_height,
+                                                                output->pending->x, output->pending->y);
                 if (xfce_displays_helper_apply_crtc (xdisplay, resources, crtc,
                                                      output->pending) != RRSetConfigSuccess)
                     g_warning ("Failed to configure %s.", output->info->name);
@@ -778,6 +795,8 @@ xfce_displays_helper_channel_apply (XfceDisplaysHelper *helper,
         }
     }
 
+    TRACE("Desktop dimensions: %dx%d (px), %dx%d (mm).", width, height, mm_width, mm_height);
+
     /* set the screen size only if it's really needed and valid */
     if (width >= min_width && width <= max_width
         && height >= min_height && height <= max_height



More information about the Xfce4-commits mailing list