[PATCH 2/15] gnome-desktop: Xerror Xrandr version checks



gnome-desktop:  103_gd-xrandr-xerror-check.patch (LP: #199960-attempt,
#197645)

Adds another NULL pointer check, for the screen argument to
configuration_apply_stored(), for situations where the system fails to
provide a valid Xrandr screen for configuration.

Also adds a check for Xrandr version 1.2 and gdk error traps.  The
checks are unnecessary on Ubuntu or Fedora since both distribute only
Xrandr 1.2 enabled servers, but the patch may be worthwhile for GNOME
users that wish to run against older X servers.

diff -Nurp gnome-desktop-2.22.0-patched/libgnome-desktop/monitor-db.c gnome-desktop-2.22.0-working/libgnome-desktop/monitor-db.c
--- gnome-desktop-2.22.0-patched/libgnome-desktop/monitor-db.c	2008-03-17 11:04:17.000000000 -0700
+++ gnome-desktop-2.22.0-working/libgnome-desktop/monitor-db.c	2008-03-17 14:49:59.000000000 -0700
@@ -780,6 +780,11 @@ configuration_apply_stored (RWScreen *sc
     Configuration *found;
     gboolean result;
 
+    if (!screen) {
+        g_print("No valid screens to apply stored configuration\n");
+        return FALSE;
+    }
+
     rw_screen_refresh (screen);
     
     current = configuration_new_current (screen);
diff -Nurp gnome-desktop-2.22.0-patched/libgnome-desktop/randrwrap.c gnome-desktop-2.22.0-working/libgnome-desktop/randrwrap.c
--- gnome-desktop-2.22.0-patched/libgnome-desktop/randrwrap.c	2008-03-17 11:04:17.000000000 -0700
+++ gnome-desktop-2.22.0-working/libgnome-desktop/randrwrap.c	2008-03-17 15:53:03.000000000 -0700
@@ -200,11 +200,25 @@ fill_out_screen_info (Display *xdisplay,
 {
     XRRScreenResources *resources;
 
-    XRRGetScreenSizeRange (xdisplay, xroot,
-			   &(info->min_width),
-			   &(info->min_height),
-			   &(info->max_width),
-			   &(info->max_height));
+    gdk_error_trap_push ();
+
+    if (!XRRGetScreenSizeRange (xdisplay, xroot,
+                                &(info->min_width),
+                                &(info->min_height),
+                                &(info->max_width),
+                                &(info->max_height))) {
+        /* XRR caught an error */
+        g_print("Error:  X was unable to determine screen size range for window %d\n", xroot);
+        return False;
+    }
+
+    gdk_flush ();
+    if (gdk_error_trap_pop ())
+    {
+        /* Unhandled X Error was generated */
+        g_print("Error:  X Error received when attempting to get screen size range for window %d\n", xroot);
+        return False;
+    }
 
 #if 0
     g_print ("ranges: %d - %d; %d - %d\n",
@@ -364,6 +378,9 @@ screen_on_event (GdkXEvent *xevent,
     return GDK_FILTER_CONTINUE;
 }
 
+/* Returns NULL if screen could not be created.  For instance, if driver
+ * does not support Xrandr 1.2.
+ */
 RWScreen *
 rw_screen_new (GdkScreen *gdk_screen,
 	       RWScreenChanged callback,


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