[gnome-settings-daemon] RANDR - only use applicable configurations for switching with the XF86Display hotkey



commit 50e6bb0778dc5f87db57dc5a12b82563921f6c1b
Author: Federico Mena Quintero <federico novell com>
Date:   Tue Jul 14 14:33:44 2009 -0500

    RANDR - only use applicable configurations for switching with the XF86Display hotkey
    
    We were not validating the generated configurations with gnome_rr_config_applicable(),
    so we could run into configurations that did not fit in the X server's
    Virtual size.
    
    This bug started as https://bugzilla.novell.com/show_bug.cgi?id=519800.
    
    Signed-off-by: Federico Mena Quintero <federico novell com>

 plugins/xrandr/gsd-xrandr-manager.c |   26 ++++++++++++++++++++++++--
 1 files changed, 24 insertions(+), 2 deletions(-)
---
diff --git a/plugins/xrandr/gsd-xrandr-manager.c b/plugins/xrandr/gsd-xrandr-manager.c
index ee5ddf3..ac892f7 100644
--- a/plugins/xrandr/gsd-xrandr-manager.c
+++ b/plugins/xrandr/gsd-xrandr-manager.c
@@ -695,7 +695,7 @@ make_other_setup (GnomeRRScreen *screen)
 }
 
 static GPtrArray *
-sanitize (GPtrArray *array)
+sanitize (GsdXrandrManager *manager, GPtrArray *array)
 {
         int i;
         GPtrArray *new;
@@ -741,12 +741,34 @@ sanitize (GPtrArray *array)
                         }
 
                         if (all_off) {
+                                g_debug ("removing configuration as all outputs are off");
                                 gnome_rr_config_free (array->pdata[i]);
                                 array->pdata[i] = NULL;
                         }
                 }
         }
 
+        /* Do a final sanitization pass.  This will remove configurations that
+         * don't fit in the framebuffer's Virtual size.
+         */
+
+        for (i = 0; i < array->len; i++) {
+                GnomeRRConfig *config = array->pdata[i];
+
+                if (config) {
+                        GError *error;
+
+                        error = NULL;
+                        if (!gnome_rr_config_applicable (config, manager->priv->rw_screen, &error)) { /* NULL-GError */
+                                g_debug ("removing configuration which is not applicable because %s", error->message);
+                                g_error_free (error);
+
+                                gnome_rr_config_free (config);
+                                array->pdata[i] = NULL;
+                        }
+                }
+        }
+
         /* Remove NULL configurations */
         new = g_ptr_array_new ();
 
@@ -796,7 +818,7 @@ generate_fn_f7_configs (GsdXrandrManager *mgr)
         g_ptr_array_add (array, make_other_setup (screen));
         g_ptr_array_add (array, gnome_rr_config_new_stored (screen, NULL)); /* NULL-GError - if this can't read the stored config, no big deal */
 
-        array = sanitize (array);
+        array = sanitize (mgr, array);
 
         if (array) {
                 mgr->priv->fn_f7_configs = (GnomeRRConfig **)g_ptr_array_free (array, FALSE);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]