File gnome-settings-daemon-bnc519800-randr-ignore-impossible-configurations.diff of Package gnome-settings-daemon
From 8be81e74c98bb5c8d6856b4b57aee18d1739b6c7 Mon Sep 17 00:00:00 2001
From: Federico Mena Quintero <federico@novell.com>
Date: Tue, 14 Jul 2009 14:33:44 -0500
Subject: [PATCH 1/2] 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);
--
1.6.0.2
From 3641675e267e145403c6bb289e53d72c78b29480 Mon Sep 17 00:00:00 2001
From: Federico Mena Quintero <federico@novell.com>
Date: Wed, 15 Jul 2009 12:33:38 -0500
Subject: [PATCH 2/2] RANDR - only use applicable configurations when auto-configuring outputs during hotplug
Like in the previous commit, we would generate a configuration automatically,
but we didn't check if it was actually applicable. We don't want auto-
configuration to cause spurious errors to be presented to the user, so now we
first check if auto-generated configurations are applicable.
Signed-off-by: Federico Mena Quintero <federico@novell.com>
---
plugins/xrandr/gsd-xrandr-manager.c | 44 +++++++++++++++++++++++++++++++---
1 files changed, 40 insertions(+), 4 deletions(-)
diff --git a/plugins/xrandr/gsd-xrandr-manager.c b/plugins/xrandr/gsd-xrandr-manager.c
index ac892f7..82a91ff 100644
--- a/plugins/xrandr/gsd-xrandr-manager.c
+++ b/plugins/xrandr/gsd-xrandr-manager.c
@@ -978,6 +978,7 @@ auto_configure_outputs (GsdXrandrManager *manager, guint32 timestamp)
GList *l;
int x;
GError *error;
+ gboolean applicable;
config = gnome_rr_config_new_current (priv->rw_screen);
@@ -1050,12 +1051,47 @@ auto_configure_outputs (GsdXrandrManager *manager, guint32 timestamp)
x += output->width;
}
- /* Apply the configuration! */
+ /* Check if we have a large enough framebuffer size. If not, turn off
+ * outputs from right to left until we reach a usable size.
+ */
- error = NULL;
- if (!gnome_rr_config_apply_with_time (config, priv->rw_screen, timestamp, &error)) {
- error_message (manager, _("Could not switch the monitor configuration"), error, NULL);
+ just_turned_on = g_list_reverse (just_turned_on); /* now the outputs here are from right to left */
+
+ l = just_turned_on;
+ while (1) {
+ GnomeOutputInfo *output;
+ gboolean is_bounds_error;
+
+ error = NULL;
+ applicable = gnome_rr_config_applicable (config, priv->rw_screen, &error);
+
+ if (applicable)
+ break;
+
+ is_bounds_error = g_error_matches (error, GNOME_RR_ERROR, GNOME_RR_ERROR_BOUNDS_ERROR);
g_error_free (error);
+
+ if (!is_bounds_error)
+ break;
+
+ if (l) {
+ i = GPOINTER_TO_INT (l->data);
+ l = l->next;
+
+ output = config->outputs[i];
+ output->on = FALSE;
+ } else
+ break;
+ }
+
+ /* Apply the configuration! */
+
+ if (applicable) {
+ error = NULL;
+ if (!gnome_rr_config_apply_with_time (config, priv->rw_screen, timestamp, &error)) {
+ error_message (manager, _("Could not switch the monitor configuration"), error, NULL);
+ g_error_free (error);
+ }
}
g_list_free (just_turned_on);
--
1.6.0.2