Dynamically load X11 libraries like we currently do for alsa, esd, etc.
authorRyan C. Gordon <icculus@icculus.org>
Sat, 05 Nov 2005 19:53:37 +0000
changeset 1168045f186426e1
parent 1167 435c2e481299
child 1169 4b3e2294782d
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
This allows you to run an SDL program on a system without Xlib, since it'll
just report the x11 target unavailable at runtime.
configure.in
src/video/Xext/Xinerama/Xinerama.c
src/video/Xext/Xv/Xv.c
src/video/Xext/Xv/Xvlibint.h
src/video/Xext/Xxf86dga/XF86DGA.c
src/video/Xext/Xxf86dga/XF86DGA2.c
src/video/Xext/Xxf86vm/XF86VMode.c
src/video/Xext/extensions/extutil.h
src/video/dga/SDL_dgaevents.c
src/video/dga/SDL_dgavideo.c
src/video/x11/Makefile.am
src/video/x11/SDL_x11dyn.c
src/video/x11/SDL_x11dyn.h
src/video/x11/SDL_x11events.c
src/video/x11/SDL_x11gamma.c
src/video/x11/SDL_x11gl.c
src/video/x11/SDL_x11image.c
src/video/x11/SDL_x11modes.c
src/video/x11/SDL_x11mouse.c
src/video/x11/SDL_x11sym.h
src/video/x11/SDL_x11video.c
src/video/x11/SDL_x11video.h
src/video/x11/SDL_x11wm.c
src/video/x11/SDL_x11yuv.c
     1.1 --- a/configure.in	Sat Nov 05 17:41:11 2005 +0000
     1.2 +++ b/configure.in	Sat Nov 05 19:53:37 2005 +0000
     1.3 @@ -609,11 +609,45 @@
     1.4          AC_PATH_X
     1.5          AC_PATH_XTRA
     1.6          if test x$have_x = xyes; then
     1.7 -            CFLAGS="$CFLAGS $X_CFLAGS -DENABLE_X11 -DXTHREADS -I$srcdir/include -I$srcdir/src/video"
     1.8 +            AC_ARG_ENABLE(x11-shared,
     1.9 +[  --enable-x11-shared     dynamically load X11 support [default=yes]],
    1.10 +                          , enable_x11_shared=yes)
    1.11 +
    1.12 +            dnl !!! FIXME: make this work?
    1.13 +            dnl x11_lib_spec=`echo $X11_LIBS | sed 's/.*-L\([[^ ]]*\).*/\1\/libX11.so.*/'`
    1.14 +            dnl x11_lib=`ls $x11_lib_spec | sed 's/.*\/\(.*\)/\1/; q'`
    1.15 +            dnl echo "-- $x11_lib_spec -> $x11_lib"
    1.16 +            dnl x11ext_lib_spec=`echo $X11EXT_LIBS | sed 's/.*-L\([[^ ]]*\).*/\1\/libXext.so.*/'`
    1.17 +            dnl x11ext_lib=`ls $x11ext_lib_spec | sed 's/.*\/\(.*\)/\1/; q'`
    1.18 +            dnl echo "-- $x11ext_lib_spec -> $x11ext_lib"
    1.19 +
    1.20 +            x11_lib_spec='/usr/X11R6/lib/libX11.so.*'
    1.21 +            x11_lib='libX11.so.6'
    1.22 +            echo "-- $x11_lib_spec -> $x11_lib"
    1.23 +            x11ext_lib_spec='/usr/X11R6/lib/libXext.so.*'
    1.24 +            x11_lib='libXext.so.6'
    1.25 +            echo "-- $x11ext_lib_spec -> $x11_lib"
    1.26 +
    1.27 +            if test x$use_dlopen != xyes && \
    1.28 +               test x$enable_x11_shared = xyes; then
    1.29 +                AC_MSG_ERROR([You must have dlopen() support and use the --enable-dlopen option])
    1.30 +            fi
    1.31 +
    1.32 +            if test x$use_dlopen = xyes && \
    1.33 +               test x$enable_x11_shared = xyes && test x$x11_lib != x; then
    1.34 +                CFLAGS="$CFLAGS $X_CFLAGS -DENABLE_X11 -DXTHREADS -DX11_DYNAMIC=\$(x11_lib) -DX11EXT_DYNAMIC=\$(x11ext_lib) -I$srcdir/include -I$srcdir/src/video"
    1.35 +                SYSTEM_LIBS="$SYSTEM_LIBS $X_LIBS"
    1.36 +                AC_SUBST(x11_lib)
    1.37 +                AC_SUBST(x11ext_lib)
    1.38 +            else
    1.39 +                CFLAGS="$CFLAGS $X_CFLAGS -DENABLE_X11 -DXTHREADS -I$srcdir/include -I$srcdir/src/video"
    1.40 +                SYSTEM_LIBS="$SYSTEM_LIBS $X_LIBS -lX11 -lXext"
    1.41 +            fi
    1.42 +
    1.43              if test x$ac_cv_func_shmat != xyes; then
    1.44                  CFLAGS="$CFLAGS -DNO_SHARED_MEMORY"
    1.45              fi
    1.46 -            SYSTEM_LIBS="$SYSTEM_LIBS $X_LIBS -lX11 -lXext"
    1.47 +
    1.48              VIDEO_SUBDIRS="$VIDEO_SUBDIRS x11"
    1.49              VIDEO_DRIVERS="$VIDEO_DRIVERS x11/libvideo_x11.la"
    1.50  
     2.1 --- a/src/video/Xext/Xinerama/Xinerama.c	Sat Nov 05 17:41:11 2005 +0000
     2.2 +++ b/src/video/Xext/Xinerama/Xinerama.c	Sat Nov 05 19:53:37 2005 +0000
     2.3 @@ -35,6 +35,13 @@
     2.4  #include "panoramiXproto.h"		/* in ../include */
     2.5  #include "Xinerama.h"
     2.6  
     2.7 +#include "../../x11/SDL_x11dyn.h"
     2.8 +
     2.9 +/* Workaround code in headers... */
    2.10 +#define _XFlush p_XFlush
    2.11 +#define _XFlushGCCache p_XFlushGCCache
    2.12 +#define _XReply p_XReply
    2.13 +#define _XSend p_XSend
    2.14  
    2.15  static XExtensionInfo _panoramiX_ext_info_data;
    2.16  static XExtensionInfo *panoramiX_ext_info = &_panoramiX_ext_info_data;
    2.17 @@ -111,7 +118,7 @@
    2.18      req->panoramiXReqType = X_PanoramiXQueryVersion;
    2.19      req->clientMajor = PANORAMIX_MAJOR_VERSION;
    2.20      req->clientMinor = PANORAMIX_MINOR_VERSION;
    2.21 -    if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
    2.22 +    if (!p_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
    2.23  	UnlockDisplay (dpy);
    2.24  	SyncHandle ();
    2.25  	return 0;
    2.26 @@ -145,7 +152,7 @@
    2.27      req->reqType = info->codes->major_opcode;
    2.28      req->panoramiXReqType = X_PanoramiXGetState;
    2.29      req->window = drawable;
    2.30 -    if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
    2.31 +    if (!p_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
    2.32  	UnlockDisplay (dpy);
    2.33  	SyncHandle ();
    2.34  	return 0;
    2.35 @@ -174,7 +181,7 @@
    2.36      req->reqType = info->codes->major_opcode;
    2.37      req->panoramiXReqType = X_PanoramiXGetScreenCount;
    2.38      req->window = drawable;
    2.39 -    if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
    2.40 +    if (!p_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
    2.41  	UnlockDisplay (dpy);
    2.42  	SyncHandle ();
    2.43  	return 0;
    2.44 @@ -205,7 +212,7 @@
    2.45      req->panoramiXReqType = X_PanoramiXGetScreenSize;
    2.46      req->window = drawable;
    2.47      req->screen = screen_num;			/* need to define */ 
    2.48 -    if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
    2.49 +    if (!p_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
    2.50  	UnlockDisplay (dpy);
    2.51  	SyncHandle ();
    2.52  	return 0;
    2.53 @@ -285,7 +292,7 @@
    2.54      GetReq (XineramaQueryScreens, req);
    2.55      req->reqType = info->codes->major_opcode;
    2.56      req->panoramiXReqType = X_XineramaQueryScreens;
    2.57 -    if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) {
    2.58 +    if (!p_XReply (dpy, (xReply *) &rep, 0, xFalse)) {
    2.59  	UnlockDisplay (dpy);
    2.60  	SyncHandle ();
    2.61  	return NULL;
    2.62 @@ -297,7 +304,7 @@
    2.63  	    int i;
    2.64  
    2.65  	    for(i = 0; i < rep.number; i++) {
    2.66 -		_XRead(dpy, (char*)(&scratch), sz_XineramaScreenInfo);
    2.67 +		p_XRead(dpy, (char*)(&scratch), sz_XineramaScreenInfo);
    2.68  		scrnInfo[i].screen_number = i;
    2.69  		scrnInfo[i].x_org 	  = scratch.x_org;
    2.70  		scrnInfo[i].y_org 	  = scratch.y_org;
    2.71 @@ -307,7 +314,7 @@
    2.72  
    2.73  	    *number = rep.number;
    2.74  	} else
    2.75 -	    _XEatData(dpy, rep.length << 2);
    2.76 +	    p_XEatData(dpy, rep.length << 2);
    2.77      }
    2.78  
    2.79      UnlockDisplay (dpy);
     3.1 --- a/src/video/Xext/Xv/Xv.c	Sat Nov 05 17:41:11 2005 +0000
     3.2 +++ b/src/video/Xext/Xv/Xv.c	Sat Nov 05 19:53:37 2005 +0000
     3.3 @@ -56,6 +56,14 @@
     3.4  #include <X11/extensions/XShm.h>
     3.5  #include "extutil.h"
     3.6  
     3.7 +#include "../../x11/SDL_x11dyn.h"
     3.8 +
     3.9 +/* Workaround code in headers... */
    3.10 +#define _XFlush p_XFlush
    3.11 +#define _XFlushGCCache p_XFlushGCCache
    3.12 +#define _XReply p_XReply
    3.13 +#define _XSend p_XSend
    3.14 +
    3.15  static XExtensionInfo _xv_info_data;
    3.16  static XExtensionInfo *xv_info = &_xv_info_data;
    3.17  static char *xv_extension_name = XvName;
    3.18 @@ -121,7 +129,7 @@
    3.19  
    3.20    XvGetReq(QueryExtension, req);
    3.21  
    3.22 -  if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
    3.23 +  if (!p_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
    3.24       UnlockDisplay(dpy);
    3.25       SyncHandle();
    3.26       return XvBadExtension;
    3.27 @@ -171,7 +179,7 @@
    3.28  
    3.29    /* READ THE REPLY */
    3.30  
    3.31 -  if (_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) {
    3.32 +  if (p_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) {
    3.33        UnlockDisplay(dpy);
    3.34        SyncHandle();
    3.35        return(XvBadReply);
    3.36 @@ -183,7 +191,7 @@
    3.37        SyncHandle();
    3.38        return(XvBadAlloc);
    3.39    }
    3.40 -  _XRead (dpy, buffer, size);
    3.41 +  p_XRead (dpy, buffer, size);
    3.42  
    3.43    u.buffer = buffer;
    3.44  
    3.45 @@ -331,7 +339,7 @@
    3.46  
    3.47    /* READ THE REPLY */
    3.48  
    3.49 -  if (_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) {
    3.50 +  if (p_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) {
    3.51        UnlockDisplay(dpy);
    3.52        SyncHandle();
    3.53        return(XvBadReply);
    3.54 @@ -343,7 +351,7 @@
    3.55        SyncHandle();
    3.56        return(XvBadAlloc);
    3.57    }
    3.58 -  _XRead (dpy, buffer, size);
    3.59 +  p_XRead (dpy, buffer, size);
    3.60  
    3.61    u.buffer = buffer;
    3.62  
    3.63 @@ -619,7 +627,7 @@
    3.64    req->port = port;
    3.65    req->time = time;
    3.66  
    3.67 -  if (_XReply (dpy, (xReply *) &rep, 0, xTrue) == 0) 
    3.68 +  if (p_XReply (dpy, (xReply *) &rep, 0, xTrue) == 0) 
    3.69      rep.result = GrabSuccess;
    3.70  
    3.71    result = rep.result;
    3.72 @@ -747,7 +755,7 @@
    3.73  
    3.74    /* READ THE REPLY */
    3.75  
    3.76 -  if (_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) {
    3.77 +  if (p_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) {
    3.78        UnlockDisplay(dpy);
    3.79        SyncHandle();
    3.80        return(XvBadReply);
    3.81 @@ -792,7 +800,7 @@
    3.82  
    3.83    /* READ THE REPLY */
    3.84  
    3.85 -  if (_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) {
    3.86 +  if (p_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) {
    3.87        UnlockDisplay(dpy);
    3.88        SyncHandle();
    3.89        return(XvBadReply);
    3.90 @@ -827,7 +835,7 @@
    3.91  
    3.92    /* READ THE REPLY */
    3.93  
    3.94 -  if (_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) {
    3.95 +  if (p_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) {
    3.96        UnlockDisplay(dpy);
    3.97        SyncHandle();
    3.98        return ret;
    3.99 @@ -842,17 +850,17 @@
   3.100  	  int i;
   3.101  	
   3.102  	  for(i = 0; i < rep.num_attributes; i++) {
   3.103 -             _XRead(dpy, (char*)(&Info), sz_xvAttributeInfo);
   3.104 +             p_XRead(dpy, (char*)(&Info), sz_xvAttributeInfo);
   3.105  	      ret[i].flags = (int)Info.flags;	      
   3.106  	      ret[i].min_value = Info.min;	      
   3.107  	      ret[i].max_value = Info.max;	      
   3.108  	      ret[i].name = marker;
   3.109 -	      _XRead(dpy, marker, Info.size);
   3.110 +	      p_XRead(dpy, marker, Info.size);
   3.111  	      marker += Info.size;
   3.112  	      (*num)++;
   3.113  	  }
   3.114        } else
   3.115 -	_XEatData(dpy, rep.length << 2);
   3.116 +	p_XEatData(dpy, rep.length << 2);
   3.117    }
   3.118  
   3.119    UnlockDisplay(dpy);
   3.120 @@ -882,7 +890,7 @@
   3.121  
   3.122    /* READ THE REPLY */
   3.123  
   3.124 -  if (_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) {
   3.125 +  if (p_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) {
   3.126        UnlockDisplay(dpy);
   3.127        SyncHandle();
   3.128        return NULL;
   3.129 @@ -896,7 +904,7 @@
   3.130  	  int i;
   3.131  	
   3.132  	  for(i = 0; i < rep.num_formats; i++) {
   3.133 -              _XRead(dpy, (char*)(&Info), sz_xvImageFormatInfo);
   3.134 +              p_XRead(dpy, (char*)(&Info), sz_xvImageFormatInfo);
   3.135  	      ret[i].id = Info.id;	      
   3.136  	      ret[i].type = Info.type;	      
   3.137  	      ret[i].byte_order = Info.byte_order;	      
   3.138 @@ -922,7 +930,7 @@
   3.139  	      (*num)++;
   3.140  	  }
   3.141        } else
   3.142 -	_XEatData(dpy, rep.length << 2);
   3.143 +	p_XEatData(dpy, rep.length << 2);
   3.144    }
   3.145  
   3.146    UnlockDisplay(dpy);
   3.147 @@ -956,7 +964,7 @@
   3.148  
   3.149     /* READ THE REPLY */
   3.150  
   3.151 -   if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
   3.152 +   if (!p_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
   3.153         UnlockDisplay(dpy);
   3.154         SyncHandle();
   3.155        return NULL;
   3.156 @@ -972,10 +980,10 @@
   3.157  	ret->offsets = ret->pitches + rep.num_planes;
   3.158  	ret->data = data;
   3.159  	ret->obdata = NULL;
   3.160 -  	_XRead(dpy, (char*)(ret->pitches), rep.num_planes << 2);
   3.161 -	_XRead(dpy, (char*)(ret->offsets), rep.num_planes << 2);
   3.162 +  	p_XRead(dpy, (char*)(ret->pitches), rep.num_planes << 2);
   3.163 +	p_XRead(dpy, (char*)(ret->offsets), rep.num_planes << 2);
   3.164     } else
   3.165 -	_XEatData(dpy, rep.length << 2);
   3.166 +	p_XEatData(dpy, rep.length << 2);
   3.167  
   3.168     UnlockDisplay(dpy);
   3.169     SyncHandle();
   3.170 @@ -1124,7 +1132,7 @@
   3.171      case XvVideoNotify:
   3.172        re->xvvideo.type = event->u.u.type & 0x7f;
   3.173        re->xvvideo.serial = 
   3.174 -	_XSetLastRequestRead(dpy, (xGenericReply *)event);
   3.175 +	p_XSetLastRequestRead(dpy, (xGenericReply *)event);
   3.176        re->xvvideo.send_event = ((event->u.u.type & 0x80) != 0);
   3.177        re->xvvideo.display = dpy;
   3.178        re->xvvideo.time = event->u.videoNotify.time;
   3.179 @@ -1135,7 +1143,7 @@
   3.180      case XvPortNotify:
   3.181        re->xvport.type = event->u.u.type & 0x7f;
   3.182        re->xvport.serial = 
   3.183 -	_XSetLastRequestRead(dpy, (xGenericReply *)event);
   3.184 +	p_XSetLastRequestRead(dpy, (xGenericReply *)event);
   3.185        re->xvport.send_event = ((event->u.u.type & 0x80) != 0);
   3.186        re->xvport.display = dpy;
   3.187        re->xvport.time = event->u.portNotify.time;
     4.1 --- a/src/video/Xext/Xv/Xvlibint.h	Sat Nov 05 17:41:11 2005 +0000
     4.2 +++ b/src/video/Xext/Xv/Xvlibint.h	Sat Nov 05 19:53:37 2005 +0000
     4.3 @@ -51,7 +51,7 @@
     4.4  #define XvGetReq(name, req) \
     4.5          WORD64ALIGN\
     4.6  	if ((dpy->bufptr + SIZEOF(xv##name##Req)) > dpy->bufmax)\
     4.7 -		_XFlush(dpy);\
     4.8 +		p_XFlush(dpy);\
     4.9  	req = (xv##name##Req *)(dpy->last_req = dpy->bufptr);\
    4.10  	req->reqType = info->codes->major_opcode;\
    4.11          req->xvReqType = xv_##name; \
    4.12 @@ -63,7 +63,7 @@
    4.13  #define XvGetReq(name, req) \
    4.14          WORD64ALIGN\
    4.15  	if ((dpy->bufptr + SIZEOF(xv/**/name/**/Req)) > dpy->bufmax)\
    4.16 -		_XFlush(dpy);\
    4.17 +		p_XFlush(dpy);\
    4.18  	req = (xv/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\
    4.19  	req->reqType = info->codes->major_opcode;\
    4.20  	req->xvReqType = xv_/**/name;\
     5.1 --- a/src/video/Xext/Xxf86dga/XF86DGA.c	Sat Nov 05 17:41:11 2005 +0000
     5.2 +++ b/src/video/Xext/Xxf86dga/XF86DGA.c	Sat Nov 05 19:53:37 2005 +0000
     5.3 @@ -56,7 +56,6 @@
     5.4  #undef _SC_PAGESIZE
     5.5  #endif
     5.6  
     5.7 -
     5.8  #define NEED_EVENTS
     5.9  #define NEED_REPLIES
    5.10  #include <X11/Xlibint.h>
    5.11 @@ -65,6 +64,14 @@
    5.12  #include <X11/extensions/Xext.h>
    5.13  #include "extutil.h"
    5.14  
    5.15 +#include "../../x11/SDL_x11dyn.h"
    5.16 +
    5.17 +/* Workaround code in headers... */
    5.18 +#define _XFlush p_XFlush
    5.19 +#define _XFlushGCCache p_XFlushGCCache
    5.20 +#define _XReply p_XReply
    5.21 +#define _XSend p_XSend
    5.22 +
    5.23  extern XExtDisplayInfo* SDL_NAME(xdga_find_display)(Display*);
    5.24  extern char *SDL_NAME(xdga_extension_name);
    5.25  
    5.26 @@ -112,7 +119,7 @@
    5.27      req->reqType = info->codes->major_opcode;
    5.28      req->dgaReqType = X_XF86DGAGetVideoLL;
    5.29      req->screen = screen;
    5.30 -    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
    5.31 +    if (!p_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
    5.32  	UnlockDisplay(dpy);
    5.33  	SyncHandle();
    5.34  	return False;
    5.35 @@ -147,7 +154,7 @@
    5.36      req->enable = enable;
    5.37      UnlockDisplay(dpy);
    5.38      SyncHandle();
    5.39 -    XSync(dpy,False);
    5.40 +    pXSync(dpy,False);
    5.41      return True;
    5.42  }
    5.43  
    5.44 @@ -168,7 +175,7 @@
    5.45      req->reqType = info->codes->major_opcode;
    5.46      req->dgaReqType = X_XF86DGAGetViewPortSize;
    5.47      req->screen = screen;
    5.48 -    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
    5.49 +    if (!p_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
    5.50  	UnlockDisplay(dpy);
    5.51  	SyncHandle();
    5.52  	return False;
    5.53 @@ -203,7 +210,7 @@
    5.54      req->y = y;
    5.55      UnlockDisplay(dpy);
    5.56      SyncHandle();
    5.57 -    XSync(dpy,False);
    5.58 +    pXSync(dpy,False);
    5.59      return True;
    5.60  }
    5.61  
    5.62 @@ -224,7 +231,7 @@
    5.63      req->reqType = info->codes->major_opcode;
    5.64      req->dgaReqType = X_XF86DGAGetVidPage;
    5.65      req->screen = screen;
    5.66 -    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
    5.67 +    if (!p_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
    5.68  	UnlockDisplay(dpy);
    5.69  	SyncHandle();
    5.70  	return False;
    5.71 @@ -255,7 +262,7 @@
    5.72      req->vpage = vpage;
    5.73      UnlockDisplay(dpy);
    5.74      SyncHandle();
    5.75 -    XSync(dpy,False);
    5.76 +    pXSync(dpy,False);
    5.77      return True;
    5.78  }
    5.79  
    5.80 @@ -277,7 +284,7 @@
    5.81      req->id = cmap;
    5.82      UnlockDisplay(dpy);
    5.83      SyncHandle();
    5.84 -    XSync(dpy,False);
    5.85 +    pXSync(dpy,False);
    5.86      return True;
    5.87  }
    5.88  
    5.89 @@ -297,7 +304,7 @@
    5.90      req->reqType = info->codes->major_opcode;
    5.91      req->dgaReqType = X_XF86DGAQueryDirectVideo;
    5.92      req->screen = screen;
    5.93 -    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
    5.94 +    if (!p_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
    5.95  	UnlockDisplay(dpy);
    5.96  	SyncHandle();
    5.97  	return False;
    5.98 @@ -325,7 +332,7 @@
    5.99      req->dgaReqType = X_XF86DGAViewPortChanged;
   5.100      req->screen = screen;
   5.101      req->n = n;
   5.102 -    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
   5.103 +    if (!p_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
   5.104  	UnlockDisplay(dpy);
   5.105  	SyncHandle();
   5.106  	return False;
   5.107 @@ -598,7 +605,7 @@
   5.108  	for (i = 0; i < numScrs; i++) {
   5.109  	    sp = scrList[i];
   5.110  	    SDL_NAME(XF86DGADirectVideoLL)(sp->display, sp->screen, 0);
   5.111 -	    XSync(sp->display, False);
   5.112 +	    pXSync(sp->display, False);
   5.113  	}
   5.114          if (WIFEXITED(status))
   5.115  	    _exit(0);
   5.116 @@ -658,7 +665,7 @@
   5.117      for (i = 0; i < numScrs; i++) {
   5.118  	sp = scrList[i];
   5.119  	SDL_NAME(XF86DGADirectVideo)(sp->display, sp->screen, 0);
   5.120 -	XSync(sp->display, False);
   5.121 +	pXSync(sp->display, False);
   5.122      }
   5.123      _exit(3);
   5.124  }
     6.1 --- a/src/video/Xext/Xxf86dga/XF86DGA2.c	Sat Nov 05 17:41:11 2005 +0000
     6.2 +++ b/src/video/Xext/Xxf86dga/XF86DGA2.c	Sat Nov 05 19:53:37 2005 +0000
     6.3 @@ -28,6 +28,14 @@
     6.4  #include <linux/fb.h>
     6.5  #endif
     6.6  
     6.7 +#include "../../x11/SDL_x11dyn.h"
     6.8 +
     6.9 +/* Workaround code in headers... */
    6.10 +#define _XFlush p_XFlush
    6.11 +#define _XFlushGCCache p_XFlushGCCache
    6.12 +#define _XReply p_XReply
    6.13 +#define _XSend p_XSend
    6.14 +
    6.15  /* If you change this, change the Bases[] array below as well */
    6.16  #define MAX_HEADS 16
    6.17  
    6.18 @@ -104,7 +112,7 @@
    6.19    case MotionNotify:
    6.20  	mevent = (SDL_NAME(XDGAMotionEvent)*)event;
    6.21  	mevent->type = wire->u.u.type & 0x7F;
    6.22 -	mevent->serial = _XSetLastRequestRead(dpy, (xGenericReply *)wire);
    6.23 +	mevent->serial = p_XSetLastRequestRead(dpy, (xGenericReply *)wire);
    6.24  	mevent->display = dpy;
    6.25  	mevent->screen = wire->u.event.screen;
    6.26  	mevent->time = wire->u.event.time;
    6.27 @@ -116,7 +124,7 @@
    6.28    case ButtonRelease:
    6.29  	bevent = (SDL_NAME(XDGAButtonEvent)*)event;
    6.30  	bevent->type = wire->u.u.type & 0x7F;
    6.31 -	bevent->serial = _XSetLastRequestRead(dpy, (xGenericReply *)wire);
    6.32 +	bevent->serial = p_XSetLastRequestRead(dpy, (xGenericReply *)wire);
    6.33  	bevent->display = dpy;
    6.34  	bevent->screen = wire->u.event.screen;
    6.35  	bevent->time = wire->u.event.time;
    6.36 @@ -127,7 +135,7 @@
    6.37    case KeyRelease:
    6.38  	kevent = (SDL_NAME(XDGAKeyEvent)*)event;
    6.39  	kevent->type = wire->u.u.type & 0x7F;
    6.40 -	kevent->serial = _XSetLastRequestRead(dpy, (xGenericReply *)wire);
    6.41 +	kevent->serial = p_XSetLastRequestRead(dpy, (xGenericReply *)wire);
    6.42  	kevent->display = dpy;
    6.43  	kevent->screen = wire->u.event.screen;
    6.44  	kevent->time = wire->u.event.time;
    6.45 @@ -172,7 +180,7 @@
    6.46      GetReq(XDGAQueryVersion, req);
    6.47      req->reqType = info->codes->major_opcode;
    6.48      req->dgaReqType = X_XDGAQueryVersion;
    6.49 -    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
    6.50 +    if (!p_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
    6.51  	UnlockDisplay(dpy);
    6.52  	SyncHandle();
    6.53  	return False;
    6.54 @@ -189,8 +197,8 @@
    6.55  	     i < XF86DGANumberEvents;
    6.56  	     i++, j++) 
    6.57  	{
    6.58 -	    XESetWireToEvent (dpy, j, xdga_wire_to_event);
    6.59 -	    XESetEventToWire (dpy, j, xdga_event_to_wire);
    6.60 +	    pXESetWireToEvent(dpy, j, xdga_wire_to_event);
    6.61 +	    pXESetEventToWire(dpy, j, xdga_event_to_wire);
    6.62  	}
    6.63  	SDL_NAME(XDGASetClientVersion)(dpy);
    6.64      }
    6.65 @@ -233,7 +241,7 @@
    6.66      req->reqType = info->codes->major_opcode;
    6.67      req->dgaReqType = X_XDGAOpenFramebuffer;
    6.68      req->screen = screen;
    6.69 -    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
    6.70 +    if (!p_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
    6.71  	UnlockDisplay(dpy);
    6.72  	SyncHandle();
    6.73  	return False;
    6.74 @@ -241,7 +249,7 @@
    6.75  
    6.76      if(rep.length) {
    6.77  	deviceName = Xmalloc(rep.length << 2);
    6.78 -	_XRead(dpy, deviceName, rep.length << 2);
    6.79 +	p_XRead(dpy, deviceName, rep.length << 2);
    6.80      }
    6.81  
    6.82      ret = SDL_NAME(XDGAMapFramebuffer)(screen, deviceName,
    6.83 @@ -298,7 +306,7 @@
    6.84      req->dgaReqType = X_XDGAQueryModes;
    6.85      req->screen = screen;
    6.86  
    6.87 -    if (_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
    6.88 +    if (p_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
    6.89  	if(rep.length) {
    6.90  	   xXDGAModeInfo info;
    6.91  	   int i, size;
    6.92 @@ -312,7 +320,7 @@
    6.93  
    6.94  	   if(modes) {	
    6.95  	      for(i = 0; i < rep.number; i++) {
    6.96 -		_XRead(dpy, (char*)(&info), sz_xXDGAModeInfo);
    6.97 +		p_XRead(dpy, (char*)(&info), sz_xXDGAModeInfo);
    6.98  
    6.99  		modes[i].num = info.num;
   6.100  		modes[i].verticalRefresh = 
   6.101 @@ -340,13 +348,13 @@
   6.102  		modes[i].reserved1 = info.reserved1;
   6.103  		modes[i].reserved2 = info.reserved2;	
   6.104  
   6.105 -		_XRead(dpy, offset, info.name_size);
   6.106 +		p_XRead(dpy, offset, info.name_size);
   6.107  		modes[i].name = offset;
   6.108  		offset += info.name_size;
   6.109  	      }
   6.110  	      *num = rep.number;
   6.111  	   } else
   6.112 -		_XEatData(dpy, rep.length << 2);
   6.113 +		p_XEatData(dpy, rep.length << 2);
   6.114  	}
   6.115      }
   6.116  
   6.117 @@ -379,7 +387,7 @@
   6.118      req->mode = mode;
   6.119      req->pid = pid = XAllocID(dpy);
   6.120      
   6.121 -    if (_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
   6.122 +    if (p_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
   6.123  	if(rep.length) {
   6.124  	   xXDGAModeInfo info;
   6.125  	   int size;
   6.126 @@ -390,7 +398,7 @@
   6.127  	   dev = (SDL_NAME(XDGADevice)*)Xmalloc(sizeof(SDL_NAME(XDGADevice)) + size);
   6.128  	    
   6.129  	   if(dev) {
   6.130 -		_XRead(dpy, (char*)(&info), sz_xXDGAModeInfo);
   6.131 +		p_XRead(dpy, (char*)(&info), sz_xXDGAModeInfo);
   6.132  
   6.133  		dev->mode.num = info.num;
   6.134  		dev->mode.verticalRefresh = 
   6.135 @@ -419,7 +427,7 @@
   6.136  		dev->mode.reserved2 = info.reserved2;
   6.137  
   6.138  		dev->mode.name = (char*)(&dev[1]);	
   6.139 -		_XRead(dpy, dev->mode.name, info.name_size);
   6.140 +		p_XRead(dpy, dev->mode.name, info.name_size);
   6.141  
   6.142  		dev->pixmap = (rep.flags & XDGAPixmap) ? pid : 0;
   6.143  		dev->data = SDL_NAME(XDGAGetMappedMemory)(screen);
   6.144 @@ -610,7 +618,7 @@
   6.145      req->reqType = info->codes->major_opcode;
   6.146      req->dgaReqType = X_XDGAGetViewportStatus;
   6.147      req->screen = screen;
   6.148 -    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse))
   6.149 +    if (!p_XReply(dpy, (xReply *)&rep, 0, xFalse))
   6.150  	status = rep.status;
   6.151      UnlockDisplay(dpy);
   6.152      SyncHandle();
   6.153 @@ -632,7 +640,7 @@
   6.154      req->reqType = info->codes->major_opcode;
   6.155      req->dgaReqType = X_XDGASync;
   6.156      req->screen = screen;
   6.157 -    _XReply(dpy, (xReply *)&rep, 0, xFalse);
   6.158 +    p_XReply(dpy, (xReply *)&rep, 0, xFalse);
   6.159      UnlockDisplay(dpy);
   6.160      SyncHandle();
   6.161  }
   6.162 @@ -659,7 +667,7 @@
   6.163      req->x = *x;
   6.164      req->y = *y;
   6.165      req->flags = mode;
   6.166 -    _XReply(dpy, (xReply *)&rep, 0, xFalse);
   6.167 +    p_XReply(dpy, (xReply *)&rep, 0, xFalse);
   6.168      *x = rep.x;
   6.169      *y = rep.y;
   6.170      UnlockDisplay(dpy);
     7.1 --- a/src/video/Xext/Xxf86vm/XF86VMode.c	Sat Nov 05 17:41:11 2005 +0000
     7.2 +++ b/src/video/Xext/Xxf86vm/XF86VMode.c	Sat Nov 05 19:53:37 2005 +0000
     7.3 @@ -47,6 +47,14 @@
     7.4  #include "include/extensions/extutil.h"
     7.5  #endif
     7.6  
     7.7 +#include "../../x11/SDL_x11dyn.h"
     7.8 +
     7.9 +/* Workaround code in headers... */
    7.10 +#define _XFlush p_XFlush
    7.11 +#define _XFlushGCCache p_XFlushGCCache
    7.12 +#define _XReply p_XReply
    7.13 +#define _XSend p_XSend
    7.14 +
    7.15  #ifdef DEBUG
    7.16  #include <stdio.h>
    7.17  #endif
    7.18 @@ -129,7 +137,7 @@
    7.19      GetReq(XF86VidModeQueryVersion, req);
    7.20      req->reqType = info->codes->major_opcode;
    7.21      req->xf86vidmodeReqType = X_XF86VidModeQueryVersion;
    7.22 -    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
    7.23 +    if (!p_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
    7.24  	UnlockDisplay(dpy);
    7.25  	SyncHandle();
    7.26  	return False;
    7.27 @@ -197,7 +205,7 @@
    7.28      req->reqType = info->codes->major_opcode;
    7.29      req->xf86vidmodeReqType = X_XF86VidModeGetGamma;
    7.30      req->screen = screen;
    7.31 -    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
    7.32 +    if (!p_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
    7.33  	UnlockDisplay(dpy);
    7.34  	SyncHandle();
    7.35  	return False;
    7.36 @@ -233,7 +241,7 @@
    7.37      req->screen = screen;
    7.38      
    7.39      if (majorVersion < 2) {
    7.40 -	if (!_XReply(dpy, (xReply *)&oldrep, 
    7.41 +	if (!p_XReply(dpy, (xReply *)&oldrep, 
    7.42              (SIZEOF(xXF86OldVidModeGetModeLineReply) - SIZEOF(xReply)) >> 2, xFalse)) {
    7.43  	    UnlockDisplay(dpy);
    7.44  	    SyncHandle();
    7.45 @@ -252,7 +260,7 @@
    7.46  	modeline->flags      = oldrep.flags;
    7.47  	modeline->privsize   = oldrep.privsize;
    7.48      } else {
    7.49 -	if (!_XReply(dpy, (xReply *)&rep, 
    7.50 +	if (!p_XReply(dpy, (xReply *)&rep, 
    7.51              (SIZEOF(xXF86VidModeGetModeLineReply) - SIZEOF(xReply)) >> 2, xFalse)) {
    7.52  	    UnlockDisplay(dpy);
    7.53  	    SyncHandle();
    7.54 @@ -274,11 +282,11 @@
    7.55      
    7.56      if (modeline->privsize > 0) {
    7.57  	if (!(modeline->private = Xcalloc(modeline->privsize, sizeof(INT32)))) {
    7.58 -	    _XEatData(dpy, (modeline->privsize) * sizeof(INT32));
    7.59 +	    p_XEatData(dpy, (modeline->privsize) * sizeof(INT32));
    7.60  	    Xfree(modeline->private);
    7.61  	    return False;
    7.62  	}
    7.63 -	_XRead(dpy, (char*)modeline->private, modeline->privsize * sizeof(INT32));
    7.64 +	p_XRead(dpy, (char*)modeline->private, modeline->privsize * sizeof(INT32));
    7.65      } else {
    7.66  	modeline->private = NULL;
    7.67      }
    7.68 @@ -327,7 +335,7 @@
    7.69      req->reqType = info->codes->major_opcode;
    7.70      req->xf86vidmodeReqType = X_XF86VidModeGetAllModeLines;
    7.71      req->screen = screen;
    7.72 -    if (!_XReply(dpy, (xReply *)&rep, 
    7.73 +    if (!p_XReply(dpy, (xReply *)&rep, 
    7.74          (SIZEOF(xXF86VidModeGetAllModeLinesReply) - SIZEOF(xReply)) >> 2, xFalse)) {
    7.75          UnlockDisplay(dpy);
    7.76  	SyncHandle();
    7.77 @@ -340,9 +348,9 @@
    7.78                                            sizeof(SDL_NAME(XF86VidModeModeInfo) *)
    7.79                                            +sizeof(SDL_NAME(XF86VidModeModeInfo))))) {
    7.80  	if (majorVersion < 2)
    7.81 -            _XEatData(dpy, (rep.modecount) * sizeof(xXF86OldVidModeModeInfo));
    7.82 +            p_XEatData(dpy, (rep.modecount) * sizeof(xXF86OldVidModeModeInfo));
    7.83  	else
    7.84 -            _XEatData(dpy, (rep.modecount) * sizeof(xXF86VidModeModeInfo));
    7.85 +            p_XEatData(dpy, (rep.modecount) * sizeof(xXF86VidModeModeInfo));
    7.86          Xfree(modelines);
    7.87          UnlockDisplay(dpy);
    7.88          SyncHandle();
    7.89 @@ -356,7 +364,7 @@
    7.90      for (i = 0; i < rep.modecount; i++) {
    7.91          modelines[i] = mdinfptr++;
    7.92  	if (majorVersion < 2) {
    7.93 -            _XRead(dpy, (char*)&oldxmdline, sizeof(xXF86OldVidModeModeInfo));
    7.94 +            p_XRead(dpy, (char*)&oldxmdline, sizeof(xXF86OldVidModeModeInfo));
    7.95  	    modelines[i]->dotclock   = oldxmdline.dotclock;
    7.96  	    modelines[i]->hdisplay   = oldxmdline.hdisplay;
    7.97  	    modelines[i]->hsyncstart = oldxmdline.hsyncstart;
    7.98 @@ -376,10 +384,10 @@
    7.99  		if (oldxmdline.privsize > 0) {
   7.100  	            if (!(modelines[i]->private =
   7.101  			    Xcalloc(oldxmdline.privsize, sizeof(INT32)))) {
   7.102 -			_XEatData(dpy, (oldxmdline.privsize) * sizeof(INT32));
   7.103 +			p_XEatData(dpy, (oldxmdline.privsize) * sizeof(INT32));
   7.104  			Xfree(modelines[i]->private);
   7.105  		    } else {
   7.106 -			_XRead(dpy, (char*)modelines[i]->private,
   7.107 +			p_XRead(dpy, (char*)modelines[i]->private,
   7.108  			     oldxmdline.privsize * sizeof(INT32));
   7.109  		    }
   7.110  		} else {
   7.111 @@ -387,7 +395,7 @@
   7.112  		}
   7.113  	    }
   7.114  	} else {
   7.115 -            _XRead(dpy, (char*)&xmdline, sizeof(xXF86VidModeModeInfo));
   7.116 +            p_XRead(dpy, (char*)&xmdline, sizeof(xXF86VidModeModeInfo));
   7.117  	    modelines[i]->dotclock   = xmdline.dotclock;
   7.118  	    modelines[i]->hdisplay   = xmdline.hdisplay;
   7.119  	    modelines[i]->hsyncstart = xmdline.hsyncstart;
   7.120 @@ -407,10 +415,10 @@
   7.121  		if (xmdline.privsize > 0) {
   7.122  		    if (!(modelines[i]->private =
   7.123  			    Xcalloc(xmdline.privsize, sizeof(INT32)))) {
   7.124 -			_XEatData(dpy, (xmdline.privsize) * sizeof(INT32));
   7.125 +			p_XEatData(dpy, (xmdline.privsize) * sizeof(INT32));
   7.126  			Xfree(modelines[i]->private);
   7.127  		    } else {
   7.128 -			_XRead(dpy, (char*)modelines[i]->private,
   7.129 +			p_XRead(dpy, (char*)modelines[i]->private,
   7.130  			     xmdline.privsize * sizeof(INT32));
   7.131  		    }
   7.132  		} else {
   7.133 @@ -432,7 +440,7 @@
   7.134  #define GetOldReq(name, oldname, req) \
   7.135          WORD64ALIGN\
   7.136  	if ((dpy->bufptr + SIZEOF(x##oldname##Req)) > dpy->bufmax)\
   7.137 -		_XFlush(dpy);\
   7.138 +		p_XFlush(dpy);\
   7.139  	req = (x##oldname##Req *)(dpy->last_req = dpy->bufptr);\
   7.140  	req->reqType = X_##name;\
   7.141  	req->length = (SIZEOF(x##oldname##Req))>>2;\
   7.142 @@ -443,7 +451,7 @@
   7.143  #define GetOldReq(name, oldname, req) \
   7.144          WORD64ALIGN\
   7.145  	if ((dpy->bufptr + SIZEOF(x/**/oldname/**/Req)) > dpy->bufmax)\
   7.146 -		_XFlush(dpy);\
   7.147 +		p_XFlush(dpy);\
   7.148  	req = (x/**/oldname/**/Req *)(dpy->last_req = dpy->bufptr);\
   7.149  	req->reqType = X_/**/name;\
   7.150  	req->length = (SIZEOF(x/**/oldname/**/Req))>>2;\
   7.151 @@ -751,7 +759,7 @@
   7.152  	       modeline->privsize * sizeof(INT32));
   7.153  	}
   7.154      }
   7.155 -    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
   7.156 +    if (!p_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
   7.157  	UnlockDisplay(dpy);
   7.158  	SyncHandle();
   7.159  	return MODE_BAD;
   7.160 @@ -913,7 +921,7 @@
   7.161      req->reqType = info->codes->major_opcode;
   7.162      req->xf86vidmodeReqType = X_XF86VidModeGetMonitor;
   7.163      req->screen = screen;
   7.164 -    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
   7.165 +    if (!p_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
   7.166  	UnlockDisplay(dpy);
   7.167  	SyncHandle();
   7.168  	return False;
   7.169 @@ -925,7 +933,7 @@
   7.170  #endif
   7.171      if (rep.vendorLength) {
   7.172  	if (!(monitor->vendor = (char *)Xcalloc(rep.vendorLength + 1, 1))) {
   7.173 -	    _XEatData(dpy, (rep.nhsync + rep.nvsync) * 4 +
   7.174 +	    p_XEatData(dpy, (rep.nhsync + rep.nvsync) * 4 +
   7.175  		      ((rep.vendorLength+3) & ~3) + ((rep.modelLength+3) & ~3));
   7.176              UnlockDisplay(dpy);
   7.177              SyncHandle();
   7.178 @@ -936,7 +944,7 @@
   7.179      }
   7.180      if (rep.modelLength) {
   7.181  	if (!(monitor->model = Xcalloc(rep.modelLength + 1, 1))) {
   7.182 -	    _XEatData(dpy, (rep.nhsync + rep.nvsync) * 4 +
   7.183 +	    p_XEatData(dpy, (rep.nhsync + rep.nvsync) * 4 +
   7.184  		      ((rep.vendorLength+3) & ~3) + ((rep.modelLength+3) & ~3));
   7.185  	    if (monitor->vendor)
   7.186  		Xfree(monitor->vendor);
   7.187 @@ -948,7 +956,7 @@
   7.188  	monitor->model = NULL;
   7.189      }
   7.190      if (!(monitor->hsync = Xcalloc(rep.nhsync, sizeof(SDL_NAME(XF86VidModeSyncRange))))) {
   7.191 -	_XEatData(dpy, (rep.nhsync + rep.nvsync) * 4 +
   7.192 +	p_XEatData(dpy, (rep.nhsync + rep.nvsync) * 4 +
   7.193  		  ((rep.vendorLength+3) & ~3) + ((rep.modelLength+3) & ~3));
   7.194  	
   7.195  	if (monitor->vendor)
   7.196 @@ -960,7 +968,7 @@
   7.197  	return False;
   7.198      }
   7.199      if (!(monitor->vsync = Xcalloc(rep.nvsync, sizeof(SDL_NAME(XF86VidModeSyncRange))))) {
   7.200 -	_XEatData(dpy, (rep.nhsync + rep.nvsync) * 4 +
   7.201 +	p_XEatData(dpy, (rep.nhsync + rep.nvsync) * 4 +
   7.202  		  ((rep.vendorLength+3) & ~3) + ((rep.modelLength+3) & ~3));
   7.203  	if (monitor->vendor)
   7.204  	    Xfree(monitor->vendor);
   7.205 @@ -972,21 +980,21 @@
   7.206  	return False;
   7.207      }
   7.208      for (i = 0; i < rep.nhsync; i++) {
   7.209 -	_XRead(dpy, (char *)&syncrange, 4);
   7.210 +	p_XRead(dpy, (char *)&syncrange, 4);
   7.211  	monitor->hsync[i].lo = (float)(syncrange & 0xFFFF) / 100.0;
   7.212  	monitor->hsync[i].hi = (float)(syncrange >> 16) / 100.0;
   7.213      }
   7.214      for (i = 0; i < rep.nvsync; i++) {
   7.215 -	_XRead(dpy, (char *)&syncrange, 4);
   7.216 +	p_XRead(dpy, (char *)&syncrange, 4);
   7.217  	monitor->vsync[i].lo = (float)(syncrange & 0xFFFF) / 100.0;
   7.218  	monitor->vsync[i].hi = (float)(syncrange >> 16) / 100.0;
   7.219      }
   7.220      if (rep.vendorLength)
   7.221 -	_XReadPad(dpy, monitor->vendor, rep.vendorLength);
   7.222 +	p_XReadPad(dpy, monitor->vendor, rep.vendorLength);
   7.223      else
   7.224  	monitor->vendor = "";
   7.225      if (rep.modelLength)
   7.226 -	_XReadPad(dpy, monitor->model, rep.modelLength);
   7.227 +	p_XReadPad(dpy, monitor->model, rep.modelLength);
   7.228      else
   7.229  	monitor->model = "";
   7.230  	
   7.231 @@ -1034,7 +1042,7 @@
   7.232  	*x = 0;
   7.233  	*y = 0;
   7.234      } else {
   7.235 -	if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
   7.236 +	if (!p_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
   7.237  	    UnlockDisplay(dpy);
   7.238  	    SyncHandle();
   7.239  	    return False;
   7.240 @@ -1092,7 +1100,7 @@
   7.241      req->reqType = info->codes->major_opcode;
   7.242      req->xf86vidmodeReqType = X_XF86VidModeGetDotClocks;
   7.243      req->screen = screen;
   7.244 -    if (!_XReply(dpy, (xReply *)&rep, 
   7.245 +    if (!p_XReply(dpy, (xReply *)&rep, 
   7.246          (SIZEOF(xXF86VidModeGetDotClocksReply) - SIZEOF(xReply)) >> 2, xFalse))
   7.247      {
   7.248          UnlockDisplay(dpy);
   7.249 @@ -1104,7 +1112,7 @@
   7.250      *flagsPtr     = rep.flags;
   7.251  
   7.252      if (!(dotclocks = (int*) Xcalloc(rep.clocks, sizeof(int)))) {
   7.253 -        _XEatData(dpy, (rep.clocks) * 4);
   7.254 +        p_XEatData(dpy, (rep.clocks) * 4);
   7.255          Xfree(dotclocks);
   7.256          UnlockDisplay(dpy);
   7.257          SyncHandle();
   7.258 @@ -1112,7 +1120,7 @@
   7.259      }
   7.260  
   7.261      for (i = 0; i < rep.clocks; i++) {
   7.262 -        _XRead(dpy, (char*)&dotclk, 4);
   7.263 +        p_XRead(dpy, (char*)&dotclk, 4);
   7.264  	dotclocks[i] = dotclk;
   7.265      }
   7.266      *clocksPtr = dotclocks;
   7.267 @@ -1143,9 +1151,9 @@
   7.268      req->screen = screen;
   7.269      req->length += (length >> 1) * 3;
   7.270      req->size = size;
   7.271 -    _XSend(dpy, (char*)red, size * 2);
   7.272 -    _XSend(dpy, (char*)green, size * 2);
   7.273 -    _XSend(dpy, (char*)blue, size * 2);
   7.274 +    p_XSend(dpy, (char*)red, size * 2);
   7.275 +    p_XSend(dpy, (char*)green, size * 2);
   7.276 +    p_XSend(dpy, (char*)blue, size * 2);
   7.277      UnlockDisplay(dpy);
   7.278      SyncHandle();
   7.279      return True;
   7.280 @@ -1174,15 +1182,15 @@
   7.281      req->xf86vidmodeReqType = X_XF86VidModeGetGammaRamp;
   7.282      req->screen = screen;
   7.283      req->size = size;
   7.284 -    if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) {
   7.285 +    if (!p_XReply (dpy, (xReply *) &rep, 0, xFalse)) {
   7.286          UnlockDisplay (dpy);
   7.287          SyncHandle ();
   7.288          return False;
   7.289      }
   7.290      if(rep.size) {
   7.291 -	_XRead(dpy, (char*)red, rep.size << 1);
   7.292 -	_XRead(dpy, (char*)green, rep.size << 1);
   7.293 -	_XRead(dpy, (char*)blue, rep.size << 1);
   7.294 +	p_XRead(dpy, (char*)red, rep.size << 1);
   7.295 +	p_XRead(dpy, (char*)green, rep.size << 1);
   7.296 +	p_XRead(dpy, (char*)blue, rep.size << 1);
   7.297      }
   7.298  
   7.299      UnlockDisplay(dpy);
   7.300 @@ -1209,7 +1217,7 @@
   7.301      req->reqType = info->codes->major_opcode;
   7.302      req->xf86vidmodeReqType = X_XF86VidModeGetGammaRampSize;
   7.303      req->screen = screen;
   7.304 -    if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
   7.305 +    if (!p_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
   7.306          UnlockDisplay (dpy);
   7.307          SyncHandle ();
   7.308          return False; 
     8.1 --- a/src/video/Xext/extensions/extutil.h	Sat Nov 05 17:41:11 2005 +0000
     8.2 +++ b/src/video/Xext/extensions/extutil.h	Sat Nov 05 19:53:37 2005 +0000
     8.3 @@ -173,9 +173,9 @@
     8.4  
     8.5  #define XextHasExtension(i) ((i) && ((i)->codes))
     8.6  #define XextCheckExtension(dpy,i,name,val) \
     8.7 -  if (!XextHasExtension(i)) { XMissingExtension (dpy, name); return val; }
     8.8 +  if (!XextHasExtension(i)) { pXMissingExtension (dpy, name); return val; }
     8.9  #define XextSimpleCheckExtension(dpy,i,name) \
    8.10 -  if (!XextHasExtension(i)) { XMissingExtension (dpy, name); return; }
    8.11 +  if (!XextHasExtension(i)) { pXMissingExtension (dpy, name); return; }
    8.12  
    8.13  
    8.14  /*
    8.15 @@ -188,9 +188,9 @@
    8.16  XExtDisplayInfo *proc (Display *dpy) \
    8.17  { \
    8.18      XExtDisplayInfo *dpyinfo; \
    8.19 -    if (!extinfo) { if (!(extinfo = XextCreateExtension())) return NULL; } \
    8.20 -    if (!(dpyinfo = XextFindDisplay (extinfo, dpy))) \
    8.21 -      dpyinfo = XextAddDisplay (extinfo,dpy,extname,hooks,nev,data); \
    8.22 +    if (!extinfo) { if (!(extinfo = pXextCreateExtension())) return NULL; } \
    8.23 +    if (!(dpyinfo = pXextFindDisplay (extinfo, dpy))) \
    8.24 +      dpyinfo = pXextAddDisplay (extinfo,dpy,extname,hooks,nev,data); \
    8.25      return dpyinfo; \
    8.26  }
    8.27  
    8.28 @@ -200,7 +200,7 @@
    8.29  #define XEXT_GENERATE_CLOSE_DISPLAY(proc,extinfo) \
    8.30  int proc (Display *dpy, XExtCodes *codes) \
    8.31  { \
    8.32 -    return XextRemoveDisplay (extinfo, dpy); \
    8.33 +    return pXextRemoveDisplay (extinfo, dpy); \
    8.34  }
    8.35  
    8.36  #define XEXT_CLOSE_DISPLAY_PROTO(proc) \
    8.37 @@ -213,7 +213,7 @@
    8.38      if (code >= 0 && code < nerr) { \
    8.39  	char tmp[256]; \
    8.40  	sprintf (tmp, "%s.%d", extname, code); \
    8.41 -	XGetErrorDatabaseText (dpy, "XProtoError", tmp, errl[code], buf, n); \
    8.42 +	pXGetErrorDatabaseText (dpy, "XProtoError", tmp, errl[code], buf, n); \
    8.43  	return buf; \
    8.44      } \
    8.45      return (char *)0; \
     9.1 --- a/src/video/dga/SDL_dgaevents.c	Sat Nov 05 17:41:11 2005 +0000
     9.2 +++ b/src/video/dga/SDL_dgaevents.c	Sat Nov 05 19:53:37 2005 +0000
     9.3 @@ -47,7 +47,7 @@
     9.4  	int posted;
     9.5  	SDL_NAME(XDGAEvent) xevent;
     9.6  
     9.7 -	XNextEvent(DGA_Display, (XEvent *)&xevent);
     9.8 +	pXNextEvent(DGA_Display, (XEvent *)&xevent);
     9.9  
    9.10  	posted = 0;
    9.11  	xevent.type -= DGA_event_base;
    10.1 --- a/src/video/dga/SDL_dgavideo.c	Sat Nov 05 17:41:11 2005 +0000
    10.2 +++ b/src/video/dga/SDL_dgavideo.c	Sat Nov 05 19:53:37 2005 +0000
    10.3 @@ -48,6 +48,9 @@
    10.4  #include "SDL_dgamouse_c.h"
    10.5  #include "SDL_dgaevents_c.h"
    10.6  
    10.7 +/* get function pointers... */
    10.8 +#include "../x11/SDL_x11dyn.h"
    10.9 +
   10.10  /* Initialization/Query functions */
   10.11  static int DGA_VideoInit(_THIS, SDL_PixelFormat *vformat);
   10.12  static SDL_Rect **DGA_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
   10.13 @@ -72,91 +75,98 @@
   10.14  
   10.15  static int DGA_Available(void)
   10.16  {
   10.17 -	const char *display;
   10.18 -	Display *dpy;
   10.19 -	int available;
   10.20 +	const char *display = NULL;
   10.21 +	Display *dpy = NULL;
   10.22 +	int available = 0;
   10.23  
   10.24  	/* The driver is available is available if the display is local
   10.25  	   and the DGA 2.0+ extension is available, and we can map mem.
   10.26  	*/
   10.27 -	available = 0;
   10.28 -	display = NULL;
   10.29 -	if ( (strncmp(XDisplayName(display), ":", 1) == 0) ||
   10.30 -	     (strncmp(XDisplayName(display), "unix:", 5) == 0) ) {
   10.31 -		dpy = XOpenDisplay(display);
   10.32 -		if ( dpy ) {
   10.33 -			int events, errors, major, minor;
   10.34 +	if ( SDL_X11_LoadSymbols() ) {
   10.35 +		if ( (strncmp(pXDisplayName(display), ":", 1) == 0) ||
   10.36 +		     (strncmp(pXDisplayName(display), "unix:", 5) == 0) ) {
   10.37 +			dpy = pXOpenDisplay(display);
   10.38 +			if ( dpy ) {
   10.39 +				int events, errors, major, minor;
   10.40  
   10.41 -			if ( SDL_NAME(XDGAQueryExtension)(dpy, &events, &errors) &&
   10.42 -			     SDL_NAME(XDGAQueryVersion)(dpy, &major, &minor) ) {
   10.43 -				int screen;
   10.44 +				if ( SDL_NAME(XDGAQueryExtension)(dpy, &events, &errors) &&
   10.45 +				     SDL_NAME(XDGAQueryVersion)(dpy, &major, &minor) ) {
   10.46 +					int screen;
   10.47  
   10.48 -				screen = DefaultScreen(dpy);
   10.49 -				if ( (major >= 2) && 
   10.50 -				     SDL_NAME(XDGAOpenFramebuffer)(dpy, screen) ) {
   10.51 -					available = 1;
   10.52 -					SDL_NAME(XDGACloseFramebuffer)(dpy, screen);
   10.53 +					screen = DefaultScreen(dpy);
   10.54 +					if ( (major >= 2) && 
   10.55 +					     SDL_NAME(XDGAOpenFramebuffer)(dpy, screen) ) {
   10.56 +						available = 1;
   10.57 +						SDL_NAME(XDGACloseFramebuffer)(dpy, screen);
   10.58 +					}
   10.59  				}
   10.60 +				pXCloseDisplay(dpy);
   10.61  			}
   10.62 -			XCloseDisplay(dpy);
   10.63  		}
   10.64 +		SDL_X11_UnloadSymbols();
   10.65  	}
   10.66  	return(available);
   10.67  }
   10.68  
   10.69  static void DGA_DeleteDevice(SDL_VideoDevice *device)
   10.70  {
   10.71 -	free(device->hidden);
   10.72 -	free(device);
   10.73 +	if (device != NULL) {
   10.74 +		free(device->hidden);
   10.75 +		free(device);
   10.76 +		SDL_X11_UnloadSymbols();
   10.77 +	}
   10.78  }
   10.79  
   10.80  static SDL_VideoDevice *DGA_CreateDevice(int devindex)
   10.81  {
   10.82 -	SDL_VideoDevice *device;
   10.83 +	SDL_VideoDevice *device = NULL;
   10.84  
   10.85  	/* Initialize all variables that we clean on shutdown */
   10.86 -	device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice));
   10.87 -	if ( device ) {
   10.88 -		memset(device, 0, (sizeof *device));
   10.89 -		device->hidden = (struct SDL_PrivateVideoData *)
   10.90 -				malloc((sizeof *device->hidden));
   10.91 +	if (SDL_X11_LoadSymbols()) {
   10.92 +		device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice));
   10.93 +		if ( device ) {
   10.94 +			memset(device, 0, (sizeof *device));
   10.95 +			device->hidden = (struct SDL_PrivateVideoData *)
   10.96 +					malloc((sizeof *device->hidden));
   10.97 +		}
   10.98 +		if ( (device == NULL) || (device->hidden == NULL) ) {
   10.99 +			SDL_OutOfMemory();
  10.100 +			if ( device ) {
  10.101 +				free(device);
  10.102 +			}
  10.103 +			SDL_X11_UnloadSymbols();
  10.104 +			return(0);
  10.105 +		}
  10.106 +		memset(device->hidden, 0, (sizeof *device->hidden));
  10.107 +
  10.108 +		/* Set the function pointers */
  10.109 +		device->VideoInit = DGA_VideoInit;
  10.110 +		device->ListModes = DGA_ListModes;
  10.111 +		device->SetVideoMode = DGA_SetVideoMode;
  10.112 +		device->SetColors = DGA_SetColors;
  10.113 +		device->UpdateRects = NULL;
  10.114 +		device->VideoQuit = DGA_VideoQuit;
  10.115 +		device->AllocHWSurface = DGA_AllocHWSurface;
  10.116 +		device->CheckHWBlit = DGA_CheckHWBlit;
  10.117 +		device->FillHWRect = DGA_FillHWRect;
  10.118 +		device->SetHWColorKey = NULL;
  10.119 +		device->SetHWAlpha = NULL;
  10.120 +		device->LockHWSurface = DGA_LockHWSurface;
  10.121 +		device->UnlockHWSurface = DGA_UnlockHWSurface;
  10.122 +		device->FlipHWSurface = DGA_FlipHWSurface;
  10.123 +		device->FreeHWSurface = DGA_FreeHWSurface;
  10.124 +		device->SetGammaRamp = DGA_SetGammaRamp;
  10.125 +		device->GetGammaRamp = NULL;
  10.126 +		device->SetCaption = NULL;
  10.127 +		device->SetIcon = NULL;
  10.128 +		device->IconifyWindow = NULL;
  10.129 +		device->GrabInput = NULL;
  10.130 +		device->GetWMInfo = NULL;
  10.131 +		device->InitOSKeymap = DGA_InitOSKeymap;
  10.132 +		device->PumpEvents = DGA_PumpEvents;
  10.133 +
  10.134 +		device->free = DGA_DeleteDevice;
  10.135  	}
  10.136 -	if ( (device == NULL) || (device->hidden == NULL) ) {
  10.137 -		SDL_OutOfMemory();
  10.138 -		if ( device ) {
  10.139 -			free(device);
  10.140 -		}
  10.141 -		return(0);
  10.142 -	}
  10.143 -	memset(device->hidden, 0, (sizeof *device->hidden));
  10.144 -
  10.145 -	/* Set the function pointers */
  10.146 -	device->VideoInit = DGA_VideoInit;
  10.147 -	device->ListModes = DGA_ListModes;
  10.148 -	device->SetVideoMode = DGA_SetVideoMode;
  10.149 -	device->SetColors = DGA_SetColors;
  10.150 -	device->UpdateRects = NULL;
  10.151 -	device->VideoQuit = DGA_VideoQuit;
  10.152 -	device->AllocHWSurface = DGA_AllocHWSurface;
  10.153 -	device->CheckHWBlit = DGA_CheckHWBlit;
  10.154 -	device->FillHWRect = DGA_FillHWRect;
  10.155 -	device->SetHWColorKey = NULL;
  10.156 -	device->SetHWAlpha = NULL;
  10.157 -	device->LockHWSurface = DGA_LockHWSurface;
  10.158 -	device->UnlockHWSurface = DGA_UnlockHWSurface;
  10.159 -	device->FlipHWSurface = DGA_FlipHWSurface;
  10.160 -	device->FreeHWSurface = DGA_FreeHWSurface;
  10.161 -	device->SetGammaRamp = DGA_SetGammaRamp;
  10.162 -	device->GetGammaRamp = NULL;
  10.163 -	device->SetCaption = NULL;
  10.164 -	device->SetIcon = NULL;
  10.165 -	device->IconifyWindow = NULL;
  10.166 -	device->GrabInput = NULL;
  10.167 -	device->GetWMInfo = NULL;
  10.168 -	device->InitOSKeymap = DGA_InitOSKeymap;
  10.169 -	device->PumpEvents = DGA_PumpEvents;
  10.170 -
  10.171 -	device->free = DGA_DeleteDevice;
  10.172  
  10.173  	return device;
  10.174  }
  10.175 @@ -329,7 +339,7 @@
  10.176  	/* Open the X11 display */
  10.177  	display = NULL;		/* Get it from DISPLAY environment variable */
  10.178  
  10.179 -	DGA_Display = XOpenDisplay(display);
  10.180 +	DGA_Display = pXOpenDisplay(display);
  10.181  	if ( DGA_Display == NULL ) {
  10.182  		SDL_SetError("Couldn't open X11 display");
  10.183  		return(-1);
  10.184 @@ -339,12 +349,12 @@
  10.185  	if ( ! SDL_NAME(XDGAQueryExtension)(DGA_Display, &event_base, &error_base) ||
  10.186  	     ! SDL_NAME(XDGAQueryVersion)(DGA_Display, &major_version, &minor_version) ) {
  10.187  		SDL_SetError("DGA extension not available");
  10.188 -		XCloseDisplay(DGA_Display);
  10.189 +		pXCloseDisplay(DGA_Display);
  10.190  		return(-1);
  10.191  	}
  10.192  	if ( major_version < 2 ) {
  10.193  		SDL_SetError("DGA driver requires DGA 2.0 or newer");
  10.194 -		XCloseDisplay(DGA_Display);
  10.195 +		pXCloseDisplay(DGA_Display);
  10.196  		return(-1);
  10.197  	}
  10.198  	DGA_event_base = event_base;
  10.199 @@ -356,10 +366,10 @@
  10.200  		int i, num_formats;
  10.201  
  10.202  		vformat->BitsPerPixel = DefaultDepth(DGA_Display, DGA_Screen);
  10.203 -		pix_format = XListPixmapFormats(DGA_Display, &num_formats);
  10.204 +		pix_format = pXListPixmapFormats(DGA_Display, &num_formats);
  10.205  		if ( pix_format == NULL ) {
  10.206  			SDL_SetError("Couldn't determine screen formats");
  10.207 -			XCloseDisplay(DGA_Display);
  10.208 +			pXCloseDisplay(DGA_Display);
  10.209  			return(-1);
  10.210  		}
  10.211  		for ( i=0; i<num_formats; ++i ) {
  10.212 @@ -368,7 +378,7 @@
  10.213  		}
  10.214  		if ( i != num_formats )
  10.215  			vformat->BitsPerPixel = pix_format[i].bits_per_pixel;
  10.216 -		XFree((char *)pix_format);
  10.217 +		pXFree((char *)pix_format);
  10.218  	}
  10.219  	if ( vformat->BitsPerPixel > 8 ) {
  10.220  		vformat->Rmask = visual->red_mask;
  10.221 @@ -379,7 +389,7 @@
  10.222  	/* Open access to the framebuffer */
  10.223  	if ( ! SDL_NAME(XDGAOpenFramebuffer)(DGA_Display, DGA_Screen) ) {
  10.224  		SDL_SetError("Unable to map the video memory");
  10.225 -		XCloseDisplay(DGA_Display);
  10.226 +		pXCloseDisplay(DGA_Display);
  10.227  		return(-1);
  10.228  	}
  10.229  
  10.230 @@ -399,7 +409,7 @@
  10.231  		}
  10.232  	}
  10.233  	UpdateHWInfo(this, modes);
  10.234 -	XFree(modes);
  10.235 +	pXFree(modes);
  10.236  
  10.237  	/* Create the hardware surface lock mutex */
  10.238  	hw_lock = SDL_CreateMutex();
  10.239 @@ -438,7 +448,7 @@
  10.240  
  10.241  	/* Free any previous colormap */
  10.242  	if ( DGA_colormap ) {
  10.243 -		XFreeColormap(DGA_Display, DGA_colormap);
  10.244 +		pXFreeColormap(DGA_Display, DGA_colormap);
  10.245  		DGA_colormap = 0;
  10.246  	}
  10.247  
  10.248 @@ -469,7 +479,7 @@
  10.249  
  10.250  	/* Set the video mode */
  10.251  	mode = SDL_NAME(XDGASetMode)(DGA_Display, DGA_Screen, modes[i].num);
  10.252 -	XFree(modes);
  10.253 +	pXFree(modes);
  10.254  	if ( mode == NULL ) {
  10.255  		SDL_SetError("Unable to switch to requested mode");
  10.256  		return(NULL);
  10.257 @@ -817,7 +827,7 @@
  10.258  #endif
  10.259  	SDL_NAME(XDGAFillRectangle)(DGA_Display, DGA_Screen, x, y, w, h, color);
  10.260  	if ( !(this->screen->flags & SDL_DOUBLEBUF) ) {
  10.261 -		XFlush(DGA_Display);
  10.262 +		pXFlush(DGA_Display);
  10.263  	}
  10.264  	DGA_AddBusySurface(dst);
  10.265  	UNLOCK_DISPLAY();
  10.266 @@ -859,7 +869,7 @@
  10.267  			srcx, srcy, w, h, dstx, dsty);
  10.268  	}
  10.269  	if ( !(this->screen->flags & SDL_DOUBLEBUF) ) {
  10.270 -		XFlush(DGA_Display);
  10.271 +		pXFlush(DGA_Display);
  10.272  	}
  10.273  	DGA_AddBusySurface(src);
  10.274  	DGA_AddBusySurface(dst);
  10.275 @@ -939,7 +949,7 @@
  10.276  	DGA_WaitFlip(this);
  10.277  	SDL_NAME(XDGASetViewport)(DGA_Display, DGA_Screen,
  10.278  	                0, flip_yoffset[flip_page], XDGAFlipRetrace);
  10.279 -	XFlush(DGA_Display);
  10.280 +	pXFlush(DGA_Display);
  10.281  	UNLOCK_DISPLAY();
  10.282  	was_flipped = 1;
  10.283  	flip_page = !flip_page;
  10.284 @@ -972,8 +982,8 @@
  10.285  		xcmap[i].flags = (DoRed|DoGreen|DoBlue);
  10.286  	}
  10.287  	LOCK_DISPLAY();
  10.288 -	XStoreColors(DGA_Display, DGA_colormap, xcmap, ncolors);
  10.289 -	XSync(DGA_Display, False);
  10.290 +	pXStoreColors(DGA_Display, DGA_colormap, xcmap, ncolors);
  10.291 +	pXSync(DGA_Display, False);
  10.292  	UNLOCK_DISPLAY();
  10.293  
  10.294  	/* That was easy. :) */
  10.295 @@ -1006,8 +1016,8 @@
  10.296  		xcmap[i].flags = (DoRed|DoGreen|DoBlue);
  10.297  	}
  10.298  	LOCK_DISPLAY();
  10.299 -	XStoreColors(DGA_Display, DGA_colormap, xcmap, ncolors);
  10.300 -	XSync(DGA_Display, False);
  10.301 +	pXStoreColors(DGA_Display, DGA_colormap, xcmap, ncolors);
  10.302 +	pXSync(DGA_Display, False);
  10.303  	UNLOCK_DISPLAY();
  10.304  	return(0);
  10.305  }
  10.306 @@ -1019,7 +1029,7 @@
  10.307  	if ( DGA_Display ) {
  10.308  		/* Free colormap, if necessary */
  10.309  		if ( DGA_colormap ) {
  10.310 -			XFreeColormap(DGA_Display, DGA_colormap);
  10.311 +			pXFreeColormap(DGA_Display, DGA_colormap);
  10.312  			DGA_colormap = 0;
  10.313  		}
  10.314  
  10.315 @@ -1059,6 +1069,6 @@
  10.316  		DGA_FreeHWSurfaces(this);
  10.317  
  10.318  		/* Close up the display */
  10.319 -		XCloseDisplay(DGA_Display);
  10.320 +		pXCloseDisplay(DGA_Display);
  10.321  	}
  10.322  }
    11.1 --- a/src/video/x11/Makefile.am	Sat Nov 05 17:41:11 2005 +0000
    11.2 +++ b/src/video/x11/Makefile.am	Sat Nov 05 19:53:37 2005 +0000
    11.3 @@ -4,6 +4,9 @@
    11.4  noinst_LTLIBRARIES = libvideo_x11.la
    11.5  libvideo_x11_la_SOURCES = $(X11_SRCS)
    11.6  
    11.7 +x11_lib = \"@x11_lib@\"
    11.8 +x11ext_lib = \"@x11ext_lib@\"
    11.9 +
   11.10  # The SDL X11 video driver sources
   11.11  X11_SRCS = 			\
   11.12  	SDL_x11dga.c		\
   11.13 @@ -25,4 +28,8 @@
   11.14  	SDL_x11wm.c		\
   11.15  	SDL_x11wm_c.h		\
   11.16  	SDL_x11yuv.c		\
   11.17 -	SDL_x11yuv_c.h
   11.18 +	SDL_x11yuv_c.h		\
   11.19 +	SDL_x11dyn.c		\
   11.20 +	SDL_x11dyn.h		\
   11.21 +	SDL_x11sym.h
   11.22 +
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/src/video/x11/SDL_x11dyn.c	Sat Nov 05 19:53:37 2005 +0000
    12.3 @@ -0,0 +1,127 @@
    12.4 +/*
    12.5 +    SDL - Simple DirectMedia Layer
    12.6 +    Copyright (C) 1997-2004 Sam Lantinga
    12.7 +
    12.8 +    This library is free software; you can redistribute it and/or
    12.9 +    modify it under the terms of the GNU Library General Public
   12.10 +    License as published by the Free Software Foundation; either
   12.11 +    version 2 of the License, or (at your option) any later version.
   12.12 +
   12.13 +    This library is distributed in the hope that it will be useful,
   12.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   12.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   12.16 +    Library General Public License for more details.
   12.17 +
   12.18 +    You should have received a copy of the GNU Library General Public
   12.19 +    License along with this library; if not, write to the Free
   12.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   12.21 +
   12.22 +    Sam Lantinga
   12.23 +    slouken@libsdl.org
   12.24 +*/
   12.25 +
   12.26 +/*#define DEBUG_DYNAMIC_X11 1*/
   12.27 +
   12.28 +#include "SDL_x11dyn.h"
   12.29 +
   12.30 +#ifdef DEBUG_DYNAMIC_X11
   12.31 +#include <stdio.h>
   12.32 +#endif
   12.33 +
   12.34 +#ifdef X11_DYNAMIC
   12.35 +#include <dlfcn.h>
   12.36 +#include "SDL_name.h"
   12.37 +#include "SDL_loadso.h"
   12.38 +static const char *x11_library = X11_DYNAMIC;
   12.39 +static void *x11_handle = NULL;
   12.40 +static const char *x11ext_library = X11EXT_DYNAMIC;
   12.41 +static void *x11ext_handle = NULL;
   12.42 +
   12.43 +static void *X11_GetSym(const char *fnname, int *rc)
   12.44 +{
   12.45 +	void *fn = NULL;
   12.46 +	if (*rc) {  /* haven't already failed on a previous lookup? */
   12.47 +		fn = SDL_LoadFunction(x11_handle, fnname);
   12.48 +		#if DEBUG_DYNAMIC_X11
   12.49 +		if (fn != NULL)
   12.50 +			printf("X11: Found '%s' in libX11 (%p)\n", fnname, fn);
   12.51 +		#endif
   12.52 +
   12.53 +		if (fn == NULL) {  /* not found? Check libX11ext ... */
   12.54 +			fn = SDL_LoadFunction(x11ext_handle, fnname);
   12.55 +			#if DEBUG_DYNAMIC_X11
   12.56 +			if (fn != NULL)
   12.57 +				printf("X11: Found '%s' in libXext (%p)\n", fnname, fn);
   12.58 +			else
   12.59 +				printf("X11: Symbol '%s' NOT FOUND!\n", fnname);
   12.60 +			#endif
   12.61 +		}
   12.62 +		*rc = (fn != NULL);
   12.63 +	}
   12.64 +
   12.65 +	return fn;
   12.66 +}
   12.67 +#endif  /* defined X11_DYNAMIC */
   12.68 +
   12.69 +/* Define all the function pointers... */
   12.70 +#define SDL_X11_SYM(ret,fn,params) ret (*p##fn) params = NULL;
   12.71 +#include "SDL_x11sym.h"
   12.72 +#undef SDL_X11_SYM
   12.73 +
   12.74 +static int x11_load_refcount = 0;
   12.75 +
   12.76 +void SDL_X11_UnloadSymbols(void)
   12.77 +{
   12.78 +	/* Don't actually unload if more than one module is using the libs... */
   12.79 +	if (x11_load_refcount > 0) {
   12.80 +		if (--x11_load_refcount == 0) {
   12.81 +			/* set all the function pointers to NULL. */
   12.82 +			#define SDL_X11_SYM(ret,fn,params) p##fn = NULL;
   12.83 +			#include "SDL_x11sym.h"
   12.84 +			#undef SDL_X11_SYM
   12.85 +
   12.86 +			#ifdef X11_DYNAMIC
   12.87 +			if (x11_handle != NULL) {
   12.88 +				SDL_UnloadObject(x11_handle);
   12.89 +				x11_handle = NULL;
   12.90 +			}
   12.91 +			if (x11ext_handle != NULL) {
   12.92 +				SDL_UnloadObject(x11ext_handle);
   12.93 +				x11ext_handle = NULL;
   12.94 +			}
   12.95 +			#endif
   12.96 +		}
   12.97 +	}
   12.98 +}
   12.99 +
  12.100 +/* returns non-zero if all needed symbols were loaded. */
  12.101 +int SDL_X11_LoadSymbols(void)
  12.102 +{
  12.103 +	int rc = 1;
  12.104 +
  12.105 +    /* deal with multiple modules (dga, x11, etc) needing these symbols... */
  12.106 +	if (x11_load_refcount++ == 0) {
  12.107 +		#ifdef X11_DYNAMIC
  12.108 +			x11_handle = SDL_LoadObject(x11_library);
  12.109 +			x11ext_handle = SDL_LoadObject(x11ext_library);
  12.110 +			if ((x11_handle != NULL) && (x11ext_handle != NULL)) {
  12.111 +				#define SDL_X11_SYM(r,fn,arg) p##fn = X11_GetSym(#fn, &rc);
  12.112 +				#include "SDL_x11sym.h"
  12.113 +				#undef SDL_X11_SYM
  12.114 +			}
  12.115 +
  12.116 +			if (!rc)
  12.117 +				SDL_X11_UnloadSymbols();  /* in case one of these loaded... */
  12.118 +
  12.119 +		#else
  12.120 +			#define SDL_X11_SYM(r,fn,arg) p##fn = fn;
  12.121 +			#include "SDL_x11sym.h"
  12.122 +			#undef SDL_X11_SYM
  12.123 +		#endif
  12.124 +	}
  12.125 +
  12.126 +	return rc;
  12.127 +}
  12.128 +
  12.129 +/* end of SDL_x11dyn.c ... */
  12.130 +
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/src/video/x11/SDL_x11dyn.h	Sat Nov 05 19:53:37 2005 +0000
    13.3 @@ -0,0 +1,71 @@
    13.4 +/*
    13.5 +    SDL - Simple DirectMedia Layer
    13.6 +    Copyright (C) 1997-2004 Sam Lantinga
    13.7 +
    13.8 +    This library is free software; you can redistribute it and/or
    13.9 +    modify it under the terms of the GNU Library General Public
   13.10 +    License as published by the Free Software Foundation; either
   13.11 +    version 2 of the License, or (at your option) any later version.
   13.12 +
   13.13 +    This library is distributed in the hope that it will be useful,
   13.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   13.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   13.16 +    Library General Public License for more details.
   13.17 +
   13.18 +    You should have received a copy of the GNU Library General Public
   13.19 +    License along with this library; if not, write to the Free
   13.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   13.21 +
   13.22 +    Sam Lantinga
   13.23 +    slouken@libsdl.org
   13.24 +*/
   13.25 +
   13.26 +#ifndef _SDL_x11dyn_h
   13.27 +#define _SDL_x11dyn_h
   13.28 +
   13.29 +#include <X11/Xlib.h>
   13.30 +#include <X11/Xutil.h>
   13.31 +#include <X11/Xatom.h>
   13.32 +#include <X11/Xproto.h>
   13.33 +#include <X11/Xlibint.h>
   13.34 +#include <X11/extensions/extutil.h>
   13.35 +
   13.36 +#ifndef NO_SHARED_MEMORY
   13.37 +#include <sys/ipc.h>
   13.38 +#include <sys/shm.h>
   13.39 +#include <X11/extensions/XShm.h>
   13.40 +#endif
   13.41 +
   13.42 +/*
   13.43 + * Never reference Xlib directly...we might load it dynamically at runtime.
   13.44 + *  Even if we don't, for readability, we still use the function pointers
   13.45 + *  (although the symbol resolution will be done by the loader in that case).
   13.46 + *
   13.47 + * We define SDL_X11_SYM and include SDL_x11sym.h to accomplish various
   13.48 + *  goals, without having to duplicate those function signatures.
   13.49 + */
   13.50 +#ifdef __cplusplus
   13.51 +extern "C" {
   13.52 +#endif
   13.53 +
   13.54 +/* evil function signatures... */
   13.55 +typedef Bool (*SDL_X11_XESetWireToEventRetType)(Display*,XEvent*,xEvent*);
   13.56 +typedef int (*SDL_X11_XSynchronizeRetType)(Display*);
   13.57 +typedef Status (*SDL_X11_XESetEventToWireRetType)(Display*,XEvent*,xEvent*);
   13.58 +
   13.59 +#define SDL_X11_SYM(ret,fn,params) extern ret (*p##fn) params;
   13.60 +#include "SDL_x11sym.h"
   13.61 +#undef SDL_X11_SYM
   13.62 +
   13.63 +/* Macro in the xlib headers, not an actual symbol... */
   13.64 +#define pXDestroyImage XDestroyImage
   13.65 +
   13.66 +int SDL_X11_LoadSymbols(void);
   13.67 +void SDL_X11_UnloadSymbols(void);
   13.68 +
   13.69 +#ifdef __cplusplus
   13.70 +}
   13.71 +#endif
   13.72 +
   13.73 +#endif  /* !defined _SDL_x11dyn_h */
   13.74 +
    14.1 --- a/src/video/x11/SDL_x11events.c	Sat Nov 05 17:41:11 2005 +0000
    14.2 +++ b/src/video/x11/SDL_x11events.c	Sat Nov 05 19:53:37 2005 +0000
    14.3 @@ -74,13 +74,13 @@
    14.4  	int repeated;
    14.5  
    14.6  	repeated = 0;
    14.7 -	if ( XPending(display) ) {
    14.8 -		XPeekEvent(display, &peekevent);
    14.9 +	if ( pXPending(display) ) {
   14.10 +		pXPeekEvent(display, &peekevent);
   14.11  		if ( (peekevent.type == KeyPress) &&
   14.12  		     (peekevent.xkey.keycode == event->xkey.keycode) &&
   14.13  		     ((peekevent.xkey.time-event->xkey.time) < 2) ) {
   14.14  			repeated = 1;
   14.15 -			XNextEvent(display, &peekevent);
   14.16 +			pXNextEvent(display, &peekevent);
   14.17  		}
   14.18  	}
   14.19  	return(repeated);
   14.20 @@ -115,7 +115,7 @@
   14.21  	     (xevent->xmotion.y < MOUSE_FUDGE_FACTOR) ||
   14.22  	     (xevent->xmotion.y > (h-MOUSE_FUDGE_FACTOR)) ) {
   14.23  		/* Get the events that have accumulated */
   14.24 -		while ( XCheckTypedEvent(SDL_Display, MotionNotify, xevent) ) {
   14.25 +		while ( pXCheckTypedEvent(SDL_Display, MotionNotify, xevent) ) {
   14.26  			deltax = xevent->xmotion.x - mouse_last.x;
   14.27  			deltay = xevent->xmotion.y - mouse_last.y;
   14.28  #ifdef DEBUG_MOTION
   14.29 @@ -127,10 +127,10 @@
   14.30  		}
   14.31  		mouse_last.x = w/2;
   14.32  		mouse_last.y = h/2;
   14.33 -		XWarpPointer(SDL_Display, None, SDL_Window, 0, 0, 0, 0,
   14.34 +		pXWarpPointer(SDL_Display, None, SDL_Window, 0, 0, 0, 0,
   14.35  					mouse_last.x, mouse_last.y);
   14.36  		for ( i=0; i<10; ++i ) {
   14.37 -        		XMaskEvent(SDL_Display, PointerMotionMask, xevent);
   14.38 +        		pXMaskEvent(SDL_Display, PointerMotionMask, xevent);
   14.39  			if ( (xevent->xmotion.x >
   14.40  			          (mouse_last.x-MOUSE_FUDGE_FACTOR)) &&
   14.41  			     (xevent->xmotion.x <
   14.42 @@ -160,7 +160,7 @@
   14.43  	XEvent xevent;
   14.44  
   14.45  	memset(&xevent, '\0', sizeof (XEvent));  /* valgrind fix. --ryan. */
   14.46 -	XNextEvent(SDL_Display, &xevent);
   14.47 +	pXNextEvent(SDL_Display, &xevent);
   14.48  
   14.49  	posted = 0;
   14.50  	switch (xevent.type) {
   14.51 @@ -437,8 +437,8 @@
   14.52  int X11_Pending(Display *display)
   14.53  {
   14.54  	/* Flush the display connection and look to see if events are queued */
   14.55 -	XFlush(display);
   14.56 -	if ( XEventsQueued(display, QueuedAlready) ) {
   14.57 +	pXFlush(display);
   14.58 +	if ( pXEventsQueued(display, QueuedAlready) ) {
   14.59  		return(1);
   14.60  	}
   14.61  
   14.62 @@ -452,7 +452,7 @@
   14.63  		FD_ZERO(&fdset);
   14.64  		FD_SET(x11_fd, &fdset);
   14.65  		if ( select(x11_fd+1, &fdset, NULL, NULL, &zero_time) == 1 ) {
   14.66 -			return(XPending(display));
   14.67 +			return(pXPending(display));
   14.68  		}
   14.69  	}
   14.70  
   14.71 @@ -619,7 +619,7 @@
   14.72  
   14.73  	/* Get the raw keyboard scancode */
   14.74  	keysym->scancode = kc;
   14.75 -	xsym = XKeycodeToKeysym(display, kc, 0);
   14.76 +	xsym = pXKeycodeToKeysym(display, kc, 0);
   14.77  #ifdef DEBUG_KEYS
   14.78  	fprintf(stderr, "Translating key 0x%.4x (%d)\n", xsym, kc);
   14.79  #endif
   14.80 @@ -711,7 +711,7 @@
   14.81  		}
   14.82  #endif
   14.83  		/* Look up the translated value for the key event */
   14.84 -		if ( XLookupString(xkey, (char *)keybuf, sizeof(keybuf),
   14.85 +		if ( pXLookupString(xkey, (char *)keybuf, sizeof(keybuf),
   14.86  							NULL, &state) ) {
   14.87  			/*
   14.88  			 * FIXME,: XLookupString() may yield more than one
   14.89 @@ -739,12 +739,12 @@
   14.90  	if(got_masks)
   14.91  		return;
   14.92  
   14.93 -	xmods = XGetModifierMapping(display);
   14.94 +	xmods = pXGetModifierMapping(display);
   14.95  	n = xmods->max_keypermod;
   14.96  	for(i = 3; i < 8; i++) {
   14.97  		for(j = 0; j < n; j++) {
   14.98  			KeyCode kc = xmods->modifiermap[i * n + j];
   14.99 -			KeySym ks = XKeycodeToKeysym(display, kc, 0);
  14.100 +			KeySym ks = pXKeycodeToKeysym(display, kc, 0);
  14.101  			unsigned mask = 1 << i;
  14.102  			switch(ks) {
  14.103  			case XK_Num_Lock:
  14.104 @@ -762,7 +762,7 @@
  14.105  			}
  14.106  		}
  14.107  	}
  14.108 -	XFreeModifiermap(xmods);
  14.109 +	pXFreeModifiermap(xmods);
  14.110  	got_masks = 1;
  14.111  }
  14.112  
  14.113 @@ -804,7 +804,7 @@
  14.114  		}
  14.115  	}
  14.116  
  14.117 -	xkey.keycode = XKeysymToKeycode(xkey.display, xsym);
  14.118 +	xkey.keycode = pXKeysymToKeycode(xkey.display, xsym);
  14.119  
  14.120  	get_modifier_masks(SDL_Display);
  14.121  	if(modifiers & KMOD_SHIFT)
  14.122 @@ -827,7 +827,7 @@
  14.123  		xkey.state |= num_mask;
  14.124  
  14.125  	unicode = 0;
  14.126 -	if ( XLookupString(&xkey, keybuf, sizeof(keybuf), NULL, NULL) )
  14.127 +	if ( pXLookupString(&xkey, keybuf, sizeof(keybuf), NULL, NULL) )
  14.128  		unicode = (unsigned char)keybuf[0];
  14.129  	return(unicode);
  14.130  }
  14.131 @@ -851,14 +851,14 @@
  14.132  
  14.133  	/* The first time the window is mapped, we initialize key state */
  14.134  	if ( ! key_vec ) {
  14.135 -		XQueryKeymap(display, keys_return);
  14.136 +		pXQueryKeymap(display, keys_return);
  14.137  		key_vec = keys_return;
  14.138  	}
  14.139  
  14.140  	/* Get the keyboard modifier state */
  14.141  	modstate = 0;
  14.142  	get_modifier_masks(display);
  14.143 -	if ( XQueryPointer(display, DefaultRootWindow(display),
  14.144 +	if ( pXQueryPointer(display, DefaultRootWindow(display),
  14.145  		&junk_window, &junk_window, &x, &y, &x, &y, &mask) ) {
  14.146  		if ( mask & LockMask ) {
  14.147  			modstate |= KMOD_CAPS;
    15.1 --- a/src/video/x11/SDL_x11gamma.c	Sat Nov 05 17:41:11 2005 +0000
    15.2 +++ b/src/video/x11/SDL_x11gamma.c	Sat Nov 05 19:53:37 2005 +0000
    15.3 @@ -68,7 +68,7 @@
    15.4  	}
    15.5          if ( SDL_GetAppState() & SDL_APPACTIVE ) {
    15.6              succeeded = SDL_NAME(XF86VidModeSetGamma)(SDL_Display, SDL_Screen, &gamma);
    15.7 -            XSync(SDL_Display, False);
    15.8 +            pXSync(SDL_Display, False);
    15.9          } else {
   15.10              gamma_saved[0] = gamma.red;
   15.11              gamma_saved[1] = gamma.green;
    16.1 --- a/src/video/x11/SDL_x11gl.c	Sat Nov 05 17:41:11 2005 +0000
    16.2 +++ b/src/video/x11/SDL_x11gl.c	Sat Nov 05 19:53:37 2005 +0000
    16.3 @@ -69,10 +69,10 @@
    16.4  		XVisualInfo vi_in;
    16.5  		int out_count;
    16.6  
    16.7 -		XGetWindowAttributes(SDL_Display, SDL_Window, &a);
    16.8 +		pXGetWindowAttributes(SDL_Display, SDL_Window, &a);
    16.9  		vi_in.screen = SDL_Screen;
   16.10 -		vi_in.visualid = XVisualIDFromVisual(a.visual);
   16.11 -		glx_visualinfo = XGetVisualInfo(SDL_Display,
   16.12 +		vi_in.visualid = pXVisualIDFromVisual(a.visual);
   16.13 +		glx_visualinfo = pXGetVisualInfo(SDL_Display,
   16.14  	                     VisualScreenMask|VisualIDMask, &vi_in, &out_count);
   16.15  		return glx_visualinfo;
   16.16  	}
   16.17 @@ -188,7 +188,7 @@
   16.18  	attributes.colormap = SDL_XColorMap;
   16.19  	mask = CWBackPixel | CWBorderPixel | CWColormap;
   16.20  
   16.21 -	SDL_Window = XCreateWindow(SDL_Display, WMwindow,
   16.22 +	SDL_Window = pXCreateWindow(SDL_Display, WMwindow,
   16.23  			0, 0, w, h, 0, glx_visualinfo->depth,
   16.24  			InputOutput, glx_visualinfo->visual,
   16.25  			mask, &attributes);
   16.26 @@ -209,10 +209,10 @@
   16.27  	int retval;
   16.28  #ifdef HAVE_OPENGL
   16.29  	/* We do this to create a clean separation between X and GLX errors. */
   16.30 -	XSync( SDL_Display, False );
   16.31 +	pXSync( SDL_Display, False );
   16.32  	glx_context = this->gl_data->glXCreateContext(GFX_Display, 
   16.33  				     glx_visualinfo, NULL, True);
   16.34 -	XSync( GFX_Display, False );
   16.35 +	pXSync( GFX_Display, False );
   16.36  
   16.37  	if (glx_context == NULL) {
   16.38  		SDL_SetError("Could not create GL context");
   16.39 @@ -296,7 +296,7 @@
   16.40  		SDL_SetError("Unable to make GL context current");
   16.41  		retval = -1;
   16.42  	}
   16.43 -	XSync( GFX_Display, False );
   16.44 +	pXSync( GFX_Display, False );
   16.45  
   16.46  	/* 
   16.47  	 * The context is now current, check for glXReleaseBuffersMESA() 
    17.1 --- a/src/video/x11/SDL_x11image.c	Sat Nov 05 17:41:11 2005 +0000
    17.2 +++ b/src/video/x11/SDL_x11image.c	Sat Nov 05 19:53:37 2005 +0000
    17.3 @@ -35,9 +35,6 @@
    17.4  
    17.5  #ifndef NO_SHARED_MEMORY
    17.6  
    17.7 -/* Shared memory information */
    17.8 -extern int XShmQueryExtension(Display *dpy);	/* Not in X11 headers */
    17.9 -
   17.10  /* Shared memory error handler routine */
   17.11  static int shm_error;
   17.12  static int (*X_handler)(Display *, XErrorEvent *) = NULL;
   17.13 @@ -61,10 +58,10 @@
   17.14  		shminfo.readOnly = False;
   17.15  		if ( shminfo.shmaddr != (char *)-1 ) {
   17.16  			shm_error = False;
   17.17 -			X_handler = XSetErrorHandler(shm_errhandler);
   17.18 -			XShmAttach(SDL_Display, &shminfo);
   17.19 -			XSync(SDL_Display, True);
   17.20 -			XSetErrorHandler(X_handler);
   17.21 +			X_handler = pXSetErrorHandler(shm_errhandler);
   17.22 +			pXShmAttach(SDL_Display, &shminfo);
   17.23 +			pXSync(SDL_Display, True);
   17.24 +			pXSetErrorHandler(X_handler);
   17.25  			if ( shm_error )
   17.26  				shmdt(shminfo.shmaddr);
   17.27  		} else {
   17.28 @@ -90,13 +87,13 @@
   17.29  #ifndef NO_SHARED_MEMORY
   17.30  	try_mitshm(this, screen);
   17.31  	if(use_mitshm) {
   17.32 -		SDL_Ximage = XShmCreateImage(SDL_Display, SDL_Visual,
   17.33 +		SDL_Ximage = pXShmCreateImage(SDL_Display, SDL_Visual,
   17.34  					     this->hidden->depth, ZPixmap,
   17.35  					     shminfo.shmaddr, &shminfo, 
   17.36  					     screen->w, screen->h);
   17.37  		if(!SDL_Ximage) {
   17.38 -			XShmDetach(SDL_Display, &shminfo);
   17.39 -			XSync(SDL_Display, False);
   17.40 +			pXShmDetach(SDL_Display, &shminfo);
   17.41 +			pXSync(SDL_Display, False);
   17.42  			shmdt(shminfo.shmaddr);
   17.43  			screen->pixels = NULL;
   17.44  			goto error;
   17.45 @@ -113,7 +110,7 @@
   17.46  			return -1;
   17.47  		}
   17.48   	        bpp = screen->format->BytesPerPixel;
   17.49 -		SDL_Ximage = XCreateImage(SDL_Display, SDL_Visual,
   17.50 +		SDL_Ximage = pXCreateImage(SDL_Display, SDL_Visual,
   17.51  					  this->hidden->depth, ZPixmap, 0,
   17.52  					  (char *)screen->pixels, 
   17.53  					  screen->w, screen->h,
   17.54 @@ -136,11 +133,11 @@
   17.55  void X11_DestroyImage(_THIS, SDL_Surface *screen)
   17.56  {
   17.57  	if ( SDL_Ximage ) {
   17.58 -		XDestroyImage(SDL_Ximage);
   17.59 +		pXDestroyImage(SDL_Ximage);
   17.60  #ifndef NO_SHARED_MEMORY
   17.61  		if ( use_mitshm ) {
   17.62 -			XShmDetach(SDL_Display, &shminfo);
   17.63 -			XSync(SDL_Display, False);
   17.64 +			pXShmDetach(SDL_Display, &shminfo);
   17.65 +			pXSync(SDL_Display, False);
   17.66  			shmdt(shminfo.shmaddr);
   17.67  		}
   17.68  #endif /* ! NO_SHARED_MEMORY */
   17.69 @@ -221,7 +218,7 @@
   17.70  int X11_LockHWSurface(_THIS, SDL_Surface *surface)
   17.71  {
   17.72  	if ( (surface == SDL_VideoSurface) && blit_queued ) {
   17.73 -		XSync(GFX_Display, False);
   17.74 +		pXSync(GFX_Display, False);
   17.75  		blit_queued = 0;
   17.76  	}
   17.77  	return(0);
   17.78 @@ -244,15 +241,15 @@
   17.79  		if ( rects[i].w == 0 || rects[i].h == 0 ) { /* Clipped? */
   17.80  			continue;
   17.81  		}
   17.82 -		XPutImage(GFX_Display, SDL_Window, SDL_GC, SDL_Ximage,
   17.83 +		pXPutImage(GFX_Display, SDL_Window, SDL_GC, SDL_Ximage,
   17.84  			  rects[i].x, rects[i].y,
   17.85  			  rects[i].x, rects[i].y, rects[i].w, rects[i].h);
   17.86  	}
   17.87  	if ( SDL_VideoSurface->flags & SDL_ASYNCBLIT ) {
   17.88 -		XFlush(GFX_Display);
   17.89 +		pXFlush(GFX_Display);
   17.90  		blit_queued = 1;
   17.91  	} else {
   17.92 -		XSync(GFX_Display, False);
   17.93 +		pXSync(GFX_Display, False);
   17.94  	}
   17.95  }
   17.96  
   17.97 @@ -265,16 +262,16 @@
   17.98  		if ( rects[i].w == 0 || rects[i].h == 0 ) { /* Clipped? */
   17.99  			continue;
  17.100  		}
  17.101 -		XShmPutImage(GFX_Display, SDL_Window, SDL_GC, SDL_Ximage,
  17.102 +		pXShmPutImage(GFX_Display, SDL_Window, SDL_GC, SDL_Ximage,
  17.103  				rects[i].x, rects[i].y,
  17.104  				rects[i].x, rects[i].y, rects[i].w, rects[i].h,
  17.105  									False);
  17.106  	}
  17.107  	if ( SDL_VideoSurface->flags & SDL_ASYNCBLIT ) {
  17.108 -		XFlush(GFX_Display);
  17.109 +		pXFlush(GFX_Display);
  17.110  		blit_queued = 1;
  17.111  	} else {
  17.112 -		XSync(GFX_Display, False);
  17.113 +		pXSync(GFX_Display, False);
  17.114  	}
  17.115  #endif /* ! NO_SHARED_MEMORY */
  17.116  }
  17.117 @@ -308,14 +305,14 @@
  17.118  	}
  17.119  #ifndef NO_SHARED_MEMORY
  17.120  	if ( this->UpdateRects == X11_MITSHMUpdate ) {
  17.121 -		XShmPutImage(SDL_Display, SDL_Window, SDL_GC, SDL_Ximage,
  17.122 +		pXShmPutImage(SDL_Display, SDL_Window, SDL_GC, SDL_Ximage,
  17.123  				0, 0, 0, 0, this->screen->w, this->screen->h,
  17.124  				False);
  17.125  	} else
  17.126  #endif /* ! NO_SHARED_MEMORY */
  17.127  	{
  17.128 -		XPutImage(SDL_Display, SDL_Window, SDL_GC, SDL_Ximage,
  17.129 +		pXPutImage(SDL_Display, SDL_Window, SDL_GC, SDL_Ximage,
  17.130  			  0, 0, 0, 0, this->screen->w, this->screen->h);
  17.131  	}
  17.132 -	XSync(SDL_Display, False);
  17.133 +	pXSync(SDL_Display, False);
  17.134  }
    18.1 --- a/src/video/x11/SDL_x11modes.c	Sat Nov 05 17:41:11 2005 +0000
    18.2 +++ b/src/video/x11/SDL_x11modes.c	Sat Nov 05 19:53:37 2005 +0000
    18.3 @@ -141,7 +141,7 @@
    18.4                   (modes[i]->vdisplay != mode.vdisplay) ) {
    18.5                  SDL_NAME(XF86VidModeSwitchToMode)(SDL_Display, SDL_Screen, modes[i]);
    18.6              }
    18.7 -            XFree(modes);
    18.8 +            pXFree(modes);
    18.9          }
   18.10      }
   18.11  #endif /* XFREE86_VM */
   18.12 @@ -180,7 +180,7 @@
   18.13                                          SDL_modelist[i]->w, 
   18.14                                          SDL_modelist[i]->h, 
   18.15                                          0);
   18.16 -                XSync(SDL_Display, False);
   18.17 +                pXSync(SDL_Display, False);
   18.18              }
   18.19          }
   18.20      }
   18.21 @@ -230,7 +230,7 @@
   18.22  {
   18.23      XEvent event;
   18.24      do {
   18.25 -        XMaskEvent(SDL_Display, StructureNotifyMask, &event);
   18.26 +        pXMaskEvent(SDL_Display, StructureNotifyMask, &event);
   18.27      } while ( (event.type != MapNotify) || (event.xmap.event != win) );
   18.28  }
   18.29  
   18.30 @@ -239,19 +239,19 @@
   18.31  {
   18.32      XEvent event;
   18.33      do {
   18.34 -        XMaskEvent(SDL_Display, StructureNotifyMask, &event);
   18.35 +        pXMaskEvent(SDL_Display, StructureNotifyMask, &event);
   18.36      } while ( (event.type != UnmapNotify) || (event.xunmap.event != win) );
   18.37  }
   18.38  
   18.39  static void move_cursor_to(_THIS, int x, int y)
   18.40  {
   18.41 -    XWarpPointer(SDL_Display, None, SDL_Root, 0, 0, 0, 0, x, y);
   18.42 +    pXWarpPointer(SDL_Display, None, SDL_Root, 0, 0, 0, 0, x, y);
   18.43  }
   18.44  
   18.45  static int add_visual(_THIS, int depth, int class)
   18.46  {
   18.47      XVisualInfo vi;
   18.48 -    if(XMatchVisualInfo(SDL_Display, SDL_Screen, depth, class, &vi)) {
   18.49 +    if(pXMatchVisualInfo(SDL_Display, SDL_Screen, depth, class, &vi)) {
   18.50          int n = this->hidden->nvisuals;
   18.51          this->hidden->visuals[n].depth = vi.depth;
   18.52          this->hidden->visuals[n].visual = vi.visual;
   18.53 @@ -267,13 +267,13 @@
   18.54      if ( visual_id ) {
   18.55          memset(&template, 0, (sizeof template));
   18.56          template.visualid = strtol(visual_id, NULL, 0);
   18.57 -        vi = XGetVisualInfo(SDL_Display, VisualIDMask, &template, &nvis);
   18.58 +        vi = pXGetVisualInfo(SDL_Display, VisualIDMask, &template, &nvis);
   18.59          if ( vi ) {
   18.60              int n = this->hidden->nvisuals;
   18.61              this->hidden->visuals[n].depth = vi->depth;
   18.62              this->hidden->visuals[n].visual = vi->visual;
   18.63              this->hidden->nvisuals++;
   18.64 -            XFree(vi);
   18.65 +            pXFree(vi);
   18.66          }
   18.67      }
   18.68      return(this->hidden->nvisuals);
   18.69 @@ -400,7 +400,7 @@
   18.70              }
   18.71              SDL_modelist[n] = NULL;
   18.72          }
   18.73 -        XFree(modes);
   18.74 +        pXFree(modes);
   18.75  
   18.76          use_vidmode = vm_major * 100 + vm_minor;
   18.77          save_mode(this);
   18.78 @@ -474,7 +474,7 @@
   18.79          use_xme = 0;
   18.80      }
   18.81      if ( modelist ) {
   18.82 -        XFree(modelist);
   18.83 +        pXFree(modelist);
   18.84      }
   18.85  #endif /* HAVE_XIGXME */
   18.86  
   18.87 @@ -509,7 +509,7 @@
   18.88          }
   18.89              
   18.90          /* look up the pixel quantum for each depth */
   18.91 -        pf = XListPixmapFormats(SDL_Display, &np);
   18.92 +        pf = pXListPixmapFormats(SDL_Display, &np);
   18.93          for(i = 0; i < this->hidden->nvisuals; i++) {
   18.94              int d = this->hidden->visuals[i].depth;
   18.95              for(j = 0; j < np; j++)
   18.96 @@ -518,7 +518,7 @@
   18.97              this->hidden->visuals[i].bpp = j < np ? pf[j].bits_per_pixel : d;
   18.98          }
   18.99  
  18.100 -        XFree(pf);
  18.101 +        pXFree(pf);
  18.102      }
  18.103  
  18.104      if ( SDL_modelist == NULL ) {
  18.105 @@ -592,7 +592,7 @@
  18.106                  xinerama_y = xinerama[i].y_org;
  18.107              }
  18.108          }
  18.109 -        XFree(xinerama);
  18.110 +        pXFree(xinerama);
  18.111      }
  18.112  #endif /* HAVE_XINERAMA */
  18.113  
  18.114 @@ -658,15 +658,15 @@
  18.115          if ( current_h > real_h ) {
  18.116              real_h = MAX(real_h, screen_h);
  18.117          }
  18.118 -        XMoveResizeWindow(SDL_Display, FSwindow, x, y, real_w, real_h);
  18.119 +        pXMoveResizeWindow(SDL_Display, FSwindow, x, y, real_w, real_h);
  18.120          move_cursor_to(this, real_w/2, real_h/2);
  18.121  
  18.122          /* Center and reparent the drawing window */
  18.123          x = (real_w - current_w)/2;
  18.124          y = (real_h - current_h)/2;
  18.125 -        XReparentWindow(SDL_Display, SDL_Window, FSwindow, x, y);
  18.126 +        pXReparentWindow(SDL_Display, SDL_Window, FSwindow, x, y);
  18.127          /* FIXME: move the mouse to the old relative location */
  18.128 -        XSync(SDL_Display, True);   /* Flush spurious mode change events */
  18.129 +        pXSync(SDL_Display, True);   /* Flush spurious mode change events */
  18.130      }
  18.131      return(1);
  18.132  }
  18.133 @@ -676,7 +676,7 @@
  18.134      switch_waiting = 0x01 | SDL_FULLSCREEN;
  18.135      switch_time = SDL_GetTicks() + 1500;
  18.136  #if 0 /* This causes a BadMatch error if the window is iconified (not needed) */
  18.137 -    XSetInputFocus(SDL_Display, WMwindow, RevertToNone, CurrentTime);
  18.138 +    pXSetInputFocus(SDL_Display, WMwindow, RevertToNone, CurrentTime);
  18.139  #endif
  18.140  }
  18.141  
  18.142 @@ -709,14 +709,14 @@
  18.143      if ( current_h > real_h ) {
  18.144          real_h = MAX(real_h, screen_h);
  18.145      }
  18.146 -    XMoveResizeWindow(SDL_Display, FSwindow,
  18.147 +    pXMoveResizeWindow(SDL_Display, FSwindow,
  18.148                        xinerama_x, xinerama_y, real_w, real_h);
  18.149 -    XMapRaised(SDL_Display, FSwindow);
  18.150 +    pXMapRaised(SDL_Display, FSwindow);
  18.151      X11_WaitMapped(this, FSwindow);
  18.152  
  18.153  #if 0 /* This seems to break WindowMaker in focus-follows-mouse mode */
  18.154      /* Make sure we got to the top of the window stack */
  18.155 -    if ( XQueryTree(SDL_Display, SDL_Root, &tmpwin, &tmpwin,
  18.156 +    if ( pXQueryTree(SDL_Display, SDL_Root, &tmpwin, &tmpwin,
  18.157                              &windows, &nwindows) && windows ) {
  18.158          /* If not, try to put us there - if fail... oh well */
  18.159          if ( windows[nwindows-1] != FSwindow ) {
  18.160 @@ -729,13 +729,13 @@
  18.161                  }
  18.162              }
  18.163              windows[nwindows-1] = FSwindow;
  18.164 -            XRestackWindows(SDL_Display, windows, nwindows);
  18.165 -            XSync(SDL_Display, False);
  18.166 +            pXRestackWindows(SDL_Display, windows, nwindows);
  18.167 +            pXSync(SDL_Display, False);
  18.168          }
  18.169 -        XFree(windows);
  18.170 +        pXFree(windows);
  18.171      }
  18.172  #else
  18.173 -    XRaiseWindow(SDL_Display, FSwindow);
  18.174 +    pXRaiseWindow(SDL_Display, FSwindow);
  18.175  #endif
  18.176  
  18.177  #ifdef XFREE86_VM
  18.178 @@ -753,7 +753,7 @@
  18.179      }
  18.180      /* Set the colormap */
  18.181      if ( SDL_XColorMap ) {
  18.182 -        XInstallColormap(SDL_Display, SDL_XColorMap);
  18.183 +        pXInstallColormap(SDL_Display, SDL_XColorMap);
  18.184      }
  18.185      if ( okay )
  18.186          X11_GrabInputNoLock(this, this->input_grab | SDL_GRAB_FULLSCREEN);
  18.187 @@ -774,7 +774,7 @@
  18.188  int X11_LeaveFullScreen(_THIS)
  18.189  {
  18.190      if ( currently_fullscreen ) {
  18.191 -        XReparentWindow(SDL_Display, SDL_Window, WMwindow, 0, 0);
  18.192 +        pXReparentWindow(SDL_Display, SDL_Window, WMwindow, 0, 0);
  18.193  #ifdef XFREE86_VM
  18.194          if ( use_vidmode ) {
  18.195              restore_mode(this);
  18.196 @@ -796,14 +796,14 @@
  18.197                                          saved_res.width, 
  18.198                                          saved_res.height,
  18.199                                          0);
  18.200 -                XSync(SDL_Display, False);
  18.201 +                pXSync(SDL_Display, False);
  18.202              }
  18.203          }
  18.204  #endif
  18.205  
  18.206 -        XUnmapWindow(SDL_Display, FSwindow);
  18.207 +        pXUnmapWindow(SDL_Display, FSwindow);
  18.208          X11_WaitUnmapped(this, FSwindow);
  18.209 -        XSync(SDL_Display, True);   /* Flush spurious mode change events */
  18.210 +        pXSync(SDL_Display, True);   /* Flush spurious mode change events */
  18.211          currently_fullscreen = 0;
  18.212      }
  18.213      /* If we get popped out of fullscreen mode for some reason, input_grab
    19.1 --- a/src/video/x11/SDL_x11mouse.c	Sat Nov 05 17:41:11 2005 +0000
    19.2 +++ b/src/video/x11/SDL_x11mouse.c	Sat Nov 05 19:53:37 2005 +0000
    19.3 @@ -50,8 +50,8 @@
    19.4  {
    19.5  	if ( SDL_Display != NULL ) {
    19.6  		SDL_Lock_EventThread();
    19.7 -		XFreeCursor(SDL_Display, cursor->x_cursor);
    19.8 -		XSync(SDL_Display, False);
    19.9 +		pXFreeCursor(SDL_Display, cursor->x_cursor);
   19.10 +		pXSync(SDL_Display, False);
   19.11  		SDL_Unlock_EventThread();
   19.12  	}
   19.13  	free(cursor);
   19.14 @@ -105,48 +105,48 @@
   19.15  	SDL_Lock_EventThread();
   19.16  
   19.17  	/* Create the data image */
   19.18 -	data_image = XCreateImage(SDL_Display, 
   19.19 +	data_image = pXCreateImage(SDL_Display, 
   19.20  			DefaultVisual(SDL_Display, SDL_Screen),
   19.21  					1, XYBitmap, 0, x_data, w, h, 8, w/8);
   19.22  	data_image->byte_order = MSBFirst;
   19.23  	data_image->bitmap_bit_order = MSBFirst;
   19.24 -	data_pixmap = XCreatePixmap(SDL_Display, SDL_Root, w, h, 1);
   19.25 +	data_pixmap = pXCreatePixmap(SDL_Display, SDL_Root, w, h, 1);
   19.26  
   19.27  	/* Create the data mask */
   19.28 -	mask_image = XCreateImage(SDL_Display, 
   19.29 +	mask_image = pXCreateImage(SDL_Display, 
   19.30  			DefaultVisual(SDL_Display, SDL_Screen),
   19.31  					1, XYBitmap, 0, x_mask, w, h, 8, w/8);
   19.32  	mask_image->byte_order = MSBFirst;
   19.33  	mask_image->bitmap_bit_order = MSBFirst;
   19.34 -	mask_pixmap = XCreatePixmap(SDL_Display, SDL_Root, w, h, 1);
   19.35 +	mask_pixmap = pXCreatePixmap(SDL_Display, SDL_Root, w, h, 1);
   19.36  
   19.37  	/* Create the graphics context */
   19.38  	GCvalues.function = GXcopy;
   19.39  	GCvalues.foreground = ~0;
   19.40  	GCvalues.background =  0;
   19.41  	GCvalues.plane_mask = AllPlanes;
   19.42 -	GCcursor = XCreateGC(SDL_Display, data_pixmap,
   19.43 +	GCcursor = pXCreateGC(SDL_Display, data_pixmap,
   19.44  			(GCFunction|GCForeground|GCBackground|GCPlaneMask),
   19.45  								&GCvalues);
   19.46  
   19.47  	/* Blit the images to the pixmaps */
   19.48 -	XPutImage(SDL_Display, data_pixmap, GCcursor, data_image,
   19.49 +	pXPutImage(SDL_Display, data_pixmap, GCcursor, data_image,
   19.50  							0, 0, 0, 0, w, h);
   19.51 -	XPutImage(SDL_Display, mask_pixmap, GCcursor, mask_image,
   19.52 +	pXPutImage(SDL_Display, mask_pixmap, GCcursor, mask_image,
   19.53  							0, 0, 0, 0, w, h);
   19.54 -	XFreeGC(SDL_Display, GCcursor);
   19.55 +	pXFreeGC(SDL_Display, GCcursor);
   19.56  	/* These free the x_data and x_mask memory pointers */
   19.57 -	XDestroyImage(data_image);
   19.58 -	XDestroyImage(mask_image);
   19.59 +	pXDestroyImage(data_image);
   19.60 +	pXDestroyImage(mask_image);
   19.61  
   19.62  	/* Create the cursor */
   19.63 -	cursor->x_cursor = XCreatePixmapCursor(SDL_Display, data_pixmap,
   19.64 +	cursor->x_cursor = pXCreatePixmapCursor(SDL_Display, data_pixmap,
   19.65  				mask_pixmap, &black, &white, hot_x, hot_y);
   19.66 -	XFreePixmap(SDL_Display, data_pixmap);
   19.67 -	XFreePixmap(SDL_Display, mask_pixmap);
   19.68 +	pXFreePixmap(SDL_Display, data_pixmap);
   19.69 +	pXFreePixmap(SDL_Display, mask_pixmap);
   19.70  
   19.71  	/* Release the event thread */
   19.72 -	XSync(SDL_Display, False);
   19.73 +	pXSync(SDL_Display, False);
   19.74  	SDL_Unlock_EventThread();
   19.75  
   19.76  	return(cursor);
   19.77 @@ -164,13 +164,13 @@
   19.78  		SDL_Lock_EventThread();
   19.79  		if ( cursor == NULL ) {
   19.80  			if ( SDL_BlankCursor != NULL ) {
   19.81 -				XDefineCursor(SDL_Display, SDL_Window,
   19.82 +				pXDefineCursor(SDL_Display, SDL_Window,
   19.83  					SDL_BlankCursor->x_cursor);
   19.84  			}
   19.85  		} else {
   19.86 -			XDefineCursor(SDL_Display, SDL_Window, cursor->x_cursor);
   19.87 +			pXDefineCursor(SDL_Display, SDL_Window, cursor->x_cursor);
   19.88  		}
   19.89 -		XSync(SDL_Display, False);
   19.90 +		pXSync(SDL_Display, False);
   19.91  		SDL_Unlock_EventThread();
   19.92  	}
   19.93  	return(1);
   19.94 @@ -187,8 +187,8 @@
   19.95  		SDL_PrivateMouseMotion(0, 0, x, y);
   19.96  	} else {
   19.97  		SDL_Lock_EventThread();
   19.98 -		XWarpPointer(SDL_Display, None, SDL_Window, 0, 0, 0, 0, x, y);
   19.99 -		XSync(SDL_Display, False);
  19.100 +		pXWarpPointer(SDL_Display, None, SDL_Window, 0, 0, 0, 0, x, y);
  19.101 +		pXSync(SDL_Display, False);
  19.102  		SDL_Unlock_EventThread();
  19.103  	}
  19.104  }
  19.105 @@ -224,7 +224,7 @@
  19.106  		}
  19.107  	}
  19.108  	if ( mouse_param_buf ) {
  19.109 -		XChangePointerControl(SDL_Display, True, True,
  19.110 +		pXChangePointerControl(SDL_Display, True, True,
  19.111  			accel_value[0], accel_value[1], accel_value[2]);
  19.112  		free(mouse_param_buf);
  19.113  	}
  19.114 @@ -257,7 +257,7 @@
  19.115  
  19.116  				SDL_GetMouseState(&mouse_last.x, &mouse_last.y);
  19.117  				/* Use as raw mouse mickeys as possible */
  19.118 -				XGetPointerControl(SDL_Display,
  19.119 +				pXGetPointerControl(SDL_Display,
  19.120  						&mouse_accel.numerator, 
  19.121  						&mouse_accel.denominator,
  19.122  						&mouse_accel.threshold);
  19.123 @@ -273,7 +273,7 @@
  19.124  			if ( using_dga & DGA_MOUSE ) {
  19.125  				X11_DisableDGAMouse(this);
  19.126  			} else {
  19.127 -				XChangePointerControl(SDL_Display, True, True,
  19.128 +				pXChangePointerControl(SDL_Display, True, True,
  19.129  						mouse_accel.numerator, 
  19.130  						mouse_accel.denominator,
  19.131  						mouse_accel.threshold);
    20.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.2 +++ b/src/video/x11/SDL_x11sym.h	Sat Nov 05 19:53:37 2005 +0000
    20.3 @@ -0,0 +1,144 @@
    20.4 +/*
    20.5 +    SDL - Simple DirectMedia Layer
    20.6 +    Copyright (C) 1997-2004 Sam Lantinga
    20.7 +
    20.8 +    This library is free software; you can redistribute it and/or
    20.9 +    modify it under the terms of the GNU Library General Public
   20.10 +    License as published by the Free Software Foundation; either
   20.11 +    version 2 of the License, or (at your option) any later version.
   20.12 +
   20.13 +    This library is distributed in the hope that it will be useful,
   20.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   20.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   20.16 +    Library General Public License for more details.
   20.17 +
   20.18 +    You should have received a copy of the GNU Library General Public
   20.19 +    License along with this library; if not, write to the Free
   20.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   20.21 +
   20.22 +    Sam Lantinga
   20.23 +    slouken@libsdl.org
   20.24 +*/
   20.25 +
   20.26 +SDL_X11_SYM(XClassHint*,XAllocClassHint,(void))
   20.27 +SDL_X11_SYM(Status,XAllocColor,(Display*,Colormap,XColor*))
   20.28 +SDL_X11_SYM(XSizeHints*,XAllocSizeHints,(void))
   20.29 +SDL_X11_SYM(XWMHints*,XAllocWMHints,(void))
   20.30 +SDL_X11_SYM(int,XChangePointerControl,(Display*,Bool,Bool,int,int,int))
   20.31 +SDL_X11_SYM(int,XChangeProperty,(Display*,Window,Atom,Atom,int,int,_Xconst unsigned char*,int))
   20.32 +SDL_X11_SYM(int,XChangeWindowAttributes,(Display*,Window,unsigned long,XSetWindowAttributes*))
   20.33 +SDL_X11_SYM(Bool,XCheckTypedEvent,(Display*,int,XEvent*))
   20.34 +SDL_X11_SYM(int,XClearWindow,(Display*,Window))
   20.35 +SDL_X11_SYM(int,XCloseDisplay,(Display*))
   20.36 +SDL_X11_SYM(Colormap,XCreateColormap,(Display*,Window,Visual*,int))
   20.37 +SDL_X11_SYM(Cursor,XCreatePixmapCursor,(Display*,Pixmap,Pixmap,XColor*,XColor*,unsigned int,unsigned int))
   20.38 +SDL_X11_SYM(GC,XCreateGC,(Display*,Drawable,unsigned long,XGCValues*))
   20.39 +SDL_X11_SYM(XImage*,XCreateImage,(Display*,Visual*,unsigned int,int,int,char*,unsigned int,unsigned int,int,int))
   20.40 +SDL_X11_SYM(Pixmap,XCreatePixmap,(Display*,Drawable,unsigned int,unsigned int,unsigned int))
   20.41 +SDL_X11_SYM(Pixmap,XCreatePixmapFromBitmapData,(Display*,Drawable,char*,unsigned int,unsigned int,unsigned long,unsigned long,unsigned int))
   20.42 +SDL_X11_SYM(Window,XCreateSimpleWindow,(Display*,Window,int,int,unsigned int,unsigned int,unsigned int,unsigned long,unsigned long))
   20.43 +SDL_X11_SYM(Window,XCreateWindow,(Display*,Window,int,int,unsigned int,unsigned int,unsigned int,int,unsigned int,Visual*,unsigned long,XSetWindowAttributes*))
   20.44 +SDL_X11_SYM(int,XDefineCursor,(Display*,Window,Cursor))
   20.45 +SDL_X11_SYM(int,XDeleteProperty,(Display*,Window,Atom))
   20.46 +SDL_X11_SYM(int,XDestroyWindow,(Display*,Window))
   20.47 +SDL_X11_SYM(char*,XDisplayName,(_Xconst char*))
   20.48 +SDL_X11_SYM(int,XEventsQueued,(Display*,int))
   20.49 +SDL_X11_SYM(int,XFlush,(Display*))
   20.50 +SDL_X11_SYM(int,XFree,(void*))
   20.51 +SDL_X11_SYM(int,XFreeColormap,(Display*,Colormap))
   20.52 +SDL_X11_SYM(int,XFreeColors,(Display*,Colormap,unsigned long*,int,unsigned long))
   20.53 +SDL_X11_SYM(int,XFreeCursor,(Display*,Cursor))
   20.54 +SDL_X11_SYM(int,XFreeGC,(Display*,GC))
   20.55 +SDL_X11_SYM(int,XFreeModifiermap,(XModifierKeymap*))
   20.56 +SDL_X11_SYM(int,XFreePixmap,(Display*,Pixmap))
   20.57 +SDL_X11_SYM(int,XGetErrorDatabaseText,(Display*,_Xconst char*,_Xconst char*,_Xconst char*,char*,int))
   20.58 +SDL_X11_SYM(XModifierKeymap*,XGetModifierMapping,(Display*))
   20.59 +SDL_X11_SYM(int,XGetPointerControl,(Display*,int*,int*,int*))
   20.60 +SDL_X11_SYM(XVisualInfo*,XGetVisualInfo,(Display*,long,XVisualInfo*,int*))
   20.61 +SDL_X11_SYM(XWMHints*,XGetWMHints,(Display*,Window))
   20.62 +SDL_X11_SYM(Status,XGetWMIconName,(Display*,Window,XTextProperty*))
   20.63 +SDL_X11_SYM(Status,XGetWMName,(Display*,Window,XTextProperty*))
   20.64 +SDL_X11_SYM(Status,XGetWindowAttributes,(Display*,Window,XWindowAttributes*))
   20.65 +SDL_X11_SYM(int,XGrabKeyboard,(Display*,Window,Bool,int,int,Time))
   20.66 +SDL_X11_SYM(int,XGrabPointer,(Display*,Window,Bool,unsigned int,int,int,Window,Cursor,Time))
   20.67 +SDL_X11_SYM(Status,XIconifyWindow,(Display*,Window,int))
   20.68 +SDL_X11_SYM(int,XInstallColormap,(Display*,Colormap))
   20.69 +SDL_X11_SYM(KeyCode,XKeysymToKeycode,(Display*,KeySym))
   20.70 +SDL_X11_SYM(Atom,XInternAtom,(Display*,_Xconst char*,Bool))
   20.71 +SDL_X11_SYM(XPixmapFormatValues*,XListPixmapFormats,(Display*,int*))
   20.72 +SDL_X11_SYM(int,XLookupString,(XKeyEvent*,char*,int,KeySym*,XComposeStatus*))
   20.73 +SDL_X11_SYM(int,XMapRaised,(Display*,Window))
   20.74 +SDL_X11_SYM(int,XMapWindow,(Display*,Window))
   20.75 +SDL_X11_SYM(int,XMaskEvent,(Display*,long,XEvent*))
   20.76 +SDL_X11_SYM(Status,XMatchVisualInfo,(Display*,int,int,int,XVisualInfo*))
   20.77 +SDL_X11_SYM(int,XMissingExtension,(Display*,_Xconst char*))
   20.78 +SDL_X11_SYM(int,XMoveResizeWindow,(Display*,Window,int,int,unsigned int,unsigned int))
   20.79 +SDL_X11_SYM(int,XMoveWindow,(Display*,Window,int,int))
   20.80 +SDL_X11_SYM(int,XNextEvent,(Display*,XEvent*))
   20.81 +SDL_X11_SYM(Display*,XOpenDisplay,(_Xconst char*))
   20.82 +SDL_X11_SYM(int,XPeekEvent,(Display*,XEvent*))
   20.83 +SDL_X11_SYM(int,XPending,(Display*))
   20.84 +SDL_X11_SYM(int,XPutImage,(Display*,Drawable,GC,XImage*,int,int,int,int,unsigned int,unsigned int))
   20.85 +SDL_X11_SYM(int,XQueryColors,(Display*,Colormap,XColor*,int))
   20.86 +SDL_X11_SYM(int,XQueryKeymap,(Display*,char [32]))
   20.87 +SDL_X11_SYM(Bool,XQueryPointer,(Display*,Window,Window*,Window*,int*,int*,int*,int*,unsigned int*))
   20.88 +SDL_X11_SYM(int,XRaiseWindow,(Display*,Window))
   20.89 +SDL_X11_SYM(int,XReparentWindow,(Display*,Window,Window,int,int))
   20.90 +SDL_X11_SYM(int,XResizeWindow,(Display*,Window,unsigned int,unsigned int))
   20.91 +SDL_X11_SYM(int,XSelectInput,(Display*,Window,long))
   20.92 +SDL_X11_SYM(Status,XSendEvent,(Display*,Window,Bool,long,XEvent*))
   20.93 +SDL_X11_SYM(int,XSetClassHint,(Display*,Window,XClassHint*))
   20.94 +SDL_X11_SYM(XErrorHandler,XSetErrorHandler,(XErrorHandler))
   20.95 +SDL_X11_SYM(XIOErrorHandler,XSetIOErrorHandler,(XIOErrorHandler))
   20.96 +SDL_X11_SYM(int,XSetTransientForHint,(Display*,Window,Window))
   20.97 +SDL_X11_SYM(int,XSetWMHints,(Display*,Window,XWMHints*))
   20.98 +SDL_X11_SYM(void,XSetWMIconName,(Display*,Window,XTextProperty*))
   20.99 +SDL_X11_SYM(void,XSetWMName,(Display*,Window,XTextProperty*))
  20.100 +SDL_X11_SYM(void,XSetWMNormalHints,(Display*,Window,XSizeHints*))
  20.101 +SDL_X11_SYM(Status,XSetWMProtocols,(Display*,Window,Atom*,int))
  20.102 +SDL_X11_SYM(int,XSetWindowBackground,(Display*,Window,unsigned long))
  20.103 +SDL_X11_SYM(int,XSetWindowBackgroundPixmap,(Display*,Window,Pixmap))
  20.104 +SDL_X11_SYM(int,XSetWindowColormap,(Display*,Window,Colormap))
  20.105 +SDL_X11_SYM(int,XStoreColors,(Display*,Colormap,XColor*,int))
  20.106 +SDL_X11_SYM(Status,XStringListToTextProperty,(char**,int,XTextProperty*))
  20.107 +SDL_X11_SYM(int,XSync,(Display*,Bool))
  20.108 +SDL_X11_SYM(int,XUngrabKeyboard,(Display*,Time))
  20.109 +SDL_X11_SYM(int,XUngrabPointer,(Display*,Time))
  20.110 +SDL_X11_SYM(int,XUnmapWindow,(Display*,Window))
  20.111 +SDL_X11_SYM(int,XWarpPointer,(Display*,Window,Window,int,int,unsigned int,unsigned int,int,int))
  20.112 +SDL_X11_SYM(VisualID,XVisualIDFromVisual,(Visual*))
  20.113 +SDL_X11_SYM(XExtDisplayInfo*,XextAddDisplay,(XExtensionInfo*,Display*,char*,XExtensionHooks*,int,XPointer))
  20.114 +SDL_X11_SYM(XExtensionInfo*,XextCreateExtension,(void))
  20.115 +SDL_X11_SYM(void,XextDestroyExtension,(XExtensionInfo*))
  20.116 +SDL_X11_SYM(XExtDisplayInfo*,XextFindDisplay,(XExtensionInfo*,Display*))
  20.117 +SDL_X11_SYM(int,XextRemoveDisplay,(XExtensionInfo*,Display*))
  20.118 +SDL_X11_SYM(int,Xutf8TextListToTextProperty,(Display*,char**,int,XICCEncodingStyle,XTextProperty*))
  20.119 +SDL_X11_SYM(void,_XEatData,(Display*,unsigned long))
  20.120 +SDL_X11_SYM(void,_XFlush,(Display*))
  20.121 +SDL_X11_SYM(void,_XFlushGCCache,(Display*,GC))
  20.122 +SDL_X11_SYM(int,_XRead,(Display*,char*,long))
  20.123 +SDL_X11_SYM(void,_XReadPad,(Display*,char*,long))
  20.124 +SDL_X11_SYM(void,_XSend,(Display*,_Xconst char*,long))
  20.125 +SDL_X11_SYM(Status,_XReply,(Display*,xReply*,int,Bool))
  20.126 +SDL_X11_SYM(unsigned long,_XSetLastRequestRead,(Display*,xGenericReply*))
  20.127 +
  20.128 +#if NeedWidePrototypes
  20.129 +SDL_X11_SYM(KeySym,XKeycodeToKeysym,(Display*,unsigned int,int))
  20.130 +#else
  20.131 +SDL_X11_SYM(KeySym,XKeycodeToKeysym,(Display*,KeyCode,int))
  20.132 +#endif
  20.133 +
  20.134 +#ifndef NO_SHARED_MEMORY
  20.135 +SDL_X11_SYM(Status,XShmAttach,(Display*,XShmSegmentInfo*))
  20.136 +SDL_X11_SYM(Status,XShmDetach,(Display*,XShmSegmentInfo*))
  20.137 +SDL_X11_SYM(Status,XShmPutImage,(Display*,Drawable,GC,XImage*,int,int,int,int,unsigned int,unsigned int,Bool))
  20.138 +SDL_X11_SYM(XImage*,XShmCreateImage,(Display*,Visual*,unsigned int,int,char*,XShmSegmentInfo*,unsigned int,unsigned int))
  20.139 +SDL_X11_SYM(Bool,XShmQueryExtension,(Display*))
  20.140 +#endif
  20.141 +
  20.142 +SDL_X11_SYM(SDL_X11_XSynchronizeRetType,XSynchronize,(Display*,Bool))
  20.143 +SDL_X11_SYM(SDL_X11_XESetWireToEventRetType,XESetWireToEvent,(Display*,int,SDL_X11_XESetWireToEventRetType))
  20.144 +SDL_X11_SYM(SDL_X11_XESetEventToWireRetType,XESetEventToWire,(Display*,int,SDL_X11_XESetEventToWireRetType))
  20.145 +
  20.146 +/* end of SDL_x11sym.h ... */
  20.147 +
    21.1 --- a/src/video/x11/SDL_x11video.c	Sat Nov 05 17:41:11 2005 +0000
    21.2 +++ b/src/video/x11/SDL_x11video.c	Sat Nov 05 19:53:37 2005 +0000
    21.3 @@ -85,15 +85,18 @@
    21.4  static int X11_SetGammaRamp(_THIS, Uint16 *ramp);
    21.5  static void X11_VideoQuit(_THIS);
    21.6  
    21.7 +
    21.8  /* X11 driver bootstrap functions */
    21.9  
   21.10  static int X11_Available(void)
   21.11  {
   21.12 -	Display *display;
   21.13 -
   21.14 -	display = XOpenDisplay(NULL);
   21.15 -	if ( display != NULL ) {
   21.16 -		XCloseDisplay(display);
   21.17 +	Display *display = NULL;
   21.18 +	if ( SDL_X11_LoadSymbols() ) {
   21.19 +		display = pXOpenDisplay(NULL);
   21.20 +		if ( display != NULL ) {
   21.21 +			pXCloseDisplay(display);
   21.22 +		}
   21.23 +		SDL_X11_UnloadSymbols();
   21.24  	}
   21.25  	return(display != NULL);
   21.26  }
   21.27 @@ -108,80 +111,83 @@
   21.28  			free(device->gl_data);
   21.29  		}
   21.30  		free(device);
   21.31 +		SDL_X11_UnloadSymbols();
   21.32  	}
   21.33  }
   21.34  
   21.35  static SDL_VideoDevice *X11_CreateDevice(int devindex)
   21.36  {
   21.37 -	SDL_VideoDevice *device;
   21.38 +	SDL_VideoDevice *device = NULL;
   21.39  
   21.40 -	/* Initialize all variables that we clean on shutdown */
   21.41 -	device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice));
   21.42 -	if ( device ) {
   21.43 -		memset(device, 0, (sizeof *device));
   21.44 -		device->hidden = (struct SDL_PrivateVideoData *)
   21.45 -				malloc((sizeof *device->hidden));
   21.46 -		device->gl_data = (struct SDL_PrivateGLData *)
   21.47 -				malloc((sizeof *device->gl_data));
   21.48 +	if ( SDL_X11_LoadSymbols() ) {
   21.49 +		/* Initialize all variables that we clean on shutdown */
   21.50 +		device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice));
   21.51 +		if ( device ) {
   21.52 +			memset(device, 0, (sizeof *device));
   21.53 +			device->hidden = (struct SDL_PrivateVideoData *)
   21.54 +					malloc((sizeof *device->hidden));
   21.55 +			device->gl_data = (struct SDL_PrivateGLData *)
   21.56 +					malloc((sizeof *device->gl_data));
   21.57 +		}
   21.58 +		if ( (device == NULL) || (device->hidden == NULL) ||
   21.59 +		                         (device->gl_data == NULL) ) {
   21.60 +			SDL_OutOfMemory();
   21.61 +			X11_DeleteDevice(device); /* calls SDL_X11_UnloadSymbols(). */
   21.62 +			return(0);
   21.63 +		}
   21.64 +		memset(device->hidden, 0, (sizeof *device->hidden));
   21.65 +		memset(device->gl_data, 0, (sizeof *device->gl_data));
   21.66 +
   21.67 +		/* Set the driver flags */
   21.68 +		device->handles_any_size = 1;
   21.69 +
   21.70 +		/* Set the function pointers */
   21.71 +		device->VideoInit = X11_VideoInit;
   21.72 +		device->ListModes = X11_ListModes;
   21.73 +		device->SetVideoMode = X11_SetVideoMode;
   21.74 +		device->ToggleFullScreen = X11_ToggleFullScreen;
   21.75 +		device->UpdateMouse = X11_UpdateMouse;
   21.76 +#ifdef XFREE86_XV
   21.77 +		device->CreateYUVOverlay = X11_CreateYUVOverlay;
   21.78 +#endif
   21.79 +		device->SetColors = X11_SetColors;
   21.80 +		device->UpdateRects = NULL;
   21.81 +		device->VideoQuit = X11_VideoQuit;
   21.82 +		device->AllocHWSurface = X11_AllocHWSurface;
   21.83 +		device->CheckHWBlit = NULL;
   21.84 +		device->FillHWRect = NULL;
   21.85 +		device->SetHWColorKey = NULL;
   21.86 +		device->SetHWAlpha = NULL;
   21.87 +		device->LockHWSurface = X11_LockHWSurface;
   21.88 +		device->UnlockHWSurface = X11_UnlockHWSurface;
   21.89 +		device->FlipHWSurface = X11_FlipHWSurface;
   21.90 +		device->FreeHWSurface = X11_FreeHWSurface;
   21.91 +		device->SetGamma = X11_SetVidModeGamma;
   21.92 +		device->GetGamma = X11_GetVidModeGamma;
   21.93 +		device->SetGammaRamp = X11_SetGammaRamp;
   21.94 +		device->GetGammaRamp = NULL;
   21.95 +#ifdef HAVE_OPENGL
   21.96 +		device->GL_LoadLibrary = X11_GL_LoadLibrary;
   21.97 +		device->GL_GetProcAddress = X11_GL_GetProcAddress;
   21.98 +		device->GL_GetAttribute = X11_GL_GetAttribute;
   21.99 +		device->GL_MakeCurrent = X11_GL_MakeCurrent;
  21.100 +		device->GL_SwapBuffers = X11_GL_SwapBuffers;
  21.101 +#endif
  21.102 +		device->SetCaption = X11_SetCaption;
  21.103 +		device->SetIcon = X11_SetIcon;
  21.104 +		device->IconifyWindow = X11_IconifyWindow;
  21.105 +		device->GrabInput = X11_GrabInput;
  21.106 +		device->GetWMInfo = X11_GetWMInfo;
  21.107 +		device->FreeWMCursor = X11_FreeWMCursor;
  21.108 +		device->CreateWMCursor = X11_CreateWMCursor;
  21.109 +		device->ShowWMCursor = X11_ShowWMCursor;
  21.110 +		device->WarpWMCursor = X11_WarpWMCursor;
  21.111 +		device->CheckMouseMode = X11_CheckMouseMode;
  21.112 +		device->InitOSKeymap = X11_InitOSKeymap;
  21.113 +		device->PumpEvents = X11_PumpEvents;
  21.114 +
  21.115 +		device->free = X11_DeleteDevice;
  21.116  	}
  21.117 -	if ( (device == NULL) || (device->hidden == NULL) ||
  21.118 -	                         (device->gl_data == NULL) ) {
  21.119 -		SDL_OutOfMemory();
  21.120 -		X11_DeleteDevice(device);
  21.121 -		return(0);
  21.122 -	}
  21.123 -	memset(device->hidden, 0, (sizeof *device->hidden));
  21.124 -	memset(device->gl_data, 0, (sizeof *device->gl_data));
  21.125 -
  21.126 -	/* Set the driver flags */
  21.127 -	device->handles_any_size = 1;
  21.128 -
  21.129 -	/* Set the function pointers */
  21.130 -	device->VideoInit = X11_VideoInit;
  21.131 -	device->ListModes = X11_ListModes;
  21.132 -	device->SetVideoMode = X11_SetVideoMode;
  21.133 -	device->ToggleFullScreen = X11_ToggleFullScreen;
  21.134 -	device->UpdateMouse = X11_UpdateMouse;
  21.135 -#ifdef XFREE86_XV
  21.136 -	device->CreateYUVOverlay = X11_CreateYUVOverlay;
  21.137 -#endif
  21.138 -	device->SetColors = X11_SetColors;
  21.139 -	device->UpdateRects = NULL;
  21.140 -	device->VideoQuit = X11_VideoQuit;
  21.141 -	device->AllocHWSurface = X11_AllocHWSurface;
  21.142 -	device->CheckHWBlit = NULL;
  21.143 -	device->FillHWRect = NULL;
  21.144 -	device->SetHWColorKey = NULL;
  21.145 -	device->SetHWAlpha = NULL;
  21.146 -	device->LockHWSurface = X11_LockHWSurface;
  21.147 -	device->UnlockHWSurface = X11_UnlockHWSurface;
  21.148 -	device->FlipHWSurface = X11_FlipHWSurface;
  21.149 -	device->FreeHWSurface = X11_FreeHWSurface;
  21.150 -	device->SetGamma = X11_SetVidModeGamma;
  21.151 -	device->GetGamma = X11_GetVidModeGamma;
  21.152 -	device->SetGammaRamp = X11_SetGammaRamp;
  21.153 -	device->GetGammaRamp = NULL;
  21.154 -#ifdef HAVE_OPENGL
  21.155 -	device->GL_LoadLibrary = X11_GL_LoadLibrary;
  21.156 -	device->GL_GetProcAddress = X11_GL_GetProcAddress;
  21.157 -	device->GL_GetAttribute = X11_GL_GetAttribute;
  21.158 -	device->GL_MakeCurrent = X11_GL_MakeCurrent;
  21.159 -	device->GL_SwapBuffers = X11_GL_SwapBuffers;
  21.160 -#endif
  21.161 -	device->SetCaption = X11_SetCaption;
  21.162 -	device->SetIcon = X11_SetIcon;
  21.163 -	device->IconifyWindow = X11_IconifyWindow;
  21.164 -	device->GrabInput = X11_GrabInput;
  21.165 -	device->GetWMInfo = X11_GetWMInfo;
  21.166 -	device->FreeWMCursor = X11_FreeWMCursor;
  21.167 -	device->CreateWMCursor = X11_CreateWMCursor;
  21.168 -	device->ShowWMCursor = X11_ShowWMCursor;
  21.169 -	device->WarpWMCursor = X11_WarpWMCursor;
  21.170 -	device->CheckMouseMode = X11_CheckMouseMode;
  21.171 -	device->InitOSKeymap = X11_InitOSKeymap;
  21.172 -	device->PumpEvents = X11_PumpEvents;
  21.173 -
  21.174 -	device->free = X11_DeleteDevice;
  21.175  
  21.176  	return device;
  21.177  }
  21.178 @@ -191,9 +197,6 @@
  21.179  	X11_Available, X11_CreateDevice
  21.180  };
  21.181  
  21.182 -/* Shared memory information */
  21.183 -extern int XShmQueryExtension(Display *dpy);	/* Not in X11 headers */
  21.184 -
  21.185  /* Normal X11 error handler routine */
  21.186  static int (*X_handler)(Display *, XErrorEvent *) = NULL;
  21.187  static int x_errhandler(Display *d, XErrorEvent *e)
  21.188 @@ -275,21 +278,21 @@
  21.189      }
  21.190  
  21.191      if(FSwindow)
  21.192 -	XDestroyWindow(SDL_Display, FSwindow);
  21.193 +	pXDestroyWindow(SDL_Display, FSwindow);
  21.194  
  21.195      xattr.override_redirect = True;
  21.196      xattr.background_pixel = def_vis ? BlackPixel(SDL_Display, SDL_Screen) : 0;
  21.197      xattr.border_pixel = 0;
  21.198      xattr.colormap = SDL_XColorMap;
  21.199  
  21.200 -    FSwindow = XCreateWindow(SDL_Display, SDL_Root,
  21.201 +    FSwindow = pXCreateWindow(SDL_Display, SDL_Root,
  21.202                               xinerama_x, xinerama_y, 32, 32, 0,
  21.203  			     this->hidden->depth, InputOutput, SDL_Visual,
  21.204  			     CWOverrideRedirect | CWBackPixel | CWBorderPixel
  21.205  			     | CWColormap,
  21.206  			     &xattr);
  21.207  
  21.208 -    XSelectInput(SDL_Display, FSwindow, StructureNotifyMask);
  21.209 +    pXSelectInput(SDL_Display, FSwindow, StructureNotifyMask);
  21.210  
  21.211      /* Tell KDE to keep the fullscreen window on top */
  21.212      {
  21.213 @@ -299,57 +302,57 @@
  21.214  	memset(&ev, 0, sizeof(ev));
  21.215  	ev.xclient.type = ClientMessage;
  21.216  	ev.xclient.window = SDL_Root;
  21.217 -	ev.xclient.message_type = XInternAtom(SDL_Display,
  21.218 +	ev.xclient.message_type = pXInternAtom(SDL_Display,
  21.219  					      "KWM_KEEP_ON_TOP", False);
  21.220  	ev.xclient.format = 32;
  21.221  	ev.xclient.data.l[0] = FSwindow;
  21.222  	ev.xclient.data.l[1] = CurrentTime;
  21.223  	mask = SubstructureRedirectMask;
  21.224 -	XSendEvent(SDL_Display, SDL_Root, False, mask, &ev);
  21.225 +	pXSendEvent(SDL_Display, SDL_Root, False, mask, &ev);
  21.226      }
  21.227  
  21.228      hints = NULL;
  21.229      titleprop.value = iconprop.value = NULL;
  21.230      if(WMwindow) {
  21.231  	/* All window attributes must survive the recreation */
  21.232 -	hints = XGetWMHints(SDL_Display, WMwindow);
  21.233 -	XGetWMName(SDL_Display, WMwindow, &titleprop);
  21.234 -	XGetWMIconName(SDL_Display, WMwindow, &iconprop);
  21.235 -	XDestroyWindow(SDL_Display, WMwindow);
  21.236 +	hints = pXGetWMHints(SDL_Display, WMwindow);
  21.237 +	pXGetWMName(SDL_Display, WMwindow, &titleprop);
  21.238 +	pXGetWMIconName(SDL_Display, WMwindow, &iconprop);
  21.239 +	pXDestroyWindow(SDL_Display, WMwindow);
  21.240      }
  21.241  
  21.242      /* Create the window for windowed management */
  21.243      /* (reusing the xattr structure above) */
  21.244 -    WMwindow = XCreateWindow(SDL_Display, SDL_Root, 0, 0, 32, 32, 0,
  21.245 +    WMwindow = pXCreateWindow(SDL_Display, SDL_Root, 0, 0, 32, 32, 0,
  21.246  			     this->hidden->depth, InputOutput, SDL_Visual,
  21.247  			     CWBackPixel | CWBorderPixel | CWColormap,
  21.248  			     &xattr);
  21.249  
  21.250      /* Set the input hints so we get keyboard input */
  21.251      if(!hints) {
  21.252 -	hints = XAllocWMHints();
  21.253 +	hints = pXAllocWMHints();
  21.254  	hints->input = True;
  21.255  	hints->flags = InputHint;
  21.256      }
  21.257 -    XSetWMHints(SDL_Display, WMwindow, hints);
  21.258 -    XFree(hints);
  21.259 +    pXSetWMHints(SDL_Display, WMwindow, hints);
  21.260 +    pXFree(hints);
  21.261      if(titleprop.value) {
  21.262 -	XSetWMName(SDL_Display, WMwindow, &titleprop);
  21.263 -	XFree(titleprop.value);
  21.264 +	pXSetWMName(SDL_Display, WMwindow, &titleprop);
  21.265 +	pXFree(titleprop.value);
  21.266      }
  21.267      if(iconprop.value) {
  21.268 -	XSetWMIconName(SDL_Display, WMwindow, &iconprop);
  21.269 -	XFree(iconprop.value);
  21.270 +	pXSetWMIconName(SDL_Display, WMwindow, &iconprop);
  21.271 +	pXFree(iconprop.value);
  21.272      }
  21.273  
  21.274 -    XSelectInput(SDL_Display, WMwindow,
  21.275 +    pXSelectInput(SDL_Display, WMwindow,
  21.276  		 FocusChangeMask | KeyPressMask | KeyReleaseMask
  21.277  		 | PropertyChangeMask | StructureNotifyMask | KeymapStateMask);
  21.278  
  21.279      /* Set the class hints so we can get an icon (AfterStep) */
  21.280      {
  21.281  	XClassHint *classhints;
  21.282 -	classhints = XAllocClassHint();
  21.283 +	classhints = pXAllocClassHint();
  21.284  	if(classhints != NULL) {
  21.285              char *classname = getenv("SDL_VIDEO_X11_WMCLASS");
  21.286              if ( ! classname ) {
  21.287 @@ -357,14 +360,14 @@
  21.288              }
  21.289  	    classhints->res_name = classname;
  21.290  	    classhints->res_class = classname;
  21.291 -	    XSetClassHint(SDL_Display, WMwindow, classhints);
  21.292 -	    XFree(classhints);
  21.293 +	    pXSetClassHint(SDL_Display, WMwindow, classhints);
  21.294 +	    pXFree(classhints);
  21.295  	}
  21.296      }
  21.297  
  21.298      /* Allow the window to be deleted by the window manager */
  21.299 -    WM_DELETE_WINDOW = XInternAtom(SDL_Display, "WM_DELETE_WINDOW", False);
  21.300 -    XSetWMProtocols(SDL_Display, WMwindow, &WM_DELETE_WINDOW, 1);
  21.301 +    WM_DELETE_WINDOW = pXInternAtom(SDL_Display, "WM_DELETE_WINDOW", False);
  21.302 +    pXSetWMProtocols(SDL_Display, WMwindow, &WM_DELETE_WINDOW, 1);
  21.303  }
  21.304  
  21.305  static int X11_VideoInit(_THIS, SDL_PixelFormat *vformat)
  21.306 @@ -375,36 +378,36 @@
  21.307  	/* Open the X11 display */
  21.308  	display = NULL;		/* Get it from DISPLAY environment variable */
  21.309  
  21.310 -	if ( (strncmp(XDisplayName(display), ":", 1) == 0) ||
  21.311 -	     (strncmp(XDisplayName(display), "unix:", 5) == 0) ) {
  21.312 +	if ( (strncmp(pXDisplayName(display), ":", 1) == 0) ||
  21.313 +	     (strncmp(pXDisplayName(display), "unix:", 5) == 0) ) {
  21.314  		local_X11 = 1;
  21.315  	} else {
  21.316  		local_X11 = 0;
  21.317  	}
  21.318 -	SDL_Display = XOpenDisplay(display);
  21.319 +	SDL_Display = pXOpenDisplay(display);
  21.320  	if ( SDL_Display == NULL ) {
  21.321  		SDL_SetError("Couldn't open X11 display");
  21.322  		return(-1);
  21.323  	}
  21.324  #ifdef X11_DEBUG
  21.325 -	XSynchronize(SDL_Display, True);
  21.326 +	pXSynchronize(SDL_Display, True);
  21.327  #endif
  21.328  
  21.329  	/* Create an alternate X display for graphics updates -- allows us
  21.330  	   to do graphics updates in a separate thread from event handling.
  21.331  	   Thread-safe X11 doesn't seem to exist.
  21.332  	 */
  21.333 -	GFX_Display = XOpenDisplay(display);
  21.334 +	GFX_Display = pXOpenDisplay(display);
  21.335  	if ( GFX_Display == NULL ) {
  21.336  		SDL_SetError("Couldn't open X11 display");
  21.337  		return(-1);
  21.338  	}
  21.339  
  21.340  	/* Set the normal X error handler */
  21.341 -	X_handler = XSetErrorHandler(x_errhandler);
  21.342 +	X_handler = pXSetErrorHandler(x_errhandler);
  21.343  
  21.344  	/* Set the error handler if we lose the X display */
  21.345 -	XIO_handler = XSetIOErrorHandler(xio_errhandler);
  21.346 +	XIO_handler = pXSetIOErrorHandler(xio_errhandler);
  21.347  
  21.348  	/* use default screen (from $DISPLAY) */
  21.349  	SDL_Screen = DefaultScreen(SDL_Display);
  21.350 @@ -413,7 +416,7 @@
  21.351  	/* Check for MIT shared memory extension */
  21.352  	use_mitshm = 0;
  21.353  	if ( local_X11 ) {
  21.354 -		use_mitshm = XShmQueryExtension(SDL_Display);
  21.355 +		use_mitshm = pXShmQueryExtension(SDL_Display);
  21.356  	}
  21.357  #endif /* NO_SHARED_MEMORY */
  21.358  
  21.359 @@ -436,7 +439,7 @@
  21.360  	if ( SDL_Visual == DefaultVisual(SDL_Display, SDL_Screen) ) {
  21.361  	    SDL_XColorMap = SDL_DisplayColormap;
  21.362  	} else {
  21.363 -	    SDL_XColorMap = XCreateColormap(SDL_Display, SDL_Root,
  21.364 +	    SDL_XColorMap = pXCreateColormap(SDL_Display, SDL_Root,
  21.365  					    SDL_Visual, AllocNone);
  21.366  	}
  21.367  	this->hidden->depth = this->hidden->visuals[i].depth;
  21.368 @@ -463,7 +466,7 @@
  21.369  	this->info.wm_available = 1;
  21.370  
  21.371  	/* We're done! */
  21.372 -	XFlush(SDL_Display);
  21.373 +	pXFlush(SDL_Display);
  21.374  	return(0);
  21.375  }
  21.376  
  21.377 @@ -478,7 +481,7 @@
  21.378  	if ( ! SDL_windowid ) {
  21.379  		/* Hide the managed window */
  21.380  		if ( WMwindow ) {
  21.381 -			XUnmapWindow(SDL_Display, WMwindow);
  21.382 +			pXUnmapWindow(SDL_Display, WMwindow);
  21.383  		}
  21.384  		if ( screen && (screen->flags & SDL_FULLSCREEN) ) {
  21.385  			screen->flags &= ~SDL_FULLSCREEN;
  21.386 @@ -487,7 +490,7 @@
  21.387  
  21.388  		/* Destroy the output window */
  21.389  		if ( SDL_Window ) {
  21.390 -			XDestroyWindow(SDL_Display, SDL_Window);
  21.391 +			pXDestroyWindow(SDL_Display, SDL_Window);
  21.392  		}
  21.393  
  21.394  		/* Free the colormap entries */
  21.395 @@ -497,7 +500,7 @@
  21.396  			numcolors = SDL_Visual->map_entries;
  21.397  			for ( pixel=0; pixel<numcolors; ++pixel ) {
  21.398  				while ( SDL_XPixels[pixel] > 0 ) {
  21.399 -					XFreeColors(GFX_Display,
  21.400 +					pXFreeColors(GFX_Display,
  21.401  						SDL_DisplayColormap,&pixel,1,0);
  21.402  					--SDL_XPixels[pixel];
  21.403  				}
  21.404 @@ -508,7 +511,7 @@
  21.405  
  21.406  		/* Free the graphics context */
  21.407  		if ( SDL_GC ) {
  21.408 -			XFreeGC(SDL_Display, SDL_GC);
  21.409 +			pXFreeGC(SDL_Display, SDL_GC);
  21.410  			SDL_GC = 0;
  21.411  		}
  21.412  	}
  21.413 @@ -538,7 +541,7 @@
  21.414  {
  21.415  	XSizeHints *hints;
  21.416  
  21.417 -	hints = XAllocSizeHints();
  21.418 +	hints = pXAllocSizeHints();
  21.419  	if ( hints ) {
  21.420  		if ( flags & SDL_RESIZABLE ) {
  21.421  			hints->min_width = 32;
  21.422 @@ -558,13 +561,13 @@
  21.423  		/* Center it, if desired */
  21.424  		if ( X11_WindowPosition(this, &hints->x, &hints->y, w, h) ) {
  21.425  			hints->flags |= USPosition;
  21.426 -			XMoveWindow(SDL_Display, WMwindow, hints->x, hints->y);
  21.427 +			pXMoveWindow(SDL_Display, WMwindow, hints->x, hints->y);
  21.428  
  21.429  			/* Flush the resize event so we don't catch it later */
  21.430 -			XSync(SDL_Display, True);
  21.431 +			pXSync(SDL_Display, True);
  21.432  		}
  21.433 -		XSetWMNormalHints(SDL_Display, WMwindow, hints);
  21.434 -		XFree(hints);
  21.435 +		pXSetWMNormalHints(SDL_Display, WMwindow, hints);
  21.436 +		pXFree(hints);
  21.437  	}
  21.438  
  21.439  	/* Respect the window caption style */
  21.440 @@ -576,7 +579,7 @@
  21.441  		set = SDL_FALSE;
  21.442  
  21.443  		/* First try to set MWM hints */
  21.444 -		WM_HINTS = XInternAtom(SDL_Display, "_MOTIF_WM_HINTS", True);
  21.445 +		WM_HINTS = pXInternAtom(SDL_Display, "_MOTIF_WM_HINTS", True);
  21.446  		if ( WM_HINTS != None ) {
  21.447  			/* Hints used by Motif compliant window managers */
  21.448  			struct {
  21.449 @@ -587,7 +590,7 @@
  21.450  				unsigned long status;
  21.451  			} MWMHints = { (1L << 1), 0, 0, 0, 0 };
  21.452  
  21.453 -			XChangeProperty(SDL_Display, WMwindow,
  21.454 +			pXChangeProperty(SDL_Display, WMwindow,
  21.455  			                WM_HINTS, WM_HINTS, 32,
  21.456  			                PropModeReplace,
  21.457  					(unsigned char *)&MWMHints,
  21.458 @@ -595,11 +598,11 @@
  21.459  			set = SDL_TRUE;
  21.460  		}
  21.461  		/* Now try to set KWM hints */
  21.462 -		WM_HINTS = XInternAtom(SDL_Display, "KWM_WIN_DECORATION", True);
  21.463 +		WM_HINTS = pXInternAtom(SDL_Display, "KWM_WIN_DECORATION", True);
  21.464  		if ( WM_HINTS != None ) {
  21.465  			long KWMHints = 0;
  21.466  
  21.467 -			XChangeProperty(SDL_Display, WMwindow,
  21.468 +			pXChangeProperty(SDL_Display, WMwindow,
  21.469  			                WM_HINTS, WM_HINTS, 32,
  21.470  			                PropModeReplace,
  21.471  					(unsigned char *)&KWMHints,
  21.472 @@ -607,11 +610,11 @@
  21.473  			set = SDL_TRUE;
  21.474  		}
  21.475  		/* Now try to set GNOME hints */
  21.476 -		WM_HINTS = XInternAtom(SDL_Display, "_WIN_HINTS", True);
  21.477 +		WM_HINTS = pXInternAtom(SDL_Display, "_WIN_HINTS", True);
  21.478  		if ( WM_HINTS != None ) {
  21.479  			long GNOMEHints = 0;
  21.480  
  21.481 -			XChangeProperty(SDL_Display, WMwindow,
  21.482 +			pXChangeProperty(SDL_Display, WMwindow,
  21.483  			                WM_HINTS, WM_HINTS, 32,
  21.484  			                PropModeReplace,
  21.485  					(unsigned char *)&GNOMEHints,
  21.486 @@ -620,7 +623,7 @@
  21.487  		}
  21.488  		/* Finally set the transient hints if necessary */
  21.489  		if ( ! set ) {
  21.490 -			XSetTransientForHint(SDL_Display, WMwindow, SDL_Root);
  21.491 +			pXSetTransientForHint(SDL_Display, WMwindow, SDL_Root);
  21.492  		}
  21.493  	} else {
  21.494  		SDL_bool set;
  21.495 @@ -630,27 +633,27 @@
  21.496  		set = SDL_FALSE;
  21.497  
  21.498  		/* First try to unset MWM hints */
  21.499 -		WM_HINTS = XInternAtom(SDL_Display, "_MOTIF_WM_HINTS", True);
  21.500 +		WM_HINTS = pXInternAtom(SDL_Display, "_MOTIF_WM_HINTS", True);
  21.501  		if ( WM_HINTS != None ) {
  21.502 -			XDeleteProperty(SDL_Display, WMwindow, WM_HINTS);
  21.503 +			pXDeleteProperty(SDL_Display, WMwindow, WM_HINTS);
  21.504  			set = SDL_TRUE;
  21.505  		}
  21.506  		/* Now try to unset KWM hints */
  21.507 -		WM_HINTS = XInternAtom(SDL_Display, "KWM_WIN_DECORATION", True);
  21.508 +		WM_HINTS = pXInternAtom(SDL_Display, "KWM_WIN_DECORATION", True);
  21.509  		if ( WM_HINTS != None ) {
  21.510 -			XDeleteProperty(SDL_Display, WMwindow, WM_HINTS);
  21.511 +			pXDeleteProperty(SDL_Display, WMwindow, WM_HINTS);
  21.512  			set = SDL_TRUE;
  21.513  		}
  21.514  		/* Now try to unset GNOME hints */
  21.515 -		WM_HINTS = XInternAtom(SDL_Display, "_WIN_HINTS", True);
  21.516 +		WM_HINTS = pXInternAtom(SDL_Display, "_WIN_HINTS", True);
  21.517  		if ( WM_HINTS != None ) {
  21.518 -			XDeleteProperty(SDL_Display, WMwindow, WM_HINTS);
  21.519 +			pXDeleteProperty(SDL_Display, WMwindow, WM_HINTS);
  21.520  			set = SDL_TRUE;
  21.521  		}
  21.522  		/* Finally unset the transient hints if necessary */
  21.523  		if ( ! set ) {
  21.524  			/* NOTE: Does this work? */
  21.525 -			XSetTransientForHint(SDL_Display, WMwindow, None);
  21.526 +			pXSetTransientForHint(SDL_Display, WMwindow, None);
  21.527  		}
  21.528  	}
  21.529  }
  21.530 @@ -688,7 +691,7 @@
  21.531  	} else if ( SDL_windowid ) {
  21.532  		XWindowAttributes a;
  21.533  
  21.534 -		XGetWindowAttributes(SDL_Display, SDL_Window, &a);
  21.535 +		pXGetWindowAttributes(SDL_Display, SDL_Window, &a);
  21.536  		vis = a.visual;
  21.537  		depth = a.depth;
  21.538  	} else {
  21.539 @@ -717,7 +720,7 @@
  21.540  
  21.541  	/* Create the appropriate colormap */
  21.542  	if ( SDL_XColorMap != SDL_DisplayColormap ) {
  21.543 -		XFreeColormap(SDL_Display, SDL_XColorMap);
  21.544 +		pXFreeColormap(SDL_Display, SDL_XColorMap);
  21.545  	}
  21.546  	if ( SDL_Visual->class == PseudoColor ) {
  21.547  	    int ncolors;
  21.548 @@ -737,7 +740,7 @@
  21.549  	    }
  21.550  	    if ( flags & SDL_HWPALETTE ) {
  21.551  		screen->flags |= SDL_HWPALETTE;
  21.552 -		SDL_XColorMap = XCreateColormap(SDL_Display, SDL_Root,
  21.553 +		SDL_XColorMap = pXCreateColormap(SDL_Display, SDL_Root,
  21.554  		                                SDL_Visual, AllocAll);
  21.555  	    } else {
  21.556  		SDL_XColorMap = SDL_DisplayColormap;
  21.557 @@ -745,9 +748,9 @@
  21.558  	} else if ( SDL_Visual->class == DirectColor ) {
  21.559  
  21.560  	    /* Create a colormap which we can manipulate for gamma */
  21.561 -	    SDL_XColorMap = XCreateColormap(SDL_Display, SDL_Root,
  21.562 +	    SDL_XColorMap = pXCreateColormap(SDL_Display, SDL_Root,
  21.563  		                            SDL_Visual, AllocAll);
  21.564 -            XSync(SDL_Display, False);
  21.565 +            pXSync(SDL_Display, False);
  21.566  
  21.567  	    /* Initialize the colormap to the identity mapping */
  21.568  	    SDL_GetGammaRamp(0, 0, 0);
  21.569 @@ -756,7 +759,7 @@
  21.570  	    this->screen = NULL;
  21.571  	} else {
  21.572  	    /* Create a read-only colormap for our window */
  21.573 -	    SDL_XColorMap = XCreateColormap(SDL_Display, SDL_Root,
  21.574 +	    SDL_XColorMap = pXCreateColormap(SDL_Display, SDL_Root,
  21.575  	                                    SDL_Visual, AllocNone);
  21.576  	}
  21.577  
  21.578 @@ -769,8 +772,8 @@
  21.579  	       colour (0 is white on some displays), we should reset the
  21.580  	       background to 0 here since that is what the user expects
  21.581  	       with a private colormap */
  21.582 -	    XSetWindowBackground(SDL_Display, FSwindow, 0);
  21.583 -	    XClearWindow(SDL_Display, FSwindow);
  21.584 +	    pXSetWindowBackground(SDL_Display, FSwindow, 0);
  21.585 +	    pXClearWindow(SDL_Display, FSwindow);
  21.586  	}
  21.587  
  21.588  	/* resize the (possibly new) window manager window */
  21.589 @@ -778,7 +781,7 @@
  21.590  	        X11_SetSizeHints(this, w, h, flags);
  21.591  		current_w = w;
  21.592  		current_h = h;
  21.593 -		XResizeWindow(SDL_Display, WMwindow, w, h);
  21.594 +		pXResizeWindow(SDL_Display, WMwindow, w, h);
  21.595  	}
  21.596  
  21.597  	/* Create (or use) the X11 display window */
  21.598 @@ -793,14 +796,14 @@
  21.599  			swa.background_pixel = 0;
  21.600  			swa.border_pixel = 0;
  21.601  			swa.colormap = SDL_XColorMap;
  21.602 -			SDL_Window = XCreateWindow(SDL_Display, WMwindow,
  21.603 +			SDL_Window = pXCreateWindow(SDL_Display, WMwindow,
  21.604  		                           	0, 0, w, h, 0, depth,
  21.605  		                           	InputOutput, SDL_Visual,
  21.606  		                           	CWBackPixel | CWBorderPixel
  21.607  		                           	| CWColormap, &swa);
  21.608  		}
  21.609  		/* Only manage our input if we own the window */
  21.610 -		XSelectInput(SDL_Display, SDL_Window,
  21.611 +		pXSelectInput(SDL_Display, SDL_Window,
  21.612  					( EnterWindowMask | LeaveWindowMask
  21.613  					| ButtonPressMask | ButtonReleaseMask
  21.614  					| PointerMotionMask | ExposureMask ));
  21.615 @@ -817,7 +820,7 @@
  21.616  		XGCValues gcv;
  21.617  
  21.618  		gcv.graphics_exposures = False;
  21.619 -		SDL_GC = XCreateGC(SDL_Display, SDL_Window,
  21.620 +		SDL_GC = pXCreateGC(SDL_Display, SDL_Window,
  21.621  		                   GCGraphicsExposures, &gcv);
  21.622  		if ( ! SDL_GC ) {
  21.623  			SDL_SetError("Couldn't create graphics context");
  21.624 @@ -827,10 +830,10 @@
  21.625  
  21.626  	/* Set our colormaps when not setting a GL mode */
  21.627  	if ( ! (flags & SDL_OPENGL) ) {
  21.628 -		XSetWindowColormap(SDL_Display, SDL_Window, SDL_XColorMap);
  21.629 +		pXSetWindowColormap(SDL_Display, SDL_Window, SDL_XColorMap);
  21.630  		if( !SDL_windowid ) {
  21.631 -		    XSetWindowColormap(SDL_Display, FSwindow, SDL_XColorMap);
  21.632 -		    XSetWindowColormap(SDL_Display, WMwindow, SDL_XColorMap);
  21.633 +		    pXSetWindowColormap(SDL_Display, FSwindow, SDL_XColorMap);
  21.634 +		    pXSetWindowColormap(SDL_Display, WMwindow, SDL_XColorMap);
  21.635  		}
  21.636  	}
  21.637  
  21.638 @@ -845,7 +848,7 @@
  21.639  		xscreen = ScreenOfDisplay(SDL_Display, SDL_Screen);
  21.640  		a.backing_store = DoesBackingStore(xscreen);
  21.641  		if ( a.backing_store != NotUseful ) {
  21.642 -			XChangeWindowAttributes(SDL_Display, SDL_Window,
  21.643 +			pXChangeWindowAttributes(SDL_Display, SDL_Window,
  21.644  			                        CWBackingStore, &a);
  21.645  		}
  21.646  	}
  21.647 @@ -879,8 +882,8 @@
  21.648  
  21.649  	/* Map them both and go fullscreen, if requested */
  21.650  	if ( ! SDL_windowid ) {
  21.651 -		XMapWindow(SDL_Display, SDL_Window);
  21.652 -		XMapWindow(SDL_Display, WMwindow);
  21.653 +		pXMapWindow(SDL_Display, SDL_Window);
  21.654 +		pXMapWindow(SDL_Display, WMwindow);
  21.655  		X11_WaitMapped(this, WMwindow);
  21.656  		if ( flags & SDL_FULLSCREEN ) {
  21.657  			screen->flags |= SDL_FULLSCREEN;
  21.658 @@ -900,7 +903,7 @@
  21.659  		X11_SetSizeHints(this, w, h, flags);
  21.660  		current_w = w;
  21.661  		current_h = h;
  21.662 -		XResizeWindow(SDL_Display, WMwindow, w, h);
  21.663 +		pXResizeWindow(SDL_Display, WMwindow, w, h);
  21.664  
  21.665  		/* Resize the fullscreen and display windows */
  21.666  		if ( flags & SDL_FULLSCREEN ) {
  21.667 @@ -916,7 +919,7 @@
  21.668  				X11_LeaveFullScreen(this);
  21.669  			}
  21.670  		}
  21.671 -		XResizeWindow(SDL_Display, SDL_Window, w, h);
  21.672 +		pXResizeWindow(SDL_Display, SDL_Window, w, h);
  21.673  	}
  21.674  	return(0);
  21.675  }
  21.676 @@ -938,7 +941,7 @@
  21.677  	}
  21.678  
  21.679  	/* Flush any delayed updates */
  21.680 -	XSync(GFX_Display, False);
  21.681 +	pXSync(GFX_Display, False);
  21.682  
  21.683  	/* Set up the X11 window */
  21.684  	saved_flags = current->flags;
  21.685 @@ -968,7 +971,7 @@
  21.686  
  21.687    done:
  21.688  	/* Release the event thread */
  21.689 -	XSync(SDL_Display, False);
  21.690 +	pXSync(SDL_Display, False);
  21.691  	SDL_Unlock_EventThread();
  21.692  
  21.693  	/* We're done! */
  21.694 @@ -1017,7 +1020,7 @@
  21.695  
  21.696  	/* Lock the event thread, in multi-threading environments */
  21.697  	SDL_Lock_EventThread();
  21.698 -	if ( XQueryPointer(SDL_Display, SDL_Window, &u1, &current_win,
  21.699 +	if ( pXQueryPointer(SDL_Display, SDL_Window, &u1, &current_win,
  21.700  	                   &u2, &u2, &x, &y, &mask) ) {
  21.701  		if ( (x >= 0) && (x < SDL_VideoSurface->w) &&
  21.702  		     (y >= 0) && (y < SDL_VideoSurface->h) ) {
  21.703 @@ -1054,7 +1057,7 @@
  21.704  	 * XQueryColors sets the flags in the XColor struct, so we use
  21.705  	 * that to keep track of which colours are available
  21.706  	 */
  21.707 -	XQueryColors(GFX_Display, SDL_XColorMap, all, 256);
  21.708 +	pXQueryColors(GFX_Display, SDL_XColorMap, all, 256);
  21.709  
  21.710  	for(i = 0; i < nwant; i++) {
  21.711  		XColor *c;
  21.712 @@ -1080,7 +1083,7 @@
  21.713  		if(SDL_XPixels[best])
  21.714  			continue; /* already allocated, waste no more time */
  21.715  		c = all + best;
  21.716 -		if(XAllocColor(GFX_Display, SDL_XColorMap, c)) {
  21.717 +		if(pXAllocColor(GFX_Display, SDL_XColorMap, c)) {
  21.718  			/* got it */
  21.719  			colors[c->pixel].r = c->red >> 8;
  21.720  			colors[c->pixel].g = c->green >> 8;
  21.721 @@ -1122,8 +1125,8 @@
  21.722  			xcmap[i].blue  = (colors[i].b<<8)|colors[i].b;
  21.723  			xcmap[i].flags = (DoRed|DoGreen|DoBlue);
  21.724  		}
  21.725 -		XStoreColors(GFX_Display, SDL_XColorMap, xcmap, ncolors);
  21.726 -		XSync(GFX_Display, False);
  21.727 +		pXStoreColors(GFX_Display, SDL_XColorMap, xcmap, ncolors);
  21.728 +		pXSync(GFX_Display, False);
  21.729  		FREEA(xcmap);
  21.730  	} else {
  21.731  	        /*
  21.732 @@ -1151,7 +1154,7 @@
  21.733  				--SDL_XPixels[pixel];
  21.734  			}
  21.735  		}
  21.736 -		XFreeColors(GFX_Display, SDL_XColorMap, freelist, nfree, 0);
  21.737 +		pXFreeColors(GFX_Display, SDL_XColorMap, freelist, nfree, 0);
  21.738  		FREEA(freelist);
  21.739  
  21.740  		want = ALLOCA(ncolors * sizeof(SDL_Color));
  21.741 @@ -1168,7 +1171,7 @@
  21.742  			col.green = want[i].g << 8;
  21.743  			col.blue = want[i].b << 8;
  21.744  			col.flags = DoRed | DoGreen | DoBlue;
  21.745 -			if(XAllocColor(GFX_Display, SDL_XColorMap, &col)) {
  21.746 +			if(pXAllocColor(GFX_Display, SDL_XColorMap, &col)) {
  21.747  			        /* We got the colour, or at least the nearest
  21.748  				   the hardware could get. */
  21.749  			        colors[col.pixel].r = col.red >> 8;
  21.750 @@ -1212,8 +1215,8 @@
  21.751  		xcmap[i].blue  = ramp[2*256+c];
  21.752  		xcmap[i].flags = (DoRed|DoGreen|DoBlue);
  21.753  	}
  21.754 -	XStoreColors(GFX_Display, SDL_XColorMap, xcmap, ncolors);
  21.755 -	XSync(GFX_Display, False);
  21.756 +	pXStoreColors(GFX_Display, SDL_XColorMap, xcmap, ncolors);
  21.757 +	pXSync(GFX_Display, False);
  21.758  	return(0);
  21.759  }
  21.760  
  21.761 @@ -1226,14 +1229,14 @@
  21.762  	/* The event thread should be done, so we can touch SDL_Display */
  21.763  	if ( SDL_Display != NULL ) {
  21.764  		/* Flush any delayed updates */
  21.765 -		XSync(GFX_Display, False);
  21.766 +		pXSync(GFX_Display, False);
  21.767  
  21.768  		/* Start shutting down the windows */
  21.769  		X11_DestroyImage(this, this->screen);
  21.770  		X11_DestroyWindow(this, this->screen);
  21.771  		X11_FreeVideoModes(this);
  21.772  		if ( SDL_XColorMap != SDL_DisplayColormap ) {
  21.773 -			XFreeColormap(SDL_Display, SDL_XColorMap);
  21.774 +			pXFreeColormap(SDL_Display, SDL_XColorMap);
  21.775  		}
  21.776  		if ( SDL_iconcolors ) {
  21.777  			unsigned long pixel;
  21.778 @@ -1241,7 +1244,7 @@
  21.779  							 SDL_Screen);
  21.780  			for(pixel = 0; pixel < 256; ++pixel) {
  21.781  				while(SDL_iconcolors[pixel] > 0) {
  21.782 -					XFreeColors(GFX_Display,
  21.783 +					pXFreeColors(GFX_Display,
  21.784  						    dcmap, &pixel, 1, 0);
  21.785  					--SDL_iconcolors[pixel];
  21.786  				}
  21.787 @@ -1262,20 +1265,20 @@
  21.788  
  21.789  		/* Close the X11 graphics connection */
  21.790  		if ( GFX_Display != NULL ) {
  21.791 -			XCloseDisplay(GFX_Display);
  21.792 +			pXCloseDisplay(GFX_Display);
  21.793  			GFX_Display = NULL;
  21.794  		}
  21.795  
  21.796  		/* Close the X11 display connection */
  21.797 -		XCloseDisplay(SDL_Display);
  21.798 +		pXCloseDisplay(SDL_Display);
  21.799  		SDL_Display = NULL;
  21.800  
  21.801  		/* Reset the X11 error handlers */
  21.802  		if ( XIO_handler ) {
  21.803 -			XSetIOErrorHandler(XIO_handler);
  21.804 +			pXSetIOErrorHandler(XIO_handler);
  21.805  		}
  21.806  		if ( X_handler ) {
  21.807 -			XSetErrorHandler(X_handler);
  21.808 +			pXSetErrorHandler(X_handler);
  21.809  		}
  21.810  
  21.811  		/* Unload GL library after X11 shuts down */
    22.1 --- a/src/video/x11/SDL_x11video.h	Sat Nov 05 17:41:11 2005 +0000
    22.2 +++ b/src/video/x11/SDL_x11video.h	Sat Nov 05 19:53:37 2005 +0000
    22.3 @@ -31,11 +31,7 @@
    22.4  #include <X11/Xlib.h>
    22.5  #include <X11/Xutil.h>
    22.6  #include <X11/Xatom.h>
    22.7 -#ifndef NO_SHARED_MEMORY
    22.8 -#include <sys/ipc.h>
    22.9 -#include <sys/shm.h>
   22.10 -#include <X11/extensions/XShm.h>
   22.11 -#endif
   22.12 +
   22.13  #ifdef XFREE86_DGAMOUSE
   22.14  #include <XFree86/extensions/xf86dga.h>
   22.15  #endif
   22.16 @@ -50,6 +46,7 @@
   22.17  
   22.18  #include "SDL_mouse.h"
   22.19  #include "SDL_sysvideo.h"
   22.20 +#include "SDL_x11dyn.h"
   22.21  
   22.22  /* Hidden "this" pointer for the video functions */
   22.23  #define _THIS	SDL_VideoDevice *this
    23.1 --- a/src/video/x11/SDL_x11wm.c	Sat Nov 05 17:41:11 2005 +0000
    23.2 +++ b/src/video/x11/SDL_x11wm.c	Sat Nov 05 19:53:37 2005 +0000
    23.3 @@ -123,7 +123,7 @@
    23.4  					SDL_iconcolors[i]--;
    23.5  				}
    23.6  			}
    23.7 -			XFreeColors(GFX_Display, dcmap, freelist, nfree, 0);
    23.8 +			pXFreeColors(GFX_Display, dcmap, freelist, nfree, 0);
    23.9  		}
   23.10  		if(!SDL_iconcolors)
   23.11  			SDL_iconcolors = malloc(256 * sizeof *SDL_iconcolors);
   23.12 @@ -138,7 +138,7 @@
   23.13  			c.green = want[i].g << 8;
   23.14  			c.blue = want[i].b << 8;
   23.15  			c.flags = DoRed | DoGreen | DoBlue;
   23.16 -			if(XAllocColor(GFX_Display, dcmap, &c)) {
   23.17 +			if(pXAllocColor(GFX_Display, dcmap, &c)) {
   23.18  				/* got the colour */
   23.19  				SDL_iconcolors[c.pixel]++;
   23.20  				got[c.pixel] = want[i];
   23.21 @@ -152,13 +152,13 @@
   23.22  			XColor cols[256];
   23.23  			for(i = 0; i < 256; i++)
   23.24  				cols[i].pixel = i;
   23.25 -			XQueryColors(GFX_Display, dcmap, cols, 256);
   23.26 +			pXQueryColors(GFX_Display, dcmap, cols, 256);
   23.27  			for(i = 0; i < 256; i++) {
   23.28  				got[i].r = cols[i].red >> 8;
   23.29  				got[i].g = cols[i].green >> 8;
   23.30  				got[i].b = cols[i].blue >> 8;
   23.31  				if(!SDL_iconcolors[i]) {
   23.32 -					if(XAllocColor(GFX_Display, dcmap,
   23.33 +					if(pXAllocColor(GFX_Display, dcmap,
   23.34  							cols + i)) {
   23.35  						SDL_iconcolors[i] = 1;
   23.36  					} else {
   23.37 @@ -191,13 +191,13 @@
   23.38  	memset(LSBmask, 0, masksize);
   23.39  	for(i = 0; i < masksize; i++)
   23.40  		LSBmask[i] = reverse_byte(mask[i]);
   23.41 -	mask_pixmap = XCreatePixmapFromBitmapData(SDL_Display, WMwindow,
   23.42 +	mask_pixmap = pXCreatePixmapFromBitmapData(SDL_Display, WMwindow,
   23.43  						  (char *)LSBmask,
   23.44  						  sicon->w, sicon->h,
   23.45  						  1L, 0L, 1);
   23.46  
   23.47  	/* Transfer the image to an X11 pixmap */
   23.48 -	icon_image = XCreateImage(SDL_Display,
   23.49 +	icon_image = pXCreateImage(SDL_Display,
   23.50  				  DefaultVisual(SDL_Display, SDL_Screen),
   23.51  				  DefaultDepth(SDL_Display, SDL_Screen),
   23.52  				  ZPixmap, 0, sicon->pixels,
   23.53 @@ -205,13 +205,13 @@
   23.54  				  32, 0);
   23.55  	icon_image->byte_order = (SDL_BYTEORDER == SDL_BIG_ENDIAN)
   23.56  		                 ? MSBFirst : LSBFirst;
   23.57 -	icon_pixmap = XCreatePixmap(SDL_Display, SDL_Root, sicon->w, sicon->h,
   23.58 +	icon_pixmap = pXCreatePixmap(SDL_Display, SDL_Root, sicon->w, sicon->h,
   23.59  				    DefaultDepth(SDL_Display, SDL_Screen));
   23.60 -	gc = XCreateGC(SDL_Display, icon_pixmap, 0, &GCvalues);
   23.61 -	XPutImage(SDL_Display, icon_pixmap, gc, icon_image,
   23.62 +	gc = pXCreateGC(SDL_Display, icon_pixmap, 0, &GCvalues);
   23.63 +	pXPutImage(SDL_Display, icon_pixmap, gc, icon_image,
   23.64  		  0, 0, 0, 0, sicon->w, sicon->h);
   23.65 -	XFreeGC(SDL_Display, gc);
   23.66 -	XDestroyImage(icon_image);
   23.67 +	pXFreeGC(SDL_Display, gc);
   23.68 +	pXDestroyImage(icon_image);
   23.69  	free(LSBmask);
   23.70  	sicon->pixels = NULL;
   23.71  
   23.72 @@ -220,17 +220,17 @@
   23.73  	   it screws up others. The default is only to use a pixmap. */
   23.74  	p = getenv("SDL_VIDEO_X11_ICONWIN");
   23.75  	if(p && *p) {
   23.76 -		icon_window = XCreateSimpleWindow(SDL_Display, SDL_Root,
   23.77 +		icon_window = pXCreateSimpleWindow(SDL_Display, SDL_Root,
   23.78  						  0, 0, sicon->w, sicon->h, 0,
   23.79  						  CopyFromParent,
   23.80  						  CopyFromParent);
   23.81 -		XSetWindowBackgroundPixmap(SDL_Display, icon_window,
   23.82 +		pXSetWindowBackgroundPixmap(SDL_Display, icon_window,
   23.83  					   icon_pixmap);
   23.84 -		XClearWindow(SDL_Display, icon_window);
   23.85 +		pXClearWindow(SDL_Display, icon_window);
   23.86  	}
   23.87  
   23.88  	/* Set the window icon to the icon pixmap (and icon window) */
   23.89 -	wmhints = XAllocWMHints();
   23.90 +	wmhints = pXAllocWMHints();
   23.91  	wmhints->flags = (IconPixmapHint | IconMaskHint);
   23.92  	wmhints->icon_pixmap = icon_pixmap;
   23.93  	wmhints->icon_mask = mask_pixmap;
   23.94 @@ -238,9 +238,9 @@
   23.95  		wmhints->flags |= IconWindowHint;
   23.96  		wmhints->icon_window = icon_window;
   23.97  	}
   23.98 -	XSetWMHints(SDL_Display, WMwindow, wmhints);
   23.99 -	XFree(wmhints);
  23.100 -	XSync(SDL_Display, False);
  23.101 +	pXSetWMHints(SDL_Display, WMwindow, wmhints);
  23.102 +	pXFree(wmhints);
  23.103 +	pXSync(SDL_Display, False);
  23.104  
  23.105    done:
  23.106  	SDL_Unlock_EventThread();
  23.107 @@ -257,30 +257,30 @@
  23.108  	if ( title != NULL ) {
  23.109  		int error = XLocaleNotSupported;
  23.110  #ifdef X_HAVE_UTF8_STRING
  23.111 -		error = Xutf8TextListToTextProperty(SDL_Display,
  23.112 +		error = pXutf8TextListToTextProperty(SDL_Display,
  23.113  				(char **)&title, 1, XUTF8StringStyle,
  23.114  				&titleprop);
  23.115  #endif
  23.116  		if ( error != Success ) {
  23.117 -			XStringListToTextProperty((char **)&title, 1,
  23.118 +			pXStringListToTextProperty((char **)&title, 1,
  23.119  					&titleprop);
  23.120  		}
  23.121 -		XSetWMName(SDL_Display, WMwindow, &titleprop);
  23.122 -		XFree(titleprop.value);
  23.123 +		pXSetWMName(SDL_Display, WMwindow, &titleprop);
  23.124 +		pXFree(titleprop.value);
  23.125  	}
  23.126  	if ( icon != NULL ) {
  23.127  		int error = XLocaleNotSupported;
  23.128  #ifdef X_HAVE_UTF8_STRING
  23.129 -		error = Xutf8TextListToTextProperty(SDL_Display,
  23.130 +		error = pXutf8TextListToTextProperty(SDL_Display,
  23.131  				(char **)&icon, 1, XUTF8StringStyle, &iconprop);
  23.132  #endif
  23.133  		if ( error != Success ) {
  23.134 -			XStringListToTextProperty((char **)&icon, 1, &iconprop);
  23.135 +			pXStringListToTextProperty((char **)&icon, 1, &iconprop);
  23.136  		}
  23.137 -		XSetWMIconName(SDL_Display, WMwindow, &iconprop);
  23.138 -		XFree(iconprop.value);
  23.139 +		pXSetWMIconName(SDL_Display, WMwindow, &iconprop);
  23.140 +		pXFree(iconprop.value);
  23.141  	}
  23.142 -	XSync(SDL_Display, False);
  23.143 +	pXSync(SDL_Display, False);
  23.144  
  23.145  	SDL_Unlock_EventThread();
  23.146  }
  23.147 @@ -291,8 +291,8 @@
  23.148  	int result;
  23.149  
  23.150  	SDL_Lock_EventThread();
  23.151 -	result = XIconifyWindow(SDL_Display, WMwindow, SDL_Screen);
  23.152 -	XSync(SDL_Display, False);
  23.153 +	result = pXIconifyWindow(SDL_Display, WMwindow, SDL_Screen);
  23.154 +	pXSync(SDL_Display, False);
  23.155  	SDL_Unlock_EventThread();
  23.156  	return(result);
  23.157  }
  23.158 @@ -308,12 +308,12 @@
  23.159  		return(mode);	/* Will be set later on mode switch */
  23.160  	}
  23.161  	if ( mode == SDL_GRAB_OFF ) {
  23.162 -		XUngrabPointer(SDL_Display, CurrentTime);
  23.163 -		XUngrabKeyboard(SDL_Display, CurrentTime);
  23.164 +		pXUngrabPointer(SDL_Display, CurrentTime);
  23.165 +		pXUngrabKeyboard(SDL_Display, CurrentTime);
  23.166  	} else {
  23.167  		if ( this->screen->flags & SDL_FULLSCREEN ) {
  23.168  			/* Unbind the mouse from the fullscreen window */
  23.169 -			XUngrabPointer(SDL_Display, CurrentTime);
  23.170 +			pXUngrabPointer(SDL_Display, CurrentTime);
  23.171  		}
  23.172  		/* Try to grab the mouse */
  23.173  #if 0 /* We'll wait here until we actually grab, otherwise behavior undefined */
  23.174 @@ -321,7 +321,7 @@
  23.175  #else
  23.176  		while ( 1 ) {
  23.177  #endif
  23.178 -			result = XGrabPointer(SDL_Display, SDL_Window, True, 0,
  23.179 +			result = pXGrabPointer(SDL_Display, SDL_Window, True, 0,
  23.180  						GrabModeAsync, GrabModeAsync,
  23.181  						SDL_Window, None, CurrentTime);
  23.182  			if ( result == GrabSuccess ) {
  23.183 @@ -333,17 +333,17 @@
  23.184  			/* Uh, oh, what do we do here? */ ;
  23.185  		}
  23.186  		/* Now grab the keyboard */
  23.187 -		XGrabKeyboard(SDL_Display, WMwindow, True,
  23.188 +		pXGrabKeyboard(SDL_Display, WMwindow, True,
  23.189  				GrabModeAsync, GrabModeAsync, CurrentTime);
  23.190  
  23.191  		/* Raise the window if we grab the mouse */
  23.192  		if ( !(this->screen->flags & SDL_FULLSCREEN) )
  23.193 -			XRaiseWindow(SDL_Display, WMwindow);
  23.194 +			pXRaiseWindow(SDL_Display, WMwindow);
  23.195  
  23.196  		/* Make sure we register input focus */
  23.197  		SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS);
  23.198  	}
  23.199 -	XSync(SDL_Display, False);
  23.200 +	pXSync(SDL_Display, False);
  23.201  
  23.202  	return(mode);
  23.203  }
  23.204 @@ -368,7 +368,7 @@
  23.205  {
  23.206  	/* Make sure any X11 transactions are completed */
  23.207  	SDL_VideoDevice *this = current_video;
  23.208 -	XSync(SDL_Display, False);
  23.209 +	pXSync(SDL_Display, False);
  23.210  	SDL_Unlock_EventThread();
  23.211  }
  23.212  int X11_GetWMInfo(_THIS, SDL_SysWMinfo *info)
    24.1 --- a/src/video/x11/SDL_x11yuv.c	Sat Nov 05 17:41:11 2005 +0000
    24.2 +++ b/src/video/x11/SDL_x11yuv.c	Sat Nov 05 19:53:37 2005 +0000
    24.3 @@ -159,7 +159,7 @@
    24.4  					}
    24.5  				}
    24.6  				if ( formats ) {
    24.7 -					XFree(formats);
    24.8 +					pXFree(formats);
    24.9  				}
   24.10  			}
   24.11  		}
   24.12 @@ -208,21 +208,21 @@
   24.13  		unsigned int i;
   24.14  
   24.15  		SDL_NAME(XvSelectPortNotify)(GFX_Display, xv_port, True);
   24.16 -		X_handler = XSetErrorHandler(xv_errhandler);
   24.17 +		X_handler = pXSetErrorHandler(xv_errhandler);
   24.18  		for ( i=0; i < sizeof(attr)/(sizeof attr[0]); ++i ) {
   24.19  			Atom a;
   24.20  
   24.21  			xv_error = False;
   24.22 -			a = XInternAtom(GFX_Display, attr[i], True);
   24.23 +			a = pXInternAtom(GFX_Display, attr[i], True);
   24.24  			if ( a != None ) {
   24.25       				SDL_NAME(XvSetPortAttribute)(GFX_Display, xv_port, a, 1);
   24.26 -				XSync(GFX_Display, True);
   24.27 +				pXSync(GFX_Display, True);
   24.28  				if ( ! xv_error ) {
   24.29  					break;
   24.30  				}
   24.31  			}
   24.32  		}
   24.33 -		XSetErrorHandler(X_handler);
   24.34 +		pXSetErrorHandler(X_handler);
   24.35  		SDL_NAME(XvSelectPortNotify)(GFX_Display, xv_port, False);
   24.36  	}
   24.37  
   24.38 @@ -262,7 +262,7 @@
   24.39  #ifdef PITCH_WORKAROUND
   24.40  	if ( hwdata->image != NULL && hwdata->image->pitches[0] != (width*bpp) ) {
   24.41  		/* Ajust overlay width according to pitch */ 
   24.42 -		XFree(hwdata->image);
   24.43 +		pXFree(hwdata->image);
   24.44  		width = hwdata->image->pitches[0] / bpp;
   24.45  		hwdata->image = SDL_NAME(XvShmCreateImage)(GFX_Display, xv_port, format,
   24.46  							   0, width, height, yuvshm);
   24.47 @@ -277,10 +277,10 @@
   24.48  			yuvshm->readOnly = False;
   24.49  			if ( yuvshm->shmaddr != (char *)-1 ) {
   24.50  				shm_error = False;
   24.51 -				X_handler = XSetErrorHandler(shm_errhandler);
   24.52 -				XShmAttach(GFX_Display, yuvshm);
   24.53 -				XSync(GFX_Display, True);
   24.54 -				XSetErrorHandler(X_handler);
   24.55 +				X_handler = pXSetErrorHandler(shm_errhandler);
   24.56 +				pXShmAttach(GFX_Display, yuvshm);
   24.57 +				pXSync(GFX_Display, True);
   24.58 +				pXSetErrorHandler(X_handler);
   24.59  				if ( shm_error )
   24.60  					shmdt(yuvshm->shmaddr);
   24.61  			} else {
   24.62 @@ -291,7 +291,7 @@
   24.63  			shm_error = True;
   24.64  		}
   24.65  		if ( shm_error ) {
   24.66 -			XFree(hwdata->image);
   24.67 +			pXFree(hwdata->image);
   24.68  			hwdata->yuv_use_mitshm = 0;
   24.69  		} else {
   24.70  			hwdata->image->data = yuvshm->shmaddr;
   24.71 @@ -306,7 +306,7 @@
   24.72  #ifdef PITCH_WORKAROUND
   24.73  		if ( hwdata->image != NULL && hwdata->image->pitches[0] != (width*bpp) ) {
   24.74  			/* Ajust overlay width according to pitch */ 
   24.75 -			XFree(hwdata->image);
   24.76 +			pXFree(hwdata->image);
   24.77  			width = hwdata->image->pitches[0] / bpp;
   24.78  			hwdata->image = SDL_NAME(XvCreateImage)(GFX_Display, xv_port, format,
   24.79  								0, width, height);
   24.80 @@ -380,7 +380,7 @@
   24.81  				     hwdata->image, 0, 0, overlay->w, overlay->h,
   24.82  				     dstrect->x, dstrect->y, dstrect->w, dstrect->h);
   24.83  	}
   24.84 -	XSync(GFX_Display, False);
   24.85 +	pXSync(GFX_Display, False);
   24.86  	return(0);
   24.87  }
   24.88  
   24.89 @@ -393,12 +393,12 @@
   24.90  		SDL_NAME(XvUngrabPort)(GFX_Display, hwdata->port, CurrentTime);
   24.91  #ifndef NO_SHARED_MEMORY
   24.92  		if ( hwdata->yuv_use_mitshm ) {
   24.93 -			XShmDetach(GFX_Display, &hwdata->yuvshm);
   24.94 +			pXShmDetach(GFX_Display, &hwdata->yuvshm);
   24.95  			shmdt(hwdata->yuvshm.shmaddr);
   24.96  		}
   24.97  #endif
   24.98  		if ( hwdata->image ) {
   24.99 -			XFree(hwdata->image);
  24.100 +			pXFree(hwdata->image);
  24.101  		}
  24.102  		free(hwdata);
  24.103  	}