diff src/video/x11/SDL_x11video.c @ 1248:d2c6881935be

Catch X11 extension errors...since most of these are notifications that we queried for a missing extension (such as the XiG vidmode one that most people don't have), and default Xlib behaviour is to write notification to stderr, this tends to generate incorrect bug reports. Since we'll actually deal with the missing extension when querying for it, we ignore these errors in our hook. The rest continue to pass through to the default handler. Fixes Bugzilla #42. --ryan.
author Ryan C. Gordon <icculus@icculus.org>
date Sat, 14 Jan 2006 08:15:38 +0000
parents aac47040c6d7
children 2bf9dda618e5
line wrap: on
line diff
--- a/src/video/x11/SDL_x11video.c	Fri Jan 13 02:36:35 2006 +0000
+++ b/src/video/x11/SDL_x11video.c	Sat Jan 14 08:15:38 2006 +0000
@@ -220,7 +220,7 @@
 	       (e->error_code <= (vm_error+XF86VidModeNumberErrors)))) ) {
 #ifdef XFREE86_DEBUG
 { char errmsg[1024];
-  XGetErrorText(d, e->error_code, errmsg, sizeof(errmsg));
+  pXGetErrorText(d, e->error_code, errmsg, sizeof(errmsg));
 printf("VidMode error: %s\n", errmsg);
 }
 #endif
@@ -235,7 +235,7 @@
 	      (e->error_code <= (dga_error+XF86DGANumberErrors))) ) {
 #ifdef XFREE86_DEBUG
 { char errmsg[1024];
-  XGetErrorText(d, e->error_code, errmsg, sizeof(errmsg));
+  pXGetErrorText(d, e->error_code, errmsg, sizeof(errmsg));
 printf("DGA error: %s\n", errmsg);
 }
 #endif
@@ -262,6 +262,28 @@
 	return(XIO_handler(d));
 }
 
+static int (*Xext_handler)(Display *,char *,char *) = NULL;
+static int xext_errhandler(Display *d, char *ext_name, char *reason)
+{
+#ifdef XFREE86_DEBUG
+	printf("Xext error inside SDL (may be harmless):\n");
+	printf("  Extension \"%s\" %s on display \"%s\".\n",
+	       ext_name, reason, pXDisplayString(d));
+#endif
+
+	if (strcmp(reason, "missing") == 0) {
+		/*
+		 * Since the query itself, elsewhere, can handle a missing extension
+		 *  and the default behaviour in Xlib is to write to stderr, which
+		 *  generates unnecessary bug reports, we just ignore these.
+		 */
+		return 0;
+	}
+
+	/* Everything else goes to the default handler... */
+	return Xext_handler(d, ext_name, reason);
+}
+
 /* Create auxiliary (toplevel) windows with the current visual */
 static void create_aux_windows(_THIS)
 {
@@ -438,6 +460,9 @@
 	/* Set the error handler if we lose the X display */
 	XIO_handler = pXSetIOErrorHandler(xio_errhandler);
 
+	/* Set the X extension error handler */
+	Xext_handler = pXSetExtensionErrorHandler(xext_errhandler);
+
 	/* use default screen (from $DISPLAY) */
 	SDL_Screen = DefaultScreen(SDL_Display);