diff --git a/src/video/x11/SDL_x11dyn.h b/src/video/x11/SDL_x11dyn.h index 47d9e9838..15962cc2a 100644 --- a/src/video/x11/SDL_x11dyn.h +++ b/src/video/x11/SDL_x11dyn.h @@ -57,6 +57,7 @@ extern "C" { typedef Bool (*SDL_X11_XESetWireToEventRetType)(Display*,XEvent*,xEvent*); typedef int (*SDL_X11_XSynchronizeRetType)(Display*); typedef Status (*SDL_X11_XESetEventToWireRetType)(Display*,XEvent*,xEvent*); +typedef int (*SDL_X11_XSetExtensionErrorHandlerType)(Display *,char *,char *); #define SDL_X11_SYM(req,ret,fn,params) extern ret (*p##fn) params; #include "SDL_x11sym.h" diff --git a/src/video/x11/SDL_x11sym.h b/src/video/x11/SDL_x11sym.h index 1c88933fd..ce76ef349 100644 --- a/src/video/x11/SDL_x11sym.h +++ b/src/video/x11/SDL_x11sym.h @@ -113,6 +113,8 @@ SDL_X11_SYM(1,void,XextDestroyExtension,(XExtensionInfo*)) SDL_X11_SYM(1,XExtDisplayInfo*,XextFindDisplay,(XExtensionInfo*,Display*)) SDL_X11_SYM(1,int,XextRemoveDisplay,(XExtensionInfo*,Display*)) SDL_X11_SYM(1,Bool,XQueryExtension,(Display*,_Xconst char*,int*,int*,int*)) +SDL_X11_SYM(1,char *,XDisplayString,(Display*)) +SDL_X11_SYM(1,int,XGetErrorText,(Display*,int,char*,int)) #ifdef X_HAVE_UTF8_STRING SDL_X11_SYM(1,int,Xutf8TextListToTextProperty,(Display*,char**,int,XICCEncodingStyle,XTextProperty*)) @@ -159,6 +161,7 @@ SDL_X11_SYM(1,Bool,XShmQueryExtension,(Display*)) SDL_X11_SYM(1,SDL_X11_XSynchronizeRetType,XSynchronize,(Display*,Bool)) SDL_X11_SYM(1,SDL_X11_XESetWireToEventRetType,XESetWireToEvent,(Display*,int,SDL_X11_XESetWireToEventRetType)) SDL_X11_SYM(1,SDL_X11_XESetEventToWireRetType,XESetEventToWire,(Display*,int,SDL_X11_XESetEventToWireRetType)) +SDL_X11_SYM(1,SDL_X11_XSetExtensionErrorHandlerType,XSetExtensionErrorHandler,(SDL_X11_XSetExtensionErrorHandlerType)) /* end of SDL_x11sym.h ... */ diff --git a/src/video/x11/SDL_x11video.c b/src/video/x11/SDL_x11video.c index 888b50b0a..dd1e4517c 100644 --- a/src/video/x11/SDL_x11video.c +++ b/src/video/x11/SDL_x11video.c @@ -220,7 +220,7 @@ static int x_errhandler(Display *d, XErrorEvent *e) (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 @@ printf("VidMode error: %s\n", errmsg); (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 @@ static int xio_errhandler(Display *d) 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 @@ static int X11_VideoInit(_THIS, SDL_PixelFormat *vformat) /* 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);