src/video/x11/SDL_x11dyn.c
branchSDL-1.2
changeset 6225 e1264a758d50
parent 6137 4720145f848b
     1.1 --- a/src/video/x11/SDL_x11dyn.c	Mon Jan 16 14:27:47 2012 -0500
     1.2 +++ b/src/video/x11/SDL_x11dyn.c	Wed Jan 18 03:03:23 2012 -0500
     1.3 @@ -112,6 +112,21 @@
     1.4  #undef SDL_X11_SYM
     1.5  
     1.6  
     1.7 +static void *SDL_XGetRequest_workaround(Display* dpy, CARD8 type, size_t len)
     1.8 +{
     1.9 +	xReq *req;
    1.10 +	WORD64ALIGN
    1.11 +	if (dpy->bufptr + len > dpy->bufmax)
    1.12 +		_XFlush(dpy);
    1.13 +	dpy->last_req = dpy->bufptr;
    1.14 +	req = (xReq*)dpy->bufptr;
    1.15 +	req->reqType = type;
    1.16 +	req->length = len / 4;
    1.17 +	dpy->bufptr += len;
    1.18 +	dpy->request++;
    1.19 +	return req;
    1.20 +}
    1.21 +
    1.22  static int x11_load_refcount = 0;
    1.23  
    1.24  void SDL_X11_UnloadSymbols(void)
    1.25 @@ -174,6 +189,15 @@
    1.26  		                                                 &SDL_X11_HAVE_UTF8);
    1.27  		#endif
    1.28  
    1.29 +		/*
    1.30 +		 * In case we're built with newer Xlib headers, we need to make sure
    1.31 +		 *  that _XGetRequest() is available, even on older systems.
    1.32 +		 *  Otherwise, various Xlib macros we use will call a NULL pointer.
    1.33 +		 */
    1.34 +		if (!SDL_X11_HAVE_XGETREQUEST) {
    1.35 +			p_XGetRequest = SDL_XGetRequest_workaround;
    1.36 +		}
    1.37 +
    1.38  		if (SDL_X11_HAVE_BASEXLIB) {  /* all required symbols loaded. */
    1.39  			SDL_ClearError();
    1.40  		} else {