Don't supply duplicate X11 symbols inside SDL.
authorRyan C. Gordon <icculus@icculus.org>
Fri, 18 Oct 2013 01:36:41 -0400
changeset 7827a03ec8de0426
parent 7826 a87057441d01
child 7828 1451063c8ecd
Don't supply duplicate X11 symbols inside SDL.

Fixes static linking when something else also uses X11.
src/video/x11/SDL_x11clipboard.c
src/video/x11/SDL_x11dyn.c
src/video/x11/SDL_x11dyn.h
src/video/x11/SDL_x11events.c
src/video/x11/SDL_x11framebuffer.c
src/video/x11/SDL_x11keyboard.c
src/video/x11/SDL_x11messagebox.c
src/video/x11/SDL_x11modes.c
src/video/x11/SDL_x11mouse.c
src/video/x11/SDL_x11opengl.c
src/video/x11/SDL_x11opengles.c
src/video/x11/SDL_x11shape.c
src/video/x11/SDL_x11video.c
src/video/x11/SDL_x11window.c
src/video/x11/SDL_x11xinput2.c
     1.1 --- a/src/video/x11/SDL_x11clipboard.c	Thu Oct 17 20:49:30 2013 -0700
     1.2 +++ b/src/video/x11/SDL_x11clipboard.c	Fri Oct 18 01:36:41 2013 -0400
     1.3 @@ -31,7 +31,7 @@
     1.4  
     1.5  /* If you don't support UTF-8, you might use XA_STRING here */
     1.6  #ifdef X_HAVE_UTF8_STRING
     1.7 -#define TEXT_FORMAT XInternAtom(display, "UTF8_STRING", False)
     1.8 +#define TEXT_FORMAT X11_XInternAtom(display, "UTF8_STRING", False)
     1.9  #else
    1.10  #define TEXT_FORMAT XA_STRING
    1.11  #endif
    1.12 @@ -55,7 +55,7 @@
    1.13      Display *display = ((SDL_VideoData *) _this->driverdata)->display;
    1.14      Atom format;
    1.15      Window window;
    1.16 -    Atom XA_CLIPBOARD = XInternAtom(display, "CLIPBOARD", 0);
    1.17 +    Atom XA_CLIPBOARD = X11_XInternAtom(display, "CLIPBOARD", 0);
    1.18  
    1.19      /* Get the SDL window that will own the selection */
    1.20      window = GetWindow(_this);
    1.21 @@ -65,17 +65,17 @@
    1.22  
    1.23      /* Save the selection on the root window */
    1.24      format = TEXT_FORMAT;
    1.25 -    XChangeProperty(display, DefaultRootWindow(display),
    1.26 +    X11_XChangeProperty(display, DefaultRootWindow(display),
    1.27          XA_CUT_BUFFER0, format, 8, PropModeReplace,
    1.28          (const unsigned char *)text, SDL_strlen(text));
    1.29  
    1.30      if (XA_CLIPBOARD != None &&
    1.31 -        XGetSelectionOwner(display, XA_CLIPBOARD) != window) {
    1.32 -        XSetSelectionOwner(display, XA_CLIPBOARD, window, CurrentTime);
    1.33 +        X11_XGetSelectionOwner(display, XA_CLIPBOARD) != window) {
    1.34 +        X11_XSetSelectionOwner(display, XA_CLIPBOARD, window, CurrentTime);
    1.35      }
    1.36  
    1.37 -    if (XGetSelectionOwner(display, XA_PRIMARY) != window) {
    1.38 -        XSetSelectionOwner(display, XA_PRIMARY, window, CurrentTime);
    1.39 +    if (X11_XGetSelectionOwner(display, XA_PRIMARY) != window) {
    1.40 +        X11_XSetSelectionOwner(display, XA_PRIMARY, window, CurrentTime);
    1.41      }
    1.42      return 0;
    1.43  }
    1.44 @@ -97,7 +97,7 @@
    1.45      char *text;
    1.46      Uint32 waitStart;
    1.47      Uint32 waitElapsed;
    1.48 -    Atom XA_CLIPBOARD = XInternAtom(display, "CLIPBOARD", 0);
    1.49 +    Atom XA_CLIPBOARD = X11_XInternAtom(display, "CLIPBOARD", 0);
    1.50      if (XA_CLIPBOARD == None) {
    1.51          SDL_SetError("Couldn't access X clipboard");
    1.52          return SDL_strdup("");
    1.53 @@ -108,15 +108,15 @@
    1.54      /* Get the window that holds the selection */
    1.55      window = GetWindow(_this);
    1.56      format = TEXT_FORMAT;
    1.57 -    owner = XGetSelectionOwner(display, XA_CLIPBOARD);
    1.58 +    owner = X11_XGetSelectionOwner(display, XA_CLIPBOARD);
    1.59      if ((owner == None) || (owner == window)) {
    1.60          owner = DefaultRootWindow(display);
    1.61          selection = XA_CUT_BUFFER0;
    1.62      } else {
    1.63          /* Request that the selection owner copy the data to our window */
    1.64          owner = window;
    1.65 -        selection = XInternAtom(display, "SDL_SELECTION", False);
    1.66 -        XConvertSelection(display, XA_CLIPBOARD, format, selection, owner,
    1.67 +        selection = X11_XInternAtom(display, "SDL_SELECTION", False);
    1.68 +        X11_XConvertSelection(display, XA_CLIPBOARD, format, selection, owner,
    1.69              CurrentTime);
    1.70  
    1.71          /* When using synergy on Linux and when data has been put in the clipboard
    1.72 @@ -139,7 +139,7 @@
    1.73          }
    1.74      }
    1.75  
    1.76 -    if (XGetWindowProperty(display, owner, selection, 0, INT_MAX/4, False,
    1.77 +    if (X11_XGetWindowProperty(display, owner, selection, 0, INT_MAX/4, False,
    1.78              format, &seln_type, &seln_format, &nbytes, &overflow, &src)
    1.79              == Success) {
    1.80          if (seln_type == format) {
    1.81 @@ -149,7 +149,7 @@
    1.82                  text[nbytes] = '\0';
    1.83              }
    1.84          }
    1.85 -        XFree(src);
    1.86 +        X11_XFree(src);
    1.87      }
    1.88  
    1.89      if (!text) {
     2.1 --- a/src/video/x11/SDL_x11dyn.c	Thu Oct 17 20:49:30 2013 -0700
     2.2 +++ b/src/video/x11/SDL_x11dyn.c	Fri Oct 18 01:36:41 2013 -0400
     2.3 @@ -103,24 +103,19 @@
     2.4      return fn;
     2.5  }
     2.6  
     2.7 +#endif /* SDL_VIDEO_DRIVER_X11_DYNAMIC */
     2.8  
     2.9  /* Define all the function pointers and wrappers... */
    2.10  #define SDL_X11_MODULE(modname)
    2.11 -#define SDL_X11_SYM(rc,fn,params,args,ret) \
    2.12 -    typedef rc (*SDL_DYNX11FN_##fn) params; \
    2.13 -    static SDL_DYNX11FN_##fn p##fn = NULL; \
    2.14 -    rc fn params { ret p##fn args ; }
    2.15 +#define SDL_X11_SYM(rc,fn,params,args,ret) SDL_DYNX11FN_##fn X11_##fn = NULL;
    2.16  #include "SDL_x11sym.h"
    2.17  #undef SDL_X11_MODULE
    2.18  #undef SDL_X11_SYM
    2.19 -#endif /* SDL_VIDEO_DRIVER_X11_DYNAMIC */
    2.20  
    2.21  /* Annoying varargs entry point... */
    2.22  #ifdef X_HAVE_UTF8_STRING
    2.23 -typedef XIC(*SDL_DYNX11FN_XCreateIC) (XIM,...);
    2.24 -SDL_DYNX11FN_XCreateIC pXCreateIC = NULL;
    2.25 -typedef char *(*SDL_DYNX11FN_XGetICValues) (XIC, ...);
    2.26 -SDL_DYNX11FN_XGetICValues pXGetICValues = NULL;
    2.27 +SDL_DYNX11FN_XCreateIC X11_XCreateIC = NULL;
    2.28 +SDL_DYNX11FN_XGetICValues X11_XGetICValues = NULL;
    2.29  #endif
    2.30  
    2.31  /* These SDL_X11_HAVE_* flags are here whether you have dynamic X11 or not. */
    2.32 @@ -130,15 +125,11 @@
    2.33  #undef SDL_X11_MODULE
    2.34  #undef SDL_X11_SYM
    2.35  
    2.36 -
    2.37 -#ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC
    2.38  static int x11_load_refcount = 0;
    2.39 -#endif
    2.40  
    2.41  void
    2.42  SDL_X11_UnloadSymbols(void)
    2.43  {
    2.44 -#ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC
    2.45      /* Don't actually unload if more than one module is using the libs... */
    2.46      if (x11_load_refcount > 0) {
    2.47          if (--x11_load_refcount == 0) {
    2.48 @@ -146,25 +137,26 @@
    2.49  
    2.50              /* set all the function pointers to NULL. */
    2.51  #define SDL_X11_MODULE(modname) SDL_X11_HAVE_##modname = 0;
    2.52 -#define SDL_X11_SYM(rc,fn,params,args,ret) p##fn = NULL;
    2.53 +#define SDL_X11_SYM(rc,fn,params,args,ret) X11_##fn = NULL;
    2.54  #include "SDL_x11sym.h"
    2.55  #undef SDL_X11_MODULE
    2.56  #undef SDL_X11_SYM
    2.57  
    2.58  #ifdef X_HAVE_UTF8_STRING
    2.59 -            pXCreateIC = NULL;
    2.60 -            pXGetICValues = NULL;
    2.61 +            X11_XCreateIC = NULL;
    2.62 +            X11_XGetICValues = NULL;
    2.63  #endif
    2.64  
    2.65 +#ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC
    2.66              for (i = 0; i < SDL_TABLESIZE(x11libs); i++) {
    2.67                  if (x11libs[i].lib != NULL) {
    2.68                      SDL_UnloadObject(x11libs[i].lib);
    2.69                      x11libs[i].lib = NULL;
    2.70                  }
    2.71              }
    2.72 +#endif
    2.73          }
    2.74      }
    2.75 -#endif
    2.76  }
    2.77  
    2.78  /* returns non-zero if all needed symbols were loaded. */
    2.79 @@ -173,9 +165,9 @@
    2.80  {
    2.81      int rc = 1;                 /* always succeed if not using Dynamic X11 stuff. */
    2.82  
    2.83 -#ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC
    2.84      /* deal with multiple modules (dga, x11, etc) needing these symbols... */
    2.85      if (x11_load_refcount++ == 0) {
    2.86 +#ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC
    2.87          int i;
    2.88          int *thismod = NULL;
    2.89          for (i = 0; i < SDL_TABLESIZE(x11libs); i++) {
    2.90 @@ -191,15 +183,15 @@
    2.91  #undef SDL_X11_SYM
    2.92  
    2.93  #define SDL_X11_MODULE(modname) thismod = &SDL_X11_HAVE_##modname;
    2.94 -#define SDL_X11_SYM(a,fn,x,y,z) p##fn = (SDL_DYNX11FN_##fn) X11_GetSym(#fn,thismod);
    2.95 +#define SDL_X11_SYM(a,fn,x,y,z) X11_##fn = (SDL_DYNX11FN_##fn) X11_GetSym(#fn,thismod);
    2.96  #include "SDL_x11sym.h"
    2.97  #undef SDL_X11_MODULE
    2.98  #undef SDL_X11_SYM
    2.99  
   2.100  #ifdef X_HAVE_UTF8_STRING
   2.101 -        pXCreateIC = (SDL_DYNX11FN_XCreateIC)
   2.102 +        X11_XCreateIC = (SDL_DYNX11FN_XCreateIC)
   2.103                          X11_GetSym("XCreateIC", &SDL_X11_HAVE_UTF8);
   2.104 -        pXGetICValues = (SDL_DYNX11FN_XGetICValues)
   2.105 +        X11_XGetICValues = (SDL_DYNX11FN_XGetICValues)
   2.106                          X11_GetSym("XGetICValues", &SDL_X11_HAVE_UTF8);
   2.107  #endif
   2.108  
   2.109 @@ -211,19 +203,21 @@
   2.110              SDL_X11_UnloadSymbols();
   2.111              rc = 0;
   2.112          }
   2.113 -    }
   2.114 -#else
   2.115 +
   2.116 +#else  /* no dynamic X11 */
   2.117 +
   2.118  #define SDL_X11_MODULE(modname) SDL_X11_HAVE_##modname = 1; /* default yes */
   2.119 -#define SDL_X11_SYM(a,fn,x,y,z)
   2.120 +#define SDL_X11_SYM(a,fn,x,y,z) X11_##fn = fn;
   2.121  #include "SDL_x11sym.h"
   2.122  #undef SDL_X11_MODULE
   2.123  #undef SDL_X11_SYM
   2.124  
   2.125  #ifdef X_HAVE_UTF8_STRING
   2.126 -    pXCreateIC = XCreateIC;
   2.127 -    pXGetICValues = XGetICValues;
   2.128 +        X11_XCreateIC = XCreateIC;
   2.129 +        X11_XGetICValues = XGetICValues;
   2.130  #endif
   2.131  #endif
   2.132 +    }
   2.133  
   2.134      return rc;
   2.135  }
     3.1 --- a/src/video/x11/SDL_x11dyn.h	Thu Oct 17 20:49:30 2013 -0700
     3.2 +++ b/src/video/x11/SDL_x11dyn.h	Fri Oct 18 01:36:41 2013 -0400
     3.3 @@ -69,35 +69,34 @@
     3.4  #include <X11/extensions/xf86vmode.h>
     3.5  #endif
     3.6  
     3.7 -/*
     3.8 - * When using the "dynamic X11" functionality, we duplicate all the Xlib
     3.9 - *  symbols that would be referenced by SDL inside of SDL itself.
    3.10 - *  These duplicated symbols just serve as passthroughs to the functions
    3.11 - *  in Xlib, that was dynamically loaded.
    3.12 - *
    3.13 - * This allows us to use Xlib as-is when linking against it directly, but
    3.14 - *  also handles all the strange cases where there was code in the Xlib
    3.15 - *  headers that may or may not exist or vary on a given platform.
    3.16 - */
    3.17  #ifdef __cplusplus
    3.18  extern "C"
    3.19  {
    3.20  #endif
    3.21  
    3.22  /* evil function signatures... */
    3.23 -    typedef Bool(*SDL_X11_XESetWireToEventRetType) (Display *, XEvent *,
    3.24 -                                                    xEvent *);
    3.25 -    typedef int (*SDL_X11_XSynchronizeRetType) (Display *);
    3.26 -    typedef Status(*SDL_X11_XESetEventToWireRetType) (Display *, XEvent *,
    3.27 -                                                      xEvent *);
    3.28 +typedef Bool(*SDL_X11_XESetWireToEventRetType) (Display *, XEvent *, xEvent *);
    3.29 +typedef int (*SDL_X11_XSynchronizeRetType) (Display *);
    3.30 +typedef Status(*SDL_X11_XESetEventToWireRetType) (Display *, XEvent *, xEvent *);
    3.31  
    3.32 -    int SDL_X11_LoadSymbols(void);
    3.33 -    void SDL_X11_UnloadSymbols(void);
    3.34 +int SDL_X11_LoadSymbols(void);
    3.35 +void SDL_X11_UnloadSymbols(void);
    3.36  
    3.37 -/* That's really annoying...make these function pointers no matter what. */
    3.38 +/* Declare all the function pointers and wrappers... */
    3.39 +#define SDL_X11_MODULE(modname)
    3.40 +#define SDL_X11_SYM(rc,fn,params,args,ret) \
    3.41 +    typedef rc (*SDL_DYNX11FN_##fn) params; \
    3.42 +    extern SDL_DYNX11FN_##fn X11_##fn;
    3.43 +#include "SDL_x11sym.h"
    3.44 +#undef SDL_X11_MODULE
    3.45 +#undef SDL_X11_SYM
    3.46 +
    3.47 +/* Annoying varargs entry point... */
    3.48  #ifdef X_HAVE_UTF8_STRING
    3.49 -    extern XIC(*pXCreateIC) (XIM, ...);
    3.50 -    extern char *(*pXGetICValues) (XIC, ...);
    3.51 +typedef XIC(*SDL_DYNX11FN_XCreateIC) (XIM,...);
    3.52 +typedef char *(*SDL_DYNX11FN_XGetICValues) (XIC, ...);
    3.53 +extern SDL_DYNX11FN_XCreateIC X11_XCreateIC;
    3.54 +extern SDL_DYNX11FN_XGetICValues X11_XGetICValues;
    3.55  #endif
    3.56  
    3.57  /* These SDL_X11_HAVE_* flags are here whether you have dynamic X11 or not. */
    3.58 @@ -107,7 +106,6 @@
    3.59  #undef SDL_X11_MODULE
    3.60  #undef SDL_X11_SYM
    3.61  
    3.62 -
    3.63  #ifdef __cplusplus
    3.64  }
    3.65  #endif
     4.1 --- a/src/video/x11/SDL_x11events.c	Thu Oct 17 20:49:30 2013 -0700
     4.2 +++ b/src/video/x11/SDL_x11events.c	Fri Oct 18 01:36:41 2013 -0400
     4.3 @@ -48,7 +48,7 @@
     4.4  } SDL_x11Prop;
     4.5  
     4.6  /* Reads property
     4.7 -   Must call XFree on results
     4.8 +   Must call X11_XFree on results
     4.9   */
    4.10  static void X11_ReadProperty(SDL_x11Prop *p, Display *disp, Window w, Atom prop)
    4.11  {
    4.12 @@ -60,8 +60,8 @@
    4.13      int bytes_fetch = 0;
    4.14  
    4.15      do {
    4.16 -        if (ret != 0) XFree(ret);
    4.17 -        XGetWindowProperty(disp, w, prop, 0, bytes_fetch, False, AnyPropertyType, &type, &fmt, &count, &bytes_left, &ret);
    4.18 +        if (ret != 0) X11_XFree(ret);
    4.19 +        X11_XGetWindowProperty(disp, w, prop, 0, bytes_fetch, False, AnyPropertyType, &type, &fmt, &count, &bytes_left, &ret);
    4.20          bytes_fetch += bytes_left;
    4.21      } while (bytes_left != 0);
    4.22  
    4.23 @@ -79,9 +79,9 @@
    4.24      char *name;
    4.25      int i;
    4.26      for (i=0; i < list_count && request == None; i++) {
    4.27 -        name = XGetAtomName(disp, list[i]);
    4.28 +        name = X11_XGetAtomName(disp, list[i]);
    4.29          if (strcmp("text/uri-list", name)==0) request = list[i];
    4.30 -        XFree(name);
    4.31 +        X11_XFree(name);
    4.32      }
    4.33      return request;
    4.34  }
    4.35 @@ -125,8 +125,8 @@
    4.36      struct KeyRepeatCheckData d;
    4.37      d.event = event;
    4.38      d.found = SDL_FALSE;
    4.39 -    if (XPending(display))
    4.40 -        XCheckIfEvent(display, &dummyev, X11_KeyRepeatCheckIfEvent,
    4.41 +    if (X11_XPending(display))
    4.42 +        X11_XCheckIfEvent(display, &dummyev, X11_KeyRepeatCheckIfEvent,
    4.43              (XPointer) &d);
    4.44      return d.found;
    4.45  }
    4.46 @@ -147,7 +147,7 @@
    4.47  static SDL_bool X11_IsWheelEvent(Display * display,XEvent * event,int * ticks)
    4.48  {
    4.49      XEvent relevent;
    4.50 -    if (XPending(display)) {
    4.51 +    if (X11_XPending(display)) {
    4.52          /* according to the xlib docs, no specific mouse wheel events exist.
    4.53             however, mouse wheel events trigger a button press and a button release
    4.54             immediately. thus, checking if the same button was released at the same
    4.55 @@ -158,7 +158,7 @@
    4.56               generated (or synthesised) immediately.
    4.57             - False negative: a wheel which, when rolled, doesn't have
    4.58               a release event generated immediately. */
    4.59 -        if (XCheckIfEvent(display, &relevent, X11_IsWheelCheckIfEvent,
    4.60 +        if (X11_XCheckIfEvent(display, &relevent, X11_IsWheelCheckIfEvent,
    4.61              (XPointer) event)) {
    4.62  
    4.63              /* by default, X11 only knows 5 buttons. on most 3 button + wheel mouse,
    4.64 @@ -217,9 +217,9 @@
    4.65  {
    4.66      /* event is a union, so cookie == &event, but this is type safe. */
    4.67      XGenericEventCookie *cookie = &event.xcookie;
    4.68 -    if (XGetEventData(videodata->display, cookie)) {
    4.69 +    if (X11_XGetEventData(videodata->display, cookie)) {
    4.70          X11_HandleXinput2Event(videodata, cookie);
    4.71 -        XFreeEventData(videodata->display, cookie);
    4.72 +        X11_XFreeEventData(videodata->display, cookie);
    4.73      }
    4.74  }
    4.75  #endif /* SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS */
    4.76 @@ -234,7 +234,7 @@
    4.77      SDL_SetKeyboardFocus(data->window);
    4.78  #ifdef X_HAVE_UTF8_STRING
    4.79      if (data->ic) {
    4.80 -        XSetICFocus(data->ic);
    4.81 +        X11_XSetICFocus(data->ic);
    4.82      }
    4.83  #endif
    4.84  }
    4.85 @@ -248,7 +248,7 @@
    4.86      SDL_SetKeyboardFocus(NULL);
    4.87  #ifdef X_HAVE_UTF8_STRING
    4.88      if (data->ic) {
    4.89 -        XUnsetICFocus(data->ic);
    4.90 +        X11_XUnsetICFocus(data->ic);
    4.91      }
    4.92  #endif
    4.93  }
    4.94 @@ -278,11 +278,11 @@
    4.95      XClientMessageEvent m;
    4.96  
    4.97      SDL_zero(xevent);           /* valgrind fix. --ryan. */
    4.98 -    XNextEvent(display, &xevent);
    4.99 +    X11_XNextEvent(display, &xevent);
   4.100  
   4.101      /* filter events catchs XIM events and sends them to the correct
   4.102         handler */
   4.103 -    if (XFilterEvent(&xevent, None) == True) {
   4.104 +    if (X11_XFilterEvent(&xevent, None) == True) {
   4.105  #if 0
   4.106          printf("Filtered event type = %d display = %d window = %d\n",
   4.107                 xevent.type, xevent.xany.display, xevent.xany.window);
   4.108 @@ -451,23 +451,23 @@
   4.109  #if 1
   4.110              if (videodata->key_layout[keycode] == SDL_SCANCODE_UNKNOWN && keycode) {
   4.111                  int min_keycode, max_keycode;
   4.112 -                XDisplayKeycodes(display, &min_keycode, &max_keycode);
   4.113 +                X11_XDisplayKeycodes(display, &min_keycode, &max_keycode);
   4.114  #if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM
   4.115 -                keysym = XkbKeycodeToKeysym(display, keycode, 0, 0);
   4.116 +                keysym = X11_XkbKeycodeToKeysym(display, keycode, 0, 0);
   4.117  #else
   4.118                  keysym = XKeycodeToKeysym(display, keycode, 0);
   4.119  #endif
   4.120                  fprintf(stderr,
   4.121                          "The key you just pressed is not recognized by SDL. To help get this fixed, please report this to the SDL mailing list <sdl@libsdl.org> X11 KeyCode %d (%d), X11 KeySym 0x%lX (%s).\n",
   4.122                          keycode, keycode - min_keycode, keysym,
   4.123 -                        XKeysymToString(keysym));
   4.124 +                        X11_XKeysymToString(keysym));
   4.125              }
   4.126  #endif
   4.127              /* */
   4.128              SDL_zero(text);
   4.129  #ifdef X_HAVE_UTF8_STRING
   4.130              if (data->ic) {
   4.131 -                Xutf8LookupString(data->ic, &xevent.xkey, text, sizeof(text),
   4.132 +                X11_Xutf8LookupString(data->ic, &xevent.xkey, text, sizeof(text),
   4.133                                    &keysym, &status);
   4.134              }
   4.135  #else
   4.136 @@ -549,7 +549,7 @@
   4.137                      X11_ReadProperty(&p, display, data->xdnd_source, videodata->XdndTypeList);
   4.138                      /* pick one */
   4.139                      data->xdnd_req = X11_PickTarget(display, (Atom*)p.data, p.count);
   4.140 -                    XFree(p.data);
   4.141 +                    X11_XFree(p.data);
   4.142                  } else {
   4.143                      /* pick from list of three */
   4.144                      data->xdnd_req = X11_PickTargetFromAtoms(display, xevent.xclient.data.l[2], xevent.xclient.data.l[3], xevent.xclient.data.l[4]);
   4.145 @@ -570,8 +570,8 @@
   4.146                  m.data.l[3] = 0;
   4.147                  m.data.l[4] = videodata->XdndActionCopy; /* we only accept copying anyway */
   4.148  
   4.149 -                XSendEvent(display, xevent.xclient.data.l[0], False, NoEventMask, (XEvent*)&m);
   4.150 -                XFlush(display);
   4.151 +                X11_XSendEvent(display, xevent.xclient.data.l[0], False, NoEventMask, (XEvent*)&m);
   4.152 +                X11_XFlush(display);
   4.153              }
   4.154              else if(xevent.xclient.message_type == videodata->XdndDrop) {
   4.155                  if (data->xdnd_req == None) {
   4.156 @@ -585,13 +585,13 @@
   4.157                      m.data.l[0] = data->xwindow;
   4.158                      m.data.l[1] = 0;
   4.159                      m.data.l[2] = None; /* fail! */
   4.160 -                    XSendEvent(display, xevent.xclient.data.l[0], False, NoEventMask, (XEvent*)&m);
   4.161 +                    X11_XSendEvent(display, xevent.xclient.data.l[0], False, NoEventMask, (XEvent*)&m);
   4.162                  } else {
   4.163                      /* convert */
   4.164                      if(xdnd_version >= 1) {
   4.165 -                        XConvertSelection(display, videodata->XdndSelection, data->xdnd_req, videodata->PRIMARY, data->xwindow, xevent.xclient.data.l[2]);
   4.166 +                        X11_XConvertSelection(display, videodata->XdndSelection, data->xdnd_req, videodata->PRIMARY, data->xwindow, xevent.xclient.data.l[2]);
   4.167                      } else {
   4.168 -                        XConvertSelection(display, videodata->XdndSelection, data->xdnd_req, videodata->PRIMARY, data->xwindow, CurrentTime);
   4.169 +                        X11_XConvertSelection(display, videodata->XdndSelection, data->xdnd_req, videodata->PRIMARY, data->xwindow, CurrentTime);
   4.170                      }
   4.171                  }
   4.172              }
   4.173 @@ -604,7 +604,7 @@
   4.174                  printf("window %p: _NET_WM_PING\n", data);
   4.175  #endif
   4.176                  xevent.xclient.window = root;
   4.177 -                XSendEvent(display, root, False, SubstructureRedirectMask | SubstructureNotifyMask, &xevent);
   4.178 +                X11_XSendEvent(display, root, False, SubstructureRedirectMask | SubstructureNotifyMask, &xevent);
   4.179                  break;
   4.180              }
   4.181  
   4.182 @@ -664,13 +664,13 @@
   4.183              Atom real_type;
   4.184              unsigned long items_read, items_left, i;
   4.185  
   4.186 -            char *name = XGetAtomName(display, xevent.xproperty.atom);
   4.187 +            char *name = X11_XGetAtomName(display, xevent.xproperty.atom);
   4.188              if (name) {
   4.189                  printf("window %p: PropertyNotify: %s %s\n", data, name, (xevent.xproperty.state == PropertyDelete) ? "deleted" : "changed");
   4.190 -                XFree(name);
   4.191 +                X11_XFree(name);
   4.192              }
   4.193  
   4.194 -            status = XGetWindowProperty(display, data->xwindow, xevent.xproperty.atom, 0L, 8192L, False, AnyPropertyType, &real_type, &real_format, &items_read, &items_left, &propdata);
   4.195 +            status = X11_XGetWindowProperty(display, data->xwindow, xevent.xproperty.atom, 0L, 8192L, False, AnyPropertyType, &real_type, &real_format, &items_read, &items_left, &propdata);
   4.196              if (status == Success && items_read > 0) {
   4.197                  if (real_type == XA_INTEGER) {
   4.198                      int *values = (int *)propdata;
   4.199 @@ -714,23 +714,23 @@
   4.200  
   4.201                      printf("{");
   4.202                      for (i = 0; i < items_read; i++) {
   4.203 -                        char *name = XGetAtomName(display, atoms[i]);
   4.204 +                        char *name = X11_XGetAtomName(display, atoms[i]);
   4.205                          if (name) {
   4.206                              printf(" %s", name);
   4.207 -                            XFree(name);
   4.208 +                            X11_XFree(name);
   4.209                          }
   4.210                      }
   4.211                      printf(" }\n");
   4.212                  } else {
   4.213 -                    char *name = XGetAtomName(display, real_type);
   4.214 +                    char *name = X11_XGetAtomName(display, real_type);
   4.215                      printf("Unknown type: %ld (%s)\n", real_type, name ? name : "UNKNOWN");
   4.216                      if (name) {
   4.217 -                        XFree(name);
   4.218 +                        X11_XFree(name);
   4.219                      }
   4.220                  }
   4.221              }
   4.222              if (status == Success) {
   4.223 -                XFree(propdata);
   4.224 +                X11_XFree(propdata);
   4.225              }
   4.226  #endif /* DEBUG_XEVENTS */
   4.227  
   4.228 @@ -774,28 +774,28 @@
   4.229              sevent.xselection.property = None;
   4.230              sevent.xselection.requestor = req->requestor;
   4.231              sevent.xselection.time = req->time;
   4.232 -            if (XGetWindowProperty(display, DefaultRootWindow(display),
   4.233 +            if (X11_XGetWindowProperty(display, DefaultRootWindow(display),
   4.234                      XA_CUT_BUFFER0, 0, INT_MAX/4, False, req->target,
   4.235                      &sevent.xselection.target, &seln_format, &nbytes,
   4.236                      &overflow, &seln_data) == Success) {
   4.237 -                Atom XA_TARGETS = XInternAtom(display, "TARGETS", 0);
   4.238 +                Atom XA_TARGETS = X11_XInternAtom(display, "TARGETS", 0);
   4.239                  if (sevent.xselection.target == req->target) {
   4.240 -                    XChangeProperty(display, req->requestor, req->property,
   4.241 +                    X11_XChangeProperty(display, req->requestor, req->property,
   4.242                          sevent.xselection.target, seln_format, PropModeReplace,
   4.243                          seln_data, nbytes);
   4.244                      sevent.xselection.property = req->property;
   4.245                  } else if (XA_TARGETS == req->target) {
   4.246                      Atom SupportedFormats[] = { sevent.xselection.target, XA_TARGETS };
   4.247 -                    XChangeProperty(display, req->requestor, req->property,
   4.248 +                    X11_XChangeProperty(display, req->requestor, req->property,
   4.249                          XA_ATOM, 32, PropModeReplace,
   4.250                          (unsigned char*)SupportedFormats,
   4.251                          sizeof(SupportedFormats)/sizeof(*SupportedFormats));
   4.252                      sevent.xselection.property = req->property;
   4.253                  }
   4.254 -                XFree(seln_data);
   4.255 +                X11_XFree(seln_data);
   4.256              }
   4.257 -            XSendEvent(display, req->requestor, False, 0, &sevent);
   4.258 -            XSync(display, False);
   4.259 +            X11_XSendEvent(display, req->requestor, False, 0, &sevent);
   4.260 +            X11_XSync(display, False);
   4.261          }
   4.262          break;
   4.263  
   4.264 @@ -845,7 +845,7 @@
   4.265                      }
   4.266                  }
   4.267  
   4.268 -                XFree(p.data);
   4.269 +                X11_XFree(p.data);
   4.270  
   4.271                  /* send reply */
   4.272                  SDL_memset(&m, 0, sizeof(XClientMessageEvent));
   4.273 @@ -857,9 +857,9 @@
   4.274                  m.data.l[0] = data->xwindow;
   4.275                  m.data.l[1] = 1;
   4.276                  m.data.l[2] = videodata->XdndActionCopy;
   4.277 -                XSendEvent(display, data->xdnd_source, False, NoEventMask, (XEvent*)&m);
   4.278 +                X11_XSendEvent(display, data->xdnd_source, False, NoEventMask, (XEvent*)&m);
   4.279  
   4.280 -                XSync(display, False);
   4.281 +                X11_XSync(display, False);
   4.282  
   4.283              } else {
   4.284                  videodata->selection_waiting = SDL_FALSE;
   4.285 @@ -899,13 +899,13 @@
   4.286          }
   4.287      }
   4.288  }
   4.289 -/* Ack!  XPending() actually performs a blocking read if no events available */
   4.290 +/* Ack!  X11_XPending() actually performs a blocking read if no events available */
   4.291  static int
   4.292  X11_Pending(Display * display)
   4.293  {
   4.294      /* Flush the display connection and look to see if events are queued */
   4.295 -    XFlush(display);
   4.296 -    if (XEventsQueued(display, QueuedAlready)) {
   4.297 +    X11_XFlush(display);
   4.298 +    if (X11_XEventsQueued(display, QueuedAlready)) {
   4.299          return (1);
   4.300      }
   4.301  
   4.302 @@ -919,7 +919,7 @@
   4.303          FD_ZERO(&fdset);
   4.304          FD_SET(x11_fd, &fdset);
   4.305          if (select(x11_fd + 1, &fdset, NULL, NULL, &zero_time) == 1) {
   4.306 -            return (XPending(display));
   4.307 +            return (X11_XPending(display));
   4.308          }
   4.309      }
   4.310  
   4.311 @@ -942,7 +942,7 @@
   4.312          Uint32 now = SDL_GetTicks();
   4.313          if (!data->screensaver_activity ||
   4.314              (int) (now - data->screensaver_activity) >= 30000) {
   4.315 -            XResetScreenSaver(data->display);
   4.316 +            X11_XResetScreenSaver(data->display);
   4.317  
   4.318              #if SDL_USE_LIBDBUS
   4.319              SDL_dbus_screensaver_tickle(_this);
   4.320 @@ -971,16 +971,16 @@
   4.321      int major_version, minor_version;
   4.322  
   4.323      if (SDL_X11_HAVE_XSS) {
   4.324 -        /* XScreenSaverSuspend was introduced in MIT-SCREEN-SAVER 1.1 */
   4.325 -        if (!XScreenSaverQueryExtension(data->display, &dummy, &dummy) ||
   4.326 -            !XScreenSaverQueryVersion(data->display,
   4.327 +        /* X11_XScreenSaverSuspend was introduced in MIT-SCREEN-SAVER 1.1 */
   4.328 +        if (!X11_XScreenSaverQueryExtension(data->display, &dummy, &dummy) ||
   4.329 +            !X11_XScreenSaverQueryVersion(data->display,
   4.330                                        &major_version, &minor_version) ||
   4.331              major_version < 1 || (major_version == 1 && minor_version < 1)) {
   4.332              return;
   4.333          }
   4.334  
   4.335 -        XScreenSaverSuspend(data->display, _this->suspend_screensaver);
   4.336 -        XResetScreenSaver(data->display);
   4.337 +        X11_XScreenSaverSuspend(data->display, _this->suspend_screensaver);
   4.338 +        X11_XResetScreenSaver(data->display);
   4.339      }
   4.340  #endif
   4.341  
     5.1 --- a/src/video/x11/SDL_x11framebuffer.c	Thu Oct 17 20:49:30 2013 -0700
     5.2 +++ b/src/video/x11/SDL_x11framebuffer.c	Fri Oct 18 01:36:41 2013 -0400
     5.3 @@ -43,8 +43,8 @@
     5.4  static SDL_bool have_mitshm(void)
     5.5  {
     5.6      /* Only use shared memory on local X servers */
     5.7 -    if ( (SDL_strncmp(XDisplayName(NULL), ":", 1) == 0) ||
     5.8 -         (SDL_strncmp(XDisplayName(NULL), "unix:", 5) == 0) ) {
     5.9 +    if ( (SDL_strncmp(X11_XDisplayName(NULL), ":", 1) == 0) ||
    5.10 +         (SDL_strncmp(X11_XDisplayName(NULL), "unix:", 5) == 0) ) {
    5.11          return SDL_X11_HAVE_SHM;
    5.12      }
    5.13      return SDL_FALSE;
    5.14 @@ -66,7 +66,7 @@
    5.15  
    5.16      /* Create the graphics context for drawing */
    5.17      gcv.graphics_exposures = False;
    5.18 -    data->gc = XCreateGC(display, data->xwindow, GCGraphicsExposures, &gcv);
    5.19 +    data->gc = X11_XCreateGC(display, data->xwindow, GCGraphicsExposures, &gcv);
    5.20      if (!data->gc) {
    5.21          return SDL_SetError("Couldn't create graphics context");
    5.22      }
    5.23 @@ -95,10 +95,10 @@
    5.24              shminfo->readOnly = False;
    5.25              if ( shminfo->shmaddr != (char *)-1 ) {
    5.26                  shm_error = False;
    5.27 -                X_handler = XSetErrorHandler(shm_errhandler);
    5.28 -                XShmAttach(display, shminfo);
    5.29 -                XSync(display, True);
    5.30 -                XSetErrorHandler(X_handler);
    5.31 +                X_handler = X11_XSetErrorHandler(shm_errhandler);
    5.32 +                X11_XShmAttach(display, shminfo);
    5.33 +                X11_XSync(display, True);
    5.34 +                X11_XSetErrorHandler(X_handler);
    5.35                  if ( shm_error )
    5.36                      shmdt(shminfo->shmaddr);
    5.37              } else {
    5.38 @@ -109,13 +109,13 @@
    5.39              shm_error = True;
    5.40          }
    5.41          if (!shm_error) {
    5.42 -            data->ximage = XShmCreateImage(display, data->visual,
    5.43 +            data->ximage = X11_XShmCreateImage(display, data->visual,
    5.44                               vinfo.depth, ZPixmap,
    5.45                               shminfo->shmaddr, shminfo,
    5.46                               window->w, window->h);
    5.47              if (!data->ximage) {
    5.48 -                XShmDetach(display, shminfo);
    5.49 -                XSync(display, False);
    5.50 +                X11_XShmDetach(display, shminfo);
    5.51 +                X11_XSync(display, False);
    5.52                  shmdt(shminfo->shmaddr);
    5.53              } else {
    5.54                  /* Done! */
    5.55 @@ -132,7 +132,7 @@
    5.56          return SDL_OutOfMemory();
    5.57      }
    5.58  
    5.59 -    data->ximage = XCreateImage(display, data->visual,
    5.60 +    data->ximage = X11_XCreateImage(display, data->visual,
    5.61                        vinfo.depth, ZPixmap, 0, (char *)(*pixels),
    5.62                        window->w, window->h, 32, 0);
    5.63      if (!data->ximage) {
    5.64 @@ -177,7 +177,7 @@
    5.65              if (y + h > window->h)
    5.66                  h = window->h - y;
    5.67  
    5.68 -            XShmPutImage(display, data->xwindow, data->gc, data->ximage,
    5.69 +            X11_XShmPutImage(display, data->xwindow, data->gc, data->ximage,
    5.70                  x, y, x, y, w, h, False);
    5.71          }
    5.72      }
    5.73 @@ -209,12 +209,12 @@
    5.74              if (y + h > window->h)
    5.75                  h = window->h - y;
    5.76  
    5.77 -            XPutImage(display, data->xwindow, data->gc, data->ximage,
    5.78 +            X11_XPutImage(display, data->xwindow, data->gc, data->ximage,
    5.79                  x, y, x, y, w, h);
    5.80          }
    5.81      }
    5.82  
    5.83 -    XSync(display, False);
    5.84 +    X11_XSync(display, False);
    5.85  
    5.86      return 0;
    5.87  }
    5.88 @@ -237,8 +237,8 @@
    5.89  
    5.90  #ifndef NO_SHARED_MEMORY
    5.91          if (data->use_mitshm) {
    5.92 -            XShmDetach(display, &data->shminfo);
    5.93 -            XSync(display, False);
    5.94 +            X11_XShmDetach(display, &data->shminfo);
    5.95 +            X11_XSync(display, False);
    5.96              shmdt(data->shminfo.shmaddr);
    5.97              data->use_mitshm = SDL_FALSE;
    5.98          }
    5.99 @@ -247,7 +247,7 @@
   5.100          data->ximage = NULL;
   5.101      }
   5.102      if (data->gc) {
   5.103 -        XFreeGC(display, data->gc);
   5.104 +        X11_XFreeGC(display, data->gc);
   5.105          data->gc = NULL;
   5.106      }
   5.107  }
     6.1 --- a/src/video/x11/SDL_x11keyboard.c	Thu Oct 17 20:49:30 2013 -0700
     6.2 +++ b/src/video/x11/SDL_x11keyboard.c	Fri Oct 18 01:36:41 2013 -0400
     6.3 @@ -152,7 +152,7 @@
     6.4      int i;
     6.5  
     6.6  #if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM
     6.7 -    keysym = XkbKeycodeToKeysym(display, keycode, 0, 0);
     6.8 +    keysym = X11_XkbKeycodeToKeysym(display, keycode, 0, 0);
     6.9  #else
    6.10      keysym = XKeycodeToKeysym(display, keycode, 0);
    6.11  #endif
    6.12 @@ -182,7 +182,7 @@
    6.13      KeySym keysym;
    6.14  
    6.15  #if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM
    6.16 -    keysym = XkbKeycodeToKeysym(display, keycode, 0, 0);
    6.17 +    keysym = X11_XkbKeycodeToKeysym(display, keycode, 0, 0);
    6.18  #else
    6.19      keysym = XKeycodeToKeysym(display, keycode, 0);
    6.20  #endif
    6.21 @@ -211,14 +211,14 @@
    6.22      };
    6.23      SDL_bool fingerprint_detected;
    6.24  
    6.25 -    XAutoRepeatOn(data->display);
    6.26 +    X11_XAutoRepeatOn(data->display);
    6.27  
    6.28      /* Try to determine which scancodes are being used based on fingerprint */
    6.29      fingerprint_detected = SDL_FALSE;
    6.30 -    XDisplayKeycodes(data->display, &min_keycode, &max_keycode);
    6.31 +    X11_XDisplayKeycodes(data->display, &min_keycode, &max_keycode);
    6.32      for (i = 0; i < SDL_arraysize(fingerprint); ++i) {
    6.33          fingerprint[i].value =
    6.34 -            XKeysymToKeycode(data->display, fingerprint[i].keysym) -
    6.35 +            X11_XKeysymToKeycode(data->display, fingerprint[i].keysym) -
    6.36              min_keycode;
    6.37      }
    6.38      for (i = 0; i < SDL_arraysize(scancode_set); ++i) {
    6.39 @@ -258,14 +258,14 @@
    6.40          for (i = min_keycode; i <= max_keycode; ++i) {
    6.41              KeySym sym;
    6.42  #if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM
    6.43 -            sym = XkbKeycodeToKeysym(data->display, i, 0, 0);
    6.44 +            sym = X11_XkbKeycodeToKeysym(data->display, i, 0, 0);
    6.45  #else
    6.46              sym = XKeycodeToKeysym(data->display, i, 0);
    6.47  #endif
    6.48              if (sym != NoSymbol) {
    6.49                  SDL_Scancode scancode;
    6.50                  printf("code = %d, sym = 0x%X (%s) ", i - min_keycode,
    6.51 -                       (unsigned int) sym, XKeysymToString(sym));
    6.52 +                       (unsigned int) sym, X11_XKeysymToString(sym));
    6.53                  scancode = X11_KeyCodeToSDLScancode(data->display, i);
    6.54                  data->key_layout[i] = scancode;
    6.55                  if (scancode == SDL_SCANCODE_UNKNOWN) {
     7.1 --- a/src/video/x11/SDL_x11messagebox.c	Thu Oct 17 20:49:30 2013 -0700
     7.2 +++ b/src/video/x11/SDL_x11messagebox.c	Fri Oct 18 01:36:41 2013 -0400
     7.3 @@ -124,13 +124,13 @@
     7.4  {
     7.5      if (SDL_X11_HAVE_UTF8) {
     7.6          XRectangle overall_ink, overall_logical;
     7.7 -        Xutf8TextExtents(data->font_set, str, nbytes, &overall_ink, &overall_logical);
     7.8 +        X11_Xutf8TextExtents(data->font_set, str, nbytes, &overall_ink, &overall_logical);
     7.9          *pwidth = overall_logical.width;
    7.10          *pheight = overall_logical.height;
    7.11      } else {
    7.12          XCharStruct text_structure;
    7.13          int font_direction, font_ascent, font_descent;
    7.14 -        XTextExtents( data->font_struct, str, nbytes,
    7.15 +        X11_XTextExtents( data->font_struct, str, nbytes,
    7.16                        &font_direction, &font_ascent, &font_descent,
    7.17                        &text_structure );
    7.18          *pwidth = text_structure.width;
    7.19 @@ -180,7 +180,7 @@
    7.20      data->numbuttons = numbuttons;
    7.21      data->pbuttonid = pbuttonid;
    7.22  
    7.23 -    data->display = XOpenDisplay( NULL );
    7.24 +    data->display = X11_XOpenDisplay( NULL );
    7.25      if ( !data->display ) {
    7.26          return SDL_SetError("Couldn't open X11 display");
    7.27      }
    7.28 @@ -188,16 +188,16 @@
    7.29      if (SDL_X11_HAVE_UTF8) {
    7.30          char **missing = NULL;
    7.31          int num_missing = 0;
    7.32 -        data->font_set = XCreateFontSet(data->display, g_MessageBoxFont,
    7.33 +        data->font_set = X11_XCreateFontSet(data->display, g_MessageBoxFont,
    7.34                                          &missing, &num_missing, NULL);
    7.35          if ( missing != NULL ) {
    7.36 -            XFreeStringList(missing);
    7.37 +            X11_XFreeStringList(missing);
    7.38          }
    7.39          if ( data->font_set == NULL ) {
    7.40              return SDL_SetError("Couldn't load font %s", g_MessageBoxFont);
    7.41          }
    7.42      } else {
    7.43 -        data->font_struct = XLoadQueryFont( data->display, g_MessageBoxFontLatin1 );
    7.44 +        data->font_struct = X11_XLoadQueryFont( data->display, g_MessageBoxFontLatin1 );
    7.45          if ( data->font_struct == NULL ) {
    7.46              return SDL_SetError("Couldn't load font %s", g_MessageBoxFontLatin1);
    7.47          }
    7.48 @@ -338,23 +338,23 @@
    7.49  X11_MessageBoxShutdown( SDL_MessageBoxDataX11 *data )
    7.50  {
    7.51      if ( data->font_set != NULL ) {
    7.52 -        XFreeFontSet( data->display, data->font_set );
    7.53 +        X11_XFreeFontSet( data->display, data->font_set );
    7.54          data->font_set = NULL;
    7.55      }
    7.56  
    7.57      if ( data->font_struct != NULL ) {
    7.58 -        XFreeFont( data->display, data->font_struct );
    7.59 +        X11_XFreeFont( data->display, data->font_struct );
    7.60          data->font_struct = NULL;
    7.61      }
    7.62  
    7.63      if ( data->display ) {
    7.64          if ( data->window != None ) {
    7.65 -            XWithdrawWindow( data->display, data->window, data->screen );
    7.66 -            XDestroyWindow( data->display, data->window );
    7.67 +            X11_XWithdrawWindow( data->display, data->window, data->screen );
    7.68 +            X11_XDestroyWindow( data->display, data->window );
    7.69              data->window = None;
    7.70          }
    7.71  
    7.72 -        XCloseDisplay( data->display );
    7.73 +        X11_XCloseDisplay( data->display );
    7.74          data->display = NULL;
    7.75      }
    7.76  }
    7.77 @@ -384,7 +384,7 @@
    7.78                         StructureNotifyMask | FocusChangeMask | PointerMotionMask;
    7.79      wnd_attr.event_mask = data->event_mask;
    7.80  
    7.81 -    data->window = XCreateWindow(
    7.82 +    data->window = X11_XCreateWindow(
    7.83                         display, RootWindow(display, data->screen),
    7.84                         0, 0,
    7.85                         data->dialog_width, data->dialog_height,
    7.86 @@ -396,31 +396,31 @@
    7.87  
    7.88      if ( windowdata ) {
    7.89          /* http://tronche.com/gui/x/icccm/sec-4.html#WM_TRANSIENT_FOR */
    7.90 -        XSetTransientForHint( display, data->window, windowdata->xwindow );
    7.91 +        X11_XSetTransientForHint( display, data->window, windowdata->xwindow );
    7.92      }
    7.93  
    7.94 -    XStoreName( display, data->window, messageboxdata->title );
    7.95 +    X11_XStoreName( display, data->window, messageboxdata->title );
    7.96  
    7.97      /* Allow the window to be deleted by the window manager */
    7.98 -    data->wm_protocols = XInternAtom( display, "WM_PROTOCOLS", False );
    7.99 -    data->wm_delete_message = XInternAtom( display, "WM_DELETE_WINDOW", False );
   7.100 -    XSetWMProtocols( display, data->window, &data->wm_delete_message, 1 );
   7.101 +    data->wm_protocols = X11_XInternAtom( display, "WM_PROTOCOLS", False );
   7.102 +    data->wm_delete_message = X11_XInternAtom( display, "WM_DELETE_WINDOW", False );
   7.103 +    X11_XSetWMProtocols( display, data->window, &data->wm_delete_message, 1 );
   7.104  
   7.105      if ( windowdata ) {
   7.106          XWindowAttributes attrib;
   7.107          Window dummy;
   7.108  
   7.109 -        XGetWindowAttributes(display, windowdata->xwindow, &attrib);
   7.110 +        X11_XGetWindowAttributes(display, windowdata->xwindow, &attrib);
   7.111          x = attrib.x + ( attrib.width - data->dialog_width ) / 2;
   7.112          y = attrib.y + ( attrib.height - data->dialog_height ) / 3 ;
   7.113 -        XTranslateCoordinates(display, windowdata->xwindow, RootWindow(display, data->screen), x, y, &x, &y, &dummy);
   7.114 +        X11_XTranslateCoordinates(display, windowdata->xwindow, RootWindow(display, data->screen), x, y, &x, &y, &dummy);
   7.115      } else {
   7.116          x = ( DisplayWidth( display, data->screen ) - data->dialog_width ) / 2;
   7.117          y = ( DisplayHeight( display, data->screen ) - data->dialog_height ) / 3 ;
   7.118      }
   7.119 -    XMoveWindow( display, data->window, x, y );
   7.120 +    X11_XMoveWindow( display, data->window, x, y );
   7.121  
   7.122 -    sizehints = XAllocSizeHints();
   7.123 +    sizehints = X11_XAllocSizeHints();
   7.124      if ( sizehints ) {
   7.125          sizehints->flags = USPosition | USSize | PMaxSize | PMinSize;
   7.126          sizehints->x = x;
   7.127 @@ -431,12 +431,12 @@
   7.128          sizehints->min_width = sizehints->max_width = data->dialog_width;
   7.129          sizehints->min_height = sizehints->max_height = data->dialog_height;
   7.130  
   7.131 -        XSetWMNormalHints( display, data->window, sizehints );
   7.132 +        X11_XSetWMNormalHints( display, data->window, sizehints );
   7.133  
   7.134 -        XFree( sizehints );
   7.135 +        X11_XFree( sizehints );
   7.136      }
   7.137  
   7.138 -    XMapRaised( display, data->window );
   7.139 +    X11_XMapRaised( display, data->window );
   7.140      return 0;
   7.141  }
   7.142  
   7.143 @@ -448,19 +448,19 @@
   7.144      Window window = data->window;
   7.145      Display *display = data->display;
   7.146  
   7.147 -    XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_BACKGROUND ] );
   7.148 -    XFillRectangle( display, window, ctx, 0, 0, data->dialog_width, data->dialog_height );
   7.149 +    X11_XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_BACKGROUND ] );
   7.150 +    X11_XFillRectangle( display, window, ctx, 0, 0, data->dialog_width, data->dialog_height );
   7.151  
   7.152 -    XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_TEXT ] );
   7.153 +    X11_XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_TEXT ] );
   7.154      for ( i = 0; i < data->numlines; i++ ) {
   7.155          TextLineData *plinedata = &data->linedata[ i ];
   7.156  
   7.157          if (SDL_X11_HAVE_UTF8) {
   7.158 -            Xutf8DrawString( display, window, data->font_set, ctx,
   7.159 +            X11_Xutf8DrawString( display, window, data->font_set, ctx,
   7.160                               data->xtext, data->ytext + i * data->text_height,
   7.161                               plinedata->text, plinedata->length );
   7.162          } else {
   7.163 -            XDrawString( display, window, ctx,
   7.164 +            X11_XDrawString( display, window, ctx,
   7.165                           data->xtext, data->ytext + i * data->text_height,
   7.166                           plinedata->text, plinedata->length );
   7.167          }
   7.168 @@ -472,27 +472,27 @@
   7.169          int border = ( buttondata->flags & SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT ) ? 2 : 0;
   7.170          int offset = ( ( data->mouse_over_index == i ) && ( data->button_press_index == data->mouse_over_index ) ) ? 1 : 0;
   7.171  
   7.172 -        XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND ] );
   7.173 -        XFillRectangle( display, window, ctx,
   7.174 +        X11_XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND ] );
   7.175 +        X11_XFillRectangle( display, window, ctx,
   7.176                          buttondatax11->rect.x - border, buttondatax11->rect.y - border,
   7.177                          buttondatax11->rect.w + 2 * border, buttondatax11->rect.h + 2 * border );
   7.178  
   7.179 -        XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_BUTTON_BORDER ] );
   7.180 -        XDrawRectangle( display, window, ctx,
   7.181 +        X11_XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_BUTTON_BORDER ] );
   7.182 +        X11_XDrawRectangle( display, window, ctx,
   7.183                          buttondatax11->rect.x, buttondatax11->rect.y,
   7.184                          buttondatax11->rect.w, buttondatax11->rect.h );
   7.185  
   7.186 -        XSetForeground( display, ctx, ( data->mouse_over_index == i ) ?
   7.187 +        X11_XSetForeground( display, ctx, ( data->mouse_over_index == i ) ?
   7.188                          data->color[ SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED ] :
   7.189                          data->color[ SDL_MESSAGEBOX_COLOR_TEXT ] );
   7.190  
   7.191          if (SDL_X11_HAVE_UTF8) {
   7.192 -            Xutf8DrawString( display, window, data->font_set, ctx,
   7.193 +            X11_Xutf8DrawString( display, window, data->font_set, ctx,
   7.194                               buttondatax11->x + offset,
   7.195                               buttondatax11->y + offset,
   7.196                               buttondata->text, buttondatax11->length );
   7.197          } else {
   7.198 -            XDrawString( display, window, ctx,
   7.199 +            X11_XDrawString( display, window, ctx,
   7.200                           buttondatax11->x + offset, buttondatax11->y + offset,
   7.201                           buttondata->text, buttondatax11->length );
   7.202          }
   7.203 @@ -519,7 +519,7 @@
   7.204          ctx_vals.font = data->font_struct->fid;
   7.205      }
   7.206  
   7.207 -    ctx = XCreateGC( data->display, data->window, gcflags, &ctx_vals );
   7.208 +    ctx = X11_XCreateGC( data->display, data->window, gcflags, &ctx_vals );
   7.209      if ( ctx == None ) {
   7.210          return SDL_SetError("Couldn't create graphics context");
   7.211      }
   7.212 @@ -531,11 +531,11 @@
   7.213          XEvent e;
   7.214          SDL_bool draw = SDL_TRUE;
   7.215  
   7.216 -        XWindowEvent( data->display, data->window, data->event_mask, &e );
   7.217 +        X11_XWindowEvent( data->display, data->window, data->event_mask, &e );
   7.218  
   7.219 -        /* If XFilterEvent returns True, then some input method has filtered the
   7.220 +        /* If X11_XFilterEvent returns True, then some input method has filtered the
   7.221             event, and the client should discard the event. */
   7.222 -        if ( ( e.type != Expose ) && XFilterEvent( &e, None ) )
   7.223 +        if ( ( e.type != Expose ) && X11_XFilterEvent( &e, None ) )
   7.224              continue;
   7.225  
   7.226          switch( e.type ) {
   7.227 @@ -574,12 +574,12 @@
   7.228  
   7.229          case KeyPress:
   7.230              /* Store key press - we make sure in key release that we got both. */
   7.231 -            last_key_pressed = XLookupKeysym( &e.xkey, 0 );
   7.232 +            last_key_pressed = X11_XLookupKeysym( &e.xkey, 0 );
   7.233              break;
   7.234  
   7.235          case KeyRelease: {
   7.236              Uint32 mask = 0;
   7.237 -            KeySym key = XLookupKeysym( &e.xkey, 0 );
   7.238 +            KeySym key = X11_XLookupKeysym( &e.xkey, 0 );
   7.239  
   7.240              /* If this is a key release for something we didn't get the key down for, then bail. */
   7.241              if ( key != last_key_pressed )
   7.242 @@ -637,7 +637,7 @@
   7.243          }
   7.244      }
   7.245  
   7.246 -    XFreeGC( data->display, ctx );
   7.247 +    X11_XFreeGC( data->display, ctx );
   7.248      return 0;
   7.249  }
   7.250  
   7.251 @@ -667,7 +667,7 @@
   7.252  #endif
   7.253  
   7.254      /* This code could get called from multiple threads maybe? */
   7.255 -    XInitThreads();
   7.256 +    X11_XInitThreads();
   7.257  
   7.258      /* Initialize the return buttonid value to -1 (for error or dialogbox closed). */
   7.259      *buttonid = -1;
   7.260 @@ -707,7 +707,7 @@
   7.261      int status = 0;
   7.262  
   7.263      /* Need to flush here in case someone has turned grab off and it hasn't gone through yet, etc. */
   7.264 -    XFlush(data->display);
   7.265 +    X11_XFlush(data->display);
   7.266  
   7.267      if (pipe(fds) == -1) {
   7.268          return X11_ShowMessageBoxImpl(messageboxdata, buttonid); /* oh well. */
     8.1 --- a/src/video/x11/SDL_x11modes.c	Thu Oct 17 20:49:30 2013 -0700
     8.2 +++ b/src/video/x11/SDL_x11modes.c	Fri Oct 18 01:36:41 2013 -0400
     8.3 @@ -54,20 +54,20 @@
     8.4  
     8.5          SDL_zero(template);
     8.6          template.visualid = SDL_strtol(visual_id, NULL, 0);
     8.7 -        vi = XGetVisualInfo(display, VisualIDMask, &template, &nvis);
     8.8 +        vi = X11_XGetVisualInfo(display, VisualIDMask, &template, &nvis);
     8.9          if (vi) {
    8.10              *vinfo = *vi;
    8.11 -            XFree(vi);
    8.12 +            X11_XFree(vi);
    8.13              return 0;
    8.14          }
    8.15      }
    8.16  
    8.17      depth = DefaultDepth(display, screen);
    8.18      if ((X11_UseDirectColorVisuals() &&
    8.19 -         XMatchVisualInfo(display, screen, depth, DirectColor, vinfo)) ||
    8.20 -        XMatchVisualInfo(display, screen, depth, TrueColor, vinfo) ||
    8.21 -        XMatchVisualInfo(display, screen, depth, PseudoColor, vinfo) ||
    8.22 -        XMatchVisualInfo(display, screen, depth, StaticColor, vinfo)) {
    8.23 +         X11_XMatchVisualInfo(display, screen, depth, DirectColor, vinfo)) ||
    8.24 +        X11_XMatchVisualInfo(display, screen, depth, TrueColor, vinfo) ||
    8.25 +        X11_XMatchVisualInfo(display, screen, depth, PseudoColor, vinfo) ||
    8.26 +        X11_XMatchVisualInfo(display, screen, depth, StaticColor, vinfo)) {
    8.27          return 0;
    8.28      }
    8.29      return -1;
    8.30 @@ -79,11 +79,11 @@
    8.31      XVisualInfo *vi;
    8.32      int nvis;
    8.33  
    8.34 -    vinfo->visualid = XVisualIDFromVisual(visual);
    8.35 -    vi = XGetVisualInfo(display, VisualIDMask, vinfo, &nvis);
    8.36 +    vinfo->visualid = X11_XVisualIDFromVisual(visual);
    8.37 +    vi = X11_XGetVisualInfo(display, VisualIDMask, vinfo, &nvis);
    8.38      if (vi) {
    8.39          *vinfo = *vi;
    8.40 -        XFree(vi);
    8.41 +        X11_XFree(vi);
    8.42          return 0;
    8.43      }
    8.44      return -1;
    8.45 @@ -108,7 +108,7 @@
    8.46          bpp = vinfo->depth;
    8.47          if (bpp == 24) {
    8.48              int i, n;
    8.49 -            XPixmapFormatValues *p = XListPixmapFormats(display, &n);
    8.50 +            XPixmapFormatValues *p = X11_XListPixmapFormats(display, &n);
    8.51              if (p) {
    8.52                  for (i = 0; i < n; ++i) {
    8.53                      if (p[i].depth == 24) {
    8.54 @@ -116,7 +116,7 @@
    8.55                          break;
    8.56                      }
    8.57                  }
    8.58 -                XFree(p);
    8.59 +                X11_XFree(p);
    8.60              }
    8.61          }
    8.62  
    8.63 @@ -178,9 +178,9 @@
    8.64      }
    8.65  
    8.66      /* Query the extension version */
    8.67 -    if (!XineramaQueryExtension(display, &event_base, &error_base) ||
    8.68 -        !XineramaQueryVersion(display, major, minor) ||
    8.69 -        !XineramaIsActive(display)) {
    8.70 +    if (!X11_XineramaQueryExtension(display, &event_base, &error_base) ||
    8.71 +        !X11_XineramaQueryVersion(display, major, minor) ||
    8.72 +        !X11_XineramaIsActive(display)) {
    8.73  #ifdef X11MODES_DEBUG
    8.74          printf("Xinerama not active on the display\n");
    8.75  #endif
    8.76 @@ -228,7 +228,7 @@
    8.77      }
    8.78  
    8.79      /* Query the extension version */
    8.80 -    if (!XRRQueryVersion(display, major, minor)) {
    8.81 +    if (!X11_XRRQueryVersion(display, major, minor)) {
    8.82  #ifdef X11MODES_DEBUG
    8.83          printf("XRandR not active on the display\n");
    8.84  #endif
    8.85 @@ -261,10 +261,10 @@
    8.86              Rotation rotation = 0;
    8.87              const XRRModeInfo *info = &res->modes[i];
    8.88  
    8.89 -            crtc = XRRGetCrtcInfo(display, res, output_info->crtc);
    8.90 +            crtc = X11_XRRGetCrtcInfo(display, res, output_info->crtc);
    8.91              if (crtc) {
    8.92                  rotation = crtc->rotation;
    8.93 -                XRRFreeCrtcInfo(crtc);
    8.94 +                X11_XRRFreeCrtcInfo(crtc);
    8.95              }
    8.96  
    8.97              if (rotation & (XRANDR_ROTATION_LEFT|XRANDR_ROTATION_RIGHT)) {
    8.98 @@ -313,8 +313,8 @@
    8.99  
   8.100      /* Query the extension version */
   8.101      vm_error = -1;
   8.102 -    if (!XF86VidModeQueryExtension(display, &vm_event, &vm_error)
   8.103 -        || !XF86VidModeQueryVersion(display, major, minor)) {
   8.104 +    if (!X11_XF86VidModeQueryExtension(display, &vm_event, &vm_error)
   8.105 +        || !X11_XF86VidModeQueryVersion(display, major, minor)) {
   8.106  #ifdef X11MODES_DEBUG
   8.107          printf("XVidMode not active on the display\n");
   8.108  #endif
   8.109 @@ -335,7 +335,7 @@
   8.110      XF86VidModeModeLine l;
   8.111      SDL_zerop(info);
   8.112      SDL_zero(l);
   8.113 -    retval = XF86VidModeGetModeLine(dpy, scr, &dotclock, &l);
   8.114 +    retval = X11_XF86VidModeGetModeLine(dpy, scr, &dotclock, &l);
   8.115      info->dotclock = dotclock;
   8.116      info->hdisplay = l.hdisplay;
   8.117      info->hsyncstart = l.hsyncstart;
   8.118 @@ -397,7 +397,7 @@
   8.119       *       or newer of the Nvidia binary drivers
   8.120       */
   8.121      if (CheckXinerama(data->display, &xinerama_major, &xinerama_minor)) {
   8.122 -        xinerama = XineramaQueryScreens(data->display, &screencount);
   8.123 +        xinerama = X11_XineramaQueryScreens(data->display, &screencount);
   8.124          if (xinerama) {
   8.125              use_xinerama = xinerama_major * 100 + xinerama_minor;
   8.126          }
   8.127 @@ -501,7 +501,7 @@
   8.128          displaydata->depth = vinfo.depth;
   8.129  
   8.130          displaydata->scanline_pad = SDL_BYTESPERPIXEL(mode.format) * 8;
   8.131 -        pixmapFormats = XListPixmapFormats(data->display, &n);
   8.132 +        pixmapFormats = X11_XListPixmapFormats(data->display, &n);
   8.133          if (pixmapFormats) {
   8.134              for (i = 0; i < n; ++i) {
   8.135                  if (pixmapFormats[i].depth == displaydata->depth) {
   8.136 @@ -509,7 +509,7 @@
   8.137                      break;
   8.138                  }
   8.139              }
   8.140 -            XFree(pixmapFormats);
   8.141 +            X11_XFree(pixmapFormats);
   8.142          }
   8.143  
   8.144  #if SDL_VIDEO_DRIVER_X11_XINERAMA
   8.145 @@ -526,13 +526,13 @@
   8.146  
   8.147  #if SDL_VIDEO_DRIVER_X11_XRANDR
   8.148          if (use_xrandr) {
   8.149 -            res = XRRGetScreenResources(data->display, RootWindow(data->display, displaydata->screen));
   8.150 +            res = X11_XRRGetScreenResources(data->display, RootWindow(data->display, displaydata->screen));
   8.151          }
   8.152          if (res) {
   8.153              XRROutputInfo *output_info;
   8.154              XRRCrtcInfo *crtc;
   8.155              int output;
   8.156 -            Atom EDID = XInternAtom(data->display, "EDID", False);
   8.157 +            Atom EDID = X11_XInternAtom(data->display, "EDID", False);
   8.158              Atom *props;
   8.159              int nprop;
   8.160              unsigned long width_mm;
   8.161 @@ -540,10 +540,10 @@
   8.162              int inches = 0;
   8.163  
   8.164              for (output = 0; output < res->noutput; output++) {
   8.165 -                output_info = XRRGetOutputInfo(data->display, res, res->outputs[output]);
   8.166 +                output_info = X11_XRRGetOutputInfo(data->display, res, res->outputs[output]);
   8.167                  if (!output_info || !output_info->crtc ||
   8.168                      output_info->connection == RR_Disconnected) {
   8.169 -                    XRRFreeOutputInfo(output_info);
   8.170 +                    X11_XRRFreeOutputInfo(output_info);
   8.171                      continue;
   8.172                  }
   8.173  
   8.174 @@ -551,10 +551,10 @@
   8.175                     We're checking the crtc position, but that may not be a valid test
   8.176                     in all cases.  Anybody want to give this some love?
   8.177                   */
   8.178 -                crtc = XRRGetCrtcInfo(data->display, res, output_info->crtc);
   8.179 +                crtc = X11_XRRGetCrtcInfo(data->display, res, output_info->crtc);
   8.180                  if (!crtc || crtc->x != displaydata->x || crtc->y != displaydata->y) {
   8.181 -                    XRRFreeOutputInfo(output_info);
   8.182 -                    XRRFreeCrtcInfo(crtc);
   8.183 +                    X11_XRRFreeOutputInfo(output_info);
   8.184 +                    X11_XRRFreeCrtcInfo(crtc);
   8.185                      continue;
   8.186                  }
   8.187  
   8.188 @@ -570,7 +570,7 @@
   8.189                  SDL_strlcpy(display_name, output_info->name, sizeof(display_name));
   8.190  
   8.191                  /* See if we can get the EDID data for the real monitor name */
   8.192 -                props = XRRListOutputProperties(data->display, res->outputs[output], &nprop);
   8.193 +                props = X11_XRRListOutputProperties(data->display, res->outputs[output], &nprop);
   8.194                  for (i = 0; i < nprop; ++i) {
   8.195                      unsigned char *prop;
   8.196                      int actual_format;
   8.197 @@ -578,7 +578,7 @@
   8.198                      Atom actual_type;
   8.199  
   8.200                      if (props[i] == EDID) {
   8.201 -                        if (XRRGetOutputProperty(data->display,
   8.202 +                        if (X11_XRRGetOutputProperty(data->display,
   8.203                                                   res->outputs[output], props[i],
   8.204                                                   0, 100, False, False,
   8.205                                                   AnyPropertyType,
   8.206 @@ -593,13 +593,13 @@
   8.207                                  SDL_strlcpy(display_name, info->dsc_product_name, sizeof(display_name));
   8.208                                  free(info);
   8.209                              }
   8.210 -                            XFree(prop);
   8.211 +                            X11_XFree(prop);
   8.212                          }
   8.213                          break;
   8.214                      }
   8.215                  }
   8.216                  if (props) {
   8.217 -                    XFree(props);
   8.218 +                    X11_XFree(props);
   8.219                  }
   8.220  
   8.221                  if (*display_name && inches) {
   8.222 @@ -610,8 +610,8 @@
   8.223                  printf("Display name: %s\n", display_name);
   8.224  #endif
   8.225  
   8.226 -                XRRFreeOutputInfo(output_info);
   8.227 -                XRRFreeCrtcInfo(crtc);
   8.228 +                X11_XRRFreeOutputInfo(output_info);
   8.229 +                X11_XRRFreeCrtcInfo(crtc);
   8.230                  break;
   8.231              }
   8.232  #ifdef X11MODES_DEBUG
   8.233 @@ -619,7 +619,7 @@
   8.234                  printf("Couldn't find XRandR CRTC at %d,%d\n", displaydata->x, displaydata->y);
   8.235              }
   8.236  #endif
   8.237 -            XRRFreeScreenResources(res);
   8.238 +            X11_XRRFreeScreenResources(res);
   8.239          }
   8.240  #endif /* SDL_VIDEO_DRIVER_X11_XRANDR */
   8.241  
   8.242 @@ -652,7 +652,7 @@
   8.243      }
   8.244  
   8.245  #if SDL_VIDEO_DRIVER_X11_XINERAMA
   8.246 -    if (xinerama) XFree(xinerama);
   8.247 +    if (xinerama) X11_XFree(xinerama);
   8.248  #endif
   8.249  
   8.250      if (_this->num_displays == 0) {
   8.251 @@ -725,13 +725,13 @@
   8.252      if (data->use_xrandr) {
   8.253          XRRScreenResources *res;
   8.254  
   8.255 -        res = XRRGetScreenResources (display, RootWindow(display, data->screen));
   8.256 +        res = X11_XRRGetScreenResources (display, RootWindow(display, data->screen));
   8.257          if (res) {
   8.258              SDL_DisplayModeData *modedata;
   8.259              XRROutputInfo *output_info;
   8.260              int i;
   8.261  
   8.262 -            output_info = XRRGetOutputInfo(display, res, data->xrandr_output);
   8.263 +            output_info = X11_XRRGetOutputInfo(display, res, data->xrandr_output);
   8.264              if (output_info && output_info->connection != RR_Disconnected) {
   8.265                  for (i = 0; i < output_info->nmode; ++i) {
   8.266                      modedata = (SDL_DisplayModeData *) SDL_calloc(1, sizeof(SDL_DisplayModeData));
   8.267 @@ -747,8 +747,8 @@
   8.268                      }
   8.269                  }
   8.270              }
   8.271 -            XRRFreeOutputInfo(output_info);
   8.272 -            XRRFreeScreenResources(res);
   8.273 +            X11_XRRFreeOutputInfo(output_info);
   8.274 +            X11_XRRFreeScreenResources(res);
   8.275          }
   8.276          return;
   8.277      }
   8.278 @@ -756,7 +756,7 @@
   8.279  
   8.280  #if SDL_VIDEO_DRIVER_X11_XVIDMODE
   8.281      if (data->use_vidmode &&
   8.282 -        XF86VidModeGetAllModeLines(display, data->vidmode_screen, &nmodes, &modes)) {
   8.283 +        X11_XF86VidModeGetAllModeLines(display, data->vidmode_screen, &nmodes, &modes)) {
   8.284          int i;
   8.285  
   8.286  #ifdef X11MODES_DEBUG
   8.287 @@ -780,7 +780,7 @@
   8.288                  SDL_free(modedata);
   8.289              }
   8.290          }
   8.291 -        XFree(modes);
   8.292 +        X11_XFree(modes);
   8.293          return;
   8.294      }
   8.295  #endif /* SDL_VIDEO_DRIVER_X11_XVIDMODE */
   8.296 @@ -811,41 +811,41 @@
   8.297          XRRCrtcInfo *crtc;
   8.298          Status status;
   8.299  
   8.300 -        res = XRRGetScreenResources (display, RootWindow(display, data->screen));
   8.301 +        res = X11_XRRGetScreenResources (display, RootWindow(display, data->screen));
   8.302          if (!res) {
   8.303              return SDL_SetError("Couldn't get XRandR screen resources");
   8.304          }
   8.305  
   8.306 -        output_info = XRRGetOutputInfo(display, res, data->xrandr_output);
   8.307 +        output_info = X11_XRRGetOutputInfo(display, res, data->xrandr_output);
   8.308          if (!output_info || output_info->connection == RR_Disconnected) {
   8.309 -            XRRFreeScreenResources(res);
   8.310 +            X11_XRRFreeScreenResources(res);
   8.311              return SDL_SetError("Couldn't get XRandR output info");
   8.312          }
   8.313  
   8.314 -        crtc = XRRGetCrtcInfo(display, res, output_info->crtc);
   8.315 +        crtc = X11_XRRGetCrtcInfo(display, res, output_info->crtc);
   8.316          if (!crtc) {
   8.317 -            XRRFreeOutputInfo(output_info);
   8.318 -            XRRFreeScreenResources(res);
   8.319 +            X11_XRRFreeOutputInfo(output_info);
   8.320 +            X11_XRRFreeScreenResources(res);
   8.321              return SDL_SetError("Couldn't get XRandR crtc info");
   8.322          }
   8.323  
   8.324 -        status = XRRSetCrtcConfig (display, res, output_info->crtc, CurrentTime,
   8.325 +        status = X11_XRRSetCrtcConfig (display, res, output_info->crtc, CurrentTime,
   8.326            crtc->x, crtc->y, modedata->xrandr_mode, crtc->rotation,
   8.327            &data->xrandr_output, 1);
   8.328  
   8.329 -        XRRFreeCrtcInfo(crtc);
   8.330 -        XRRFreeOutputInfo(output_info);
   8.331 -        XRRFreeScreenResources(res);
   8.332 +        X11_XRRFreeCrtcInfo(crtc);
   8.333 +        X11_XRRFreeOutputInfo(output_info);
   8.334 +        X11_XRRFreeScreenResources(res);
   8.335  
   8.336          if (status != Success) {
   8.337 -            return SDL_SetError("XRRSetCrtcConfig failed");
   8.338 +            return SDL_SetError("X11_XRRSetCrtcConfig failed");
   8.339          }
   8.340      }
   8.341  #endif /* SDL_VIDEO_DRIVER_X11_XRANDR */
   8.342  
   8.343  #if SDL_VIDEO_DRIVER_X11_XVIDMODE
   8.344      if (data->use_vidmode) {
   8.345 -        XF86VidModeSwitchToMode(display, data->vidmode_screen, &modedata->vm_mode);
   8.346 +        X11_XF86VidModeSwitchToMode(display, data->vidmode_screen, &modedata->vm_mode);
   8.347      }
   8.348  #endif /* SDL_VIDEO_DRIVER_X11_XVIDMODE */
   8.349  
   8.350 @@ -872,11 +872,11 @@
   8.351      if (data->use_xinerama) {
   8.352          Display *display = ((SDL_VideoData *) _this->driverdata)->display;
   8.353          int screencount;
   8.354 -        XineramaScreenInfo *xinerama = XineramaQueryScreens(display, &screencount);
   8.355 +        XineramaScreenInfo *xinerama = X11_XineramaQueryScreens(display, &screencount);
   8.356          if (xinerama) {
   8.357              rect->x = xinerama[data->xinerama_screen].x_org;
   8.358              rect->y = xinerama[data->xinerama_screen].y_org;
   8.359 -            XFree(xinerama);
   8.360 +            X11_XFree(xinerama);
   8.361          }
   8.362      }
   8.363  #endif /* SDL_VIDEO_DRIVER_X11_XINERAMA */
     9.1 --- a/src/video/x11/SDL_x11mouse.c	Thu Oct 17 20:49:30 2013 -0700
     9.2 +++ b/src/video/x11/SDL_x11mouse.c	Fri Oct 18 01:36:41 2013 -0400
     9.3 @@ -50,12 +50,12 @@
     9.4  
     9.5          SDL_zero(data);
     9.6          color.red = color.green = color.blue = 0;
     9.7 -        pixmap = XCreateBitmapFromData(display, DefaultRootWindow(display),
     9.8 +        pixmap = X11_XCreateBitmapFromData(display, DefaultRootWindow(display),
     9.9                                         data, 1, 1);
    9.10          if (pixmap) {
    9.11 -            x11_empty_cursor = XCreatePixmapCursor(display, pixmap, pixmap,
    9.12 +            x11_empty_cursor = X11_XCreatePixmapCursor(display, pixmap, pixmap,
    9.13                                                     &color, &color, 0, 0);
    9.14 -            XFreePixmap(display, pixmap);
    9.15 +            X11_XFreePixmap(display, pixmap);
    9.16          }
    9.17      }
    9.18      return x11_empty_cursor;
    9.19 @@ -65,7 +65,7 @@
    9.20  X11_DestroyEmptyCursor(void)
    9.21  {
    9.22      if (x11_empty_cursor != None) {
    9.23 -        XFreeCursor(GetDisplay(), x11_empty_cursor);
    9.24 +        X11_XFreeCursor(GetDisplay(), x11_empty_cursor);
    9.25          x11_empty_cursor = None;
    9.26      }
    9.27  }
    9.28 @@ -94,7 +94,7 @@
    9.29      Cursor cursor = None;
    9.30      XcursorImage *image;
    9.31  
    9.32 -    image = XcursorImageCreate(surface->w, surface->h);
    9.33 +    image = X11_XcursorImageCreate(surface->w, surface->h);
    9.34      if (!image) {
    9.35          SDL_OutOfMemory();
    9.36          return None;
    9.37 @@ -107,9 +107,9 @@
    9.38      SDL_assert(surface->pitch == surface->w * 4);
    9.39      SDL_memcpy(image->pixels, surface->pixels, surface->h * surface->pitch);
    9.40  
    9.41 -    cursor = XcursorImageLoadCursor(display, image);
    9.42 +    cursor = X11_XcursorImageLoadCursor(display, image);
    9.43  
    9.44 -    XcursorImageDestroy(image);
    9.45 +    X11_XcursorImageDestroy(image);
    9.46  
    9.47      return cursor;
    9.48  }
    9.49 @@ -186,16 +186,16 @@
    9.50      }
    9.51      else bg.red = bg.green = bg.blue = 0;
    9.52  
    9.53 -    data_pixmap = XCreateBitmapFromData(display, DefaultRootWindow(display),
    9.54 +    data_pixmap = X11_XCreateBitmapFromData(display, DefaultRootWindow(display),
    9.55                                          (char*)data_bits,
    9.56                                          surface->w, surface->h);
    9.57 -    mask_pixmap = XCreateBitmapFromData(display, DefaultRootWindow(display),
    9.58 +    mask_pixmap = X11_XCreateBitmapFromData(display, DefaultRootWindow(display),
    9.59                                          (char*)mask_bits,
    9.60                                          surface->w, surface->h);
    9.61 -    cursor = XCreatePixmapCursor(display, data_pixmap, mask_pixmap,
    9.62 +    cursor = X11_XCreatePixmapCursor(display, data_pixmap, mask_pixmap,
    9.63                                   &fg, &bg, hot_x, hot_y);
    9.64 -    XFreePixmap(display, data_pixmap);
    9.65 -    XFreePixmap(display, mask_pixmap);
    9.66 +    X11_XFreePixmap(display, data_pixmap);
    9.67 +    X11_XFreePixmap(display, mask_pixmap);
    9.68  
    9.69      return cursor;
    9.70  }
    9.71 @@ -256,7 +256,7 @@
    9.72      if (cursor) {
    9.73          Cursor x11_cursor;
    9.74  
    9.75 -        x11_cursor = XCreateFontCursor(GetDisplay(), shape);
    9.76 +        x11_cursor = X11_XCreateFontCursor(GetDisplay(), shape);
    9.77  
    9.78          cursor->driverdata = (void*)x11_cursor;
    9.79      } else {
    9.80 @@ -272,7 +272,7 @@
    9.81      Cursor x11_cursor = (Cursor)cursor->driverdata;
    9.82  
    9.83      if (x11_cursor != None) {
    9.84 -        XFreeCursor(GetDisplay(), x11_cursor);
    9.85 +        X11_XFreeCursor(GetDisplay(), x11_cursor);
    9.86      }
    9.87      SDL_free(cursor);
    9.88  }
    9.89 @@ -298,12 +298,12 @@
    9.90          for (window = video->windows; window; window = window->next) {
    9.91              data = (SDL_WindowData *)window->driverdata;
    9.92              if (x11_cursor != None) {
    9.93 -                XDefineCursor(display, data->xwindow, x11_cursor);
    9.94 +                X11_XDefineCursor(display, data->xwindow, x11_cursor);
    9.95              } else {
    9.96 -                XUndefineCursor(display, data->xwindow);
    9.97 +                X11_XUndefineCursor(display, data->xwindow);
    9.98              }
    9.99          }
   9.100 -        XFlush(display);
   9.101 +        X11_XFlush(display);
   9.102      }
   9.103      return 0;
   9.104  }
   9.105 @@ -314,8 +314,8 @@
   9.106      SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
   9.107      Display *display = data->videodata->display;
   9.108  
   9.109 -    XWarpPointer(display, None, data->xwindow, 0, 0, 0, 0, x, y);
   9.110 -    XSync(display, False);
   9.111 +    X11_XWarpPointer(display, None, data->xwindow, 0, 0, 0, 0, x, y);
   9.112 +    X11_XSync(display, False);
   9.113  }
   9.114  
   9.115  static int
    10.1 --- a/src/video/x11/SDL_x11opengl.c	Thu Oct 17 20:49:30 2013 -0700
    10.2 +++ b/src/video/x11/SDL_x11opengl.c	Fri Oct 18 01:36:41 2013 -0400
    10.3 @@ -320,16 +320,16 @@
    10.4      xattr.background_pixel = 0;
    10.5      xattr.border_pixel = 0;
    10.6      xattr.colormap =
    10.7 -        XCreateColormap(display, RootWindow(display, screen), vinfo->visual,
    10.8 +        X11_XCreateColormap(display, RootWindow(display, screen), vinfo->visual,
    10.9                          AllocNone);
   10.10 -    w = XCreateWindow(display, RootWindow(display, screen), 0, 0, 32, 32, 0,
   10.11 +    w = X11_XCreateWindow(display, RootWindow(display, screen), 0, 0, 32, 32, 0,
   10.12                        vinfo->depth, InputOutput, vinfo->visual,
   10.13                        (CWBackPixel | CWBorderPixel | CWColormap), &xattr);
   10.14      context = _this->gl_data->glXCreateContext(display, vinfo, NULL, True);
   10.15      if (context) {
   10.16          _this->gl_data->glXMakeCurrent(display, w, context);
   10.17      }
   10.18 -    XFree(vinfo);
   10.19 +    X11_XFree(vinfo);
   10.20  
   10.21      glXQueryExtensionsStringFunc =
   10.22          (const char *(*)(Display *, int)) X11_GL_GetProcAddress(_this,
   10.23 @@ -385,7 +385,7 @@
   10.24          _this->gl_data->glXMakeCurrent(display, None, NULL);
   10.25          _this->gl_data->glXDestroyContext(display, context);
   10.26      }
   10.27 -    XDestroyWindow(display, w);
   10.28 +    X11_XDestroyWindow(display, w);
   10.29      X11_PumpEvents(_this);
   10.30  }
   10.31  
   10.32 @@ -566,13 +566,13 @@
   10.33      }
   10.34  
   10.35      /* We do this to create a clean separation between X and GLX errors. */
   10.36 -    XSync(display, False);
   10.37 +    X11_XSync(display, False);
   10.38      errorBase = _this->gl_data->errorBase;
   10.39 -    handler = XSetErrorHandler(X11_GL_CreateContextErrorHandler);
   10.40 -    XGetWindowAttributes(display, data->xwindow, &xattr);
   10.41 +    handler = X11_XSetErrorHandler(X11_GL_CreateContextErrorHandler);
   10.42 +    X11_XGetWindowAttributes(display, data->xwindow, &xattr);
   10.43      v.screen = screen;
   10.44 -    v.visualid = XVisualIDFromVisual(xattr.visual);
   10.45 -    vinfo = XGetVisualInfo(display, VisualScreenMask | VisualIDMask, &v, &n);
   10.46 +    v.visualid = X11_XVisualIDFromVisual(xattr.visual);
   10.47 +    vinfo = X11_XGetVisualInfo(display, VisualScreenMask | VisualIDMask, &v, &n);
   10.48      if (vinfo) {
   10.49          if (_this->gl_config.major_version < 3 &&
   10.50              _this->gl_config.profile_mask == 0 &&
   10.51 @@ -656,10 +656,10 @@
   10.52                  }
   10.53              }
   10.54          }
   10.55 -        XFree(vinfo);
   10.56 +        X11_XFree(vinfo);
   10.57      }
   10.58 -    XSync(display, False);
   10.59 -    XSetErrorHandler(handler);
   10.60 +    X11_XSync(display, False);
   10.61 +    X11_XSetErrorHandler(handler);
   10.62  
   10.63      if (!context) {
   10.64          SDL_SetError("Could not create GL context");
   10.65 @@ -801,7 +801,7 @@
   10.66          return;
   10.67      }
   10.68      _this->gl_data->glXDestroyContext(display, glx_context);
   10.69 -    XSync(display, False);
   10.70 +    X11_XSync(display, False);
   10.71  }
   10.72  
   10.73  #endif /* SDL_VIDEO_OPENGL_GLX */
    11.1 --- a/src/video/x11/SDL_x11opengles.c	Thu Oct 17 20:49:30 2013 -0700
    11.2 +++ b/src/video/x11/SDL_x11opengles.c	Fri Oct 18 01:36:41 2013 -0400
    11.3 @@ -74,13 +74,13 @@
    11.4                                              &visual_id) == EGL_FALSE || !visual_id) {
    11.5          /* Use the default visual when all else fails */
    11.6          vi_in.screen = screen;
    11.7 -        egl_visualinfo = XGetVisualInfo(display,
    11.8 +        egl_visualinfo = X11_XGetVisualInfo(display,
    11.9                                          VisualScreenMask,
   11.10                                          &vi_in, &out_count);
   11.11      } else {
   11.12          vi_in.screen = screen;
   11.13          vi_in.visualid = visual_id;
   11.14 -        egl_visualinfo = XGetVisualInfo(display, VisualScreenMask | VisualIDMask, &vi_in, &out_count);
   11.15 +        egl_visualinfo = X11_XGetVisualInfo(display, VisualScreenMask | VisualIDMask, &vi_in, &out_count);
   11.16      }
   11.17  
   11.18      return egl_visualinfo;
   11.19 @@ -93,9 +93,9 @@
   11.20      SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
   11.21      Display *display = data->videodata->display;
   11.22  
   11.23 -    XSync(display, False);
   11.24 +    X11_XSync(display, False);
   11.25      context = SDL_EGL_CreateContext(_this, data->egl_surface);
   11.26 -    XSync(display, False);
   11.27 +    X11_XSync(display, False);
   11.28  
   11.29      return context;
   11.30  }
    12.1 --- a/src/video/x11/SDL_x11shape.c	Thu Oct 17 20:49:30 2013 -0700
    12.2 +++ b/src/video/x11/SDL_x11shape.c	Fri Oct 18 01:36:41 2013 -0400
    12.3 @@ -106,12 +106,12 @@
    12.4      SDL_CalculateShapeBitmap(shaper->mode,shape,data->bitmap,8);
    12.5  
    12.6      windowdata = (SDL_WindowData*)(shaper->window->driverdata);
    12.7 -    shapemask = XCreateBitmapFromData(windowdata->videodata->display,windowdata->xwindow,data->bitmap,shaper->window->w,shaper->window->h);
    12.8 +    shapemask = X11_XCreateBitmapFromData(windowdata->videodata->display,windowdata->xwindow,data->bitmap,shaper->window->w,shaper->window->h);
    12.9  
   12.10 -    XShapeCombineMask(windowdata->videodata->display,windowdata->xwindow, ShapeBounding, 0, 0,shapemask, ShapeSet);
   12.11 -    XSync(windowdata->videodata->display,False);
   12.12 +    X11_XShapeCombineMask(windowdata->videodata->display,windowdata->xwindow, ShapeBounding, 0, 0,shapemask, ShapeSet);
   12.13 +    X11_XSync(windowdata->videodata->display,False);
   12.14  
   12.15 -    XFreePixmap(windowdata->videodata->display,shapemask);
   12.16 +    X11_XFreePixmap(windowdata->videodata->display,shapemask);
   12.17  #endif
   12.18  
   12.19      return 0;
    13.1 --- a/src/video/x11/SDL_x11video.c	Thu Oct 17 20:49:30 2013 -0700
    13.2 +++ b/src/video/x11/SDL_x11video.c	Fri Oct 18 01:36:41 2013 -0400
    13.3 @@ -230,9 +230,9 @@
    13.4  {
    13.5      Display *display = NULL;
    13.6      if (SDL_X11_LoadSymbols()) {
    13.7 -        display = XOpenDisplay(NULL);
    13.8 +        display = X11_XOpenDisplay(NULL);
    13.9          if (display != NULL) {
   13.10 -            XCloseDisplay(display);
   13.11 +            X11_XCloseDisplay(display);
   13.12          }
   13.13          SDL_X11_UnloadSymbols();
   13.14      }
   13.15 @@ -244,7 +244,7 @@
   13.16  {
   13.17      SDL_VideoData *data = (SDL_VideoData *) device->driverdata;
   13.18      if (data->display) {
   13.19 -        XCloseDisplay(data->display);
   13.20 +        X11_XCloseDisplay(data->display);
   13.21      }
   13.22      SDL_free(data->windowlist);
   13.23      SDL_free(device->driverdata);
   13.24 @@ -296,7 +296,7 @@
   13.25  
   13.26      /* Need for threading gl calls. This is also required for the proprietary
   13.27          nVidia driver to be threaded. */
   13.28 -    XInitThreads();
   13.29 +    X11_XInitThreads();
   13.30  
   13.31      /* Initialize all variables that we clean on shutdown */
   13.32      device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
   13.33 @@ -313,14 +313,14 @@
   13.34      device->driverdata = data;
   13.35  
   13.36      /* FIXME: Do we need this?
   13.37 -       if ( (SDL_strncmp(XDisplayName(display), ":", 1) == 0) ||
   13.38 -       (SDL_strncmp(XDisplayName(display), "unix:", 5) == 0) ) {
   13.39 +       if ( (SDL_strncmp(X11_XDisplayName(display), ":", 1) == 0) ||
   13.40 +       (SDL_strncmp(X11_XDisplayName(display), "unix:", 5) == 0) ) {
   13.41         local_X11 = 1;
   13.42         } else {
   13.43         local_X11 = 0;
   13.44         }
   13.45       */
   13.46 -    data->display = XOpenDisplay(display);
   13.47 +    data->display = X11_XOpenDisplay(display);
   13.48  #if defined(__osf__) && defined(SDL_VIDEO_DRIVER_X11_DYNAMIC)
   13.49      /* On Tru64 if linking without -lX11, it fails and you get following message.
   13.50       * Xlib: connection to ":0.0" refused by server
   13.51 @@ -331,7 +331,7 @@
   13.52       */
   13.53      if (data->display == NULL) {
   13.54          SDL_Delay(1000);
   13.55 -        data->display = XOpenDisplay(display);
   13.56 +        data->display = X11_XOpenDisplay(display);
   13.57      }
   13.58  #endif
   13.59      if (data->display == NULL) {
   13.60 @@ -341,12 +341,12 @@
   13.61          return NULL;
   13.62      }
   13.63  #ifdef X11_DEBUG
   13.64 -    XSynchronize(data->display, True);
   13.65 +    X11_XSynchronize(data->display, True);
   13.66  #endif
   13.67  
   13.68      /* Hook up an X11 error handler to recover the desktop resolution. */
   13.69      safety_net_triggered = SDL_FALSE;
   13.70 -    orig_x11_errhandler = XSetErrorHandler(X11_SafetyNetErrHandler);
   13.71 +    orig_x11_errhandler = X11_XSetErrorHandler(X11_SafetyNetErrHandler);
   13.72  
   13.73      /* Set the function pointers */
   13.74      device->VideoInit = X11_VideoInit;
   13.75 @@ -448,31 +448,31 @@
   13.76  #endif
   13.77  
   13.78      /* Set up a handler to gracefully catch errors */
   13.79 -    XSync(display, False);
   13.80 -    handler = XSetErrorHandler(X11_CheckWindowManagerErrorHandler);
   13.81 +    X11_XSync(display, False);
   13.82 +    handler = X11_XSetErrorHandler(X11_CheckWindowManagerErrorHandler);
   13.83  
   13.84 -    _NET_SUPPORTING_WM_CHECK = XInternAtom(display, "_NET_SUPPORTING_WM_CHECK", False);
   13.85 -    status = XGetWindowProperty(display, DefaultRootWindow(display), _NET_SUPPORTING_WM_CHECK, 0L, 1L, False, XA_WINDOW, &real_type, &real_format, &items_read, &items_left, &propdata);
   13.86 +    _NET_SUPPORTING_WM_CHECK = X11_XInternAtom(display, "_NET_SUPPORTING_WM_CHECK", False);
   13.87 +    status = X11_XGetWindowProperty(display, DefaultRootWindow(display), _NET_SUPPORTING_WM_CHECK, 0L, 1L, False, XA_WINDOW, &real_type, &real_format, &items_read, &items_left, &propdata);
   13.88      if (status == Success && items_read) {
   13.89          wm_window = ((Window*)propdata)[0];
   13.90      }
   13.91      if (propdata) {
   13.92 -        XFree(propdata);
   13.93 +        X11_XFree(propdata);
   13.94      }
   13.95  
   13.96      if (wm_window) {
   13.97 -        status = XGetWindowProperty(display, wm_window, _NET_SUPPORTING_WM_CHECK, 0L, 1L, False, XA_WINDOW, &real_type, &real_format, &items_read, &items_left, &propdata);
   13.98 +        status = X11_XGetWindowProperty(display, wm_window, _NET_SUPPORTING_WM_CHECK, 0L, 1L, False, XA_WINDOW, &real_type, &real_format, &items_read, &items_left, &propdata);
   13.99          if (status != Success || !items_read || wm_window != ((Window*)propdata)[0]) {
  13.100              wm_window = None;
  13.101          }
  13.102          if (propdata) {
  13.103 -            XFree(propdata);
  13.104 +            X11_XFree(propdata);
  13.105          }
  13.106      }
  13.107  
  13.108      /* Reset the error handler, we're done checking */
  13.109 -    XSync(display, False);
  13.110 -    XSetErrorHandler(handler);
  13.111 +    X11_XSync(display, False);
  13.112 +    X11_XSetErrorHandler(handler);
  13.113  
  13.114      if (!wm_window) {
  13.115  #ifdef DEBUG_WINDOW_MANAGER
  13.116 @@ -505,12 +505,12 @@
  13.117  #ifdef X_HAVE_UTF8_STRING
  13.118      if (SDL_X11_HAVE_UTF8) {
  13.119          data->im =
  13.120 -            XOpenIM(data->display, NULL, data->classname, data->classname);
  13.121 +            X11_XOpenIM(data->display, NULL, data->classname, data->classname);
  13.122      }
  13.123  #endif
  13.124  
  13.125      /* Look up some useful Atoms */
  13.126 -#define GET_ATOM(X) data->X = XInternAtom(data->display, #X, False)
  13.127 +#define GET_ATOM(X) data->X = X11_XInternAtom(data->display, #X, False)
  13.128      GET_ATOM(WM_PROTOCOLS);
  13.129      GET_ATOM(WM_DELETE_WINDOW);
  13.130      GET_ATOM(_NET_WM_STATE);
  13.131 @@ -568,7 +568,7 @@
  13.132      SDL_free(data->classname);
  13.133  #ifdef X_HAVE_UTF8_STRING
  13.134      if (data->im) {
  13.135 -        XCloseIM(data->im);
  13.136 +        X11_XCloseIM(data->im);
  13.137      }
  13.138  #endif
  13.139  
    14.1 --- a/src/video/x11/SDL_x11window.c	Thu Oct 17 20:49:30 2013 -0700
    14.2 +++ b/src/video/x11/SDL_x11window.c	Fri Oct 18 01:36:41 2013 -0400
    14.3 @@ -61,11 +61,11 @@
    14.4  
    14.5  /*
    14.6  static Bool
    14.7 -XIfEventTimeout(Display *display, XEvent *event_return, Bool (*predicate)(), XPointer arg, int timeoutMS)
    14.8 +X11_XIfEventTimeout(Display *display, XEvent *event_return, Bool (*predicate)(), XPointer arg, int timeoutMS)
    14.9  {
   14.10      Uint32 start = SDL_GetTicks();
   14.11  
   14.12 -    while (!XCheckIfEvent(display, event_return, predicate, arg)) {
   14.13 +    while (!X11_XCheckIfEvent(display, event_return, predicate, arg)) {
   14.14          if ((SDL_GetTicks() - start) >= timeoutMS) {
   14.15              return False;
   14.16          }
   14.17 @@ -88,7 +88,7 @@
   14.18      SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
   14.19      XWindowAttributes attr;
   14.20  
   14.21 -    XGetWindowAttributes(videodata->display, data->xwindow, &attr);
   14.22 +    X11_XGetWindowAttributes(videodata->display, data->xwindow, &attr);
   14.23      if (attr.map_state != IsUnmapped) {
   14.24          return SDL_TRUE;
   14.25      } else {
   14.26 @@ -110,7 +110,7 @@
   14.27      Atom *list;
   14.28      SDL_bool ret = SDL_FALSE;
   14.29  
   14.30 -    if (XGetWindowProperty(display, data->xwindow, _NET_WM_ALLOWED_ACTIONS, 0, 1024, False, XA_ATOM, &type, &form, &len, &remain, (unsigned char **)&list) == Success)
   14.31 +    if (X11_XGetWindowProperty(display, data->xwindow, _NET_WM_ALLOWED_ACTIONS, 0, 1024, False, XA_ATOM, &type, &form, &len, &remain, (unsigned char **)&list) == Success)
   14.32      {
   14.33          for (i=0; i<len; ++i)
   14.34          {
   14.35 @@ -119,7 +119,7 @@
   14.36                  break;
   14.37              }
   14.38          }
   14.39 -        XFree(list);
   14.40 +        X11_XFree(list);
   14.41      }
   14.42      return ret;
   14.43  }
   14.44 @@ -141,7 +141,7 @@
   14.45  
   14.46      /* The window manager sets this property, we shouldn't set it.
   14.47         If we did, this would indicate to the window manager that we don't
   14.48 -       actually want to be mapped during XMapRaised(), which would be bad.
   14.49 +       actually want to be mapped during X11_XMapRaised(), which would be bad.
   14.50       *
   14.51      if (flags & SDL_WINDOW_HIDDEN) {
   14.52          atoms[count++] = _NET_WM_STATE_HIDDEN;
   14.53 @@ -158,10 +158,10 @@
   14.54          atoms[count++] = _NET_WM_STATE_FULLSCREEN;
   14.55      }
   14.56      if (count > 0) {
   14.57 -        XChangeProperty(display, xwindow, _NET_WM_STATE, XA_ATOM, 32,
   14.58 +        X11_XChangeProperty(display, xwindow, _NET_WM_STATE, XA_ATOM, 32,
   14.59                          PropModeReplace, (unsigned char *)atoms, count);
   14.60      } else {
   14.61 -        XDeleteProperty(display, xwindow, _NET_WM_STATE);
   14.62 +        X11_XDeleteProperty(display, xwindow, _NET_WM_STATE);
   14.63      }
   14.64  }
   14.65  
   14.66 @@ -183,7 +183,7 @@
   14.67      long maxLength = 1024;
   14.68      Uint32 flags = 0;
   14.69  
   14.70 -    if (XGetWindowProperty(display, xwindow, _NET_WM_STATE,
   14.71 +    if (X11_XGetWindowProperty(display, xwindow, _NET_WM_STATE,
   14.72                             0l, maxLength, False, XA_ATOM, &actualType,
   14.73                             &actualFormat, &numItems, &bytesAfter,
   14.74                             &propertyValue) == Success) {
   14.75 @@ -209,7 +209,7 @@
   14.76          }  else if (fullscreen == 1) {
   14.77              flags |= SDL_WINDOW_FULLSCREEN;
   14.78          }
   14.79 -        XFree(propertyValue);
   14.80 +        X11_XFree(propertyValue);
   14.81      }
   14.82  
   14.83      /* FIXME, check the size hints for resizable */
   14.84 @@ -237,7 +237,7 @@
   14.85  #ifdef X_HAVE_UTF8_STRING
   14.86      if (SDL_X11_HAVE_UTF8 && videodata->im) {
   14.87          data->ic =
   14.88 -            pXCreateIC(videodata->im, XNClientWindow, w, XNFocusWindow, w,
   14.89 +            X11_XCreateIC(videodata->im, XNClientWindow, w, XNFocusWindow, w,
   14.90                         XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
   14.91                         XNResourceName, videodata->classname, XNResourceClass,
   14.92                         videodata->classname, NULL);
   14.93 @@ -270,7 +270,7 @@
   14.94      {
   14.95          XWindowAttributes attrib;
   14.96  
   14.97 -        XGetWindowAttributes(data->videodata->display, w, &attrib);
   14.98 +        X11_XGetWindowAttributes(data->videodata->display, w, &attrib);
   14.99          window->x = attrib.x;
  14.100          window->y = attrib.y;
  14.101          window->w = attrib.width;
  14.102 @@ -289,7 +289,7 @@
  14.103      {
  14.104          Window FocalWindow;
  14.105          int RevertTo=0;
  14.106 -        XGetInputFocus(data->videodata->display, &FocalWindow, &RevertTo);
  14.107 +        X11_XGetInputFocus(data->videodata->display, &FocalWindow, &RevertTo);
  14.108          if (FocalWindow==w)
  14.109          {
  14.110              window->flags |= SDL_WINDOW_INPUT_FOCUS;
  14.111 @@ -318,7 +318,7 @@
  14.112       *  Gnome is similar: just use the Motif atom.
  14.113       */
  14.114  
  14.115 -    Atom WM_HINTS = XInternAtom(display, "_MOTIF_WM_HINTS", True);
  14.116 +    Atom WM_HINTS = X11_XInternAtom(display, "_MOTIF_WM_HINTS", True);
  14.117      if (WM_HINTS != None) {
  14.118          /* Hints used by Motif compliant window managers */
  14.119          struct
  14.120 @@ -332,11 +332,11 @@
  14.121              (1L << 1), 0, border ? 1 : 0, 0, 0
  14.122          };
  14.123  
  14.124 -        XChangeProperty(display, window, WM_HINTS, WM_HINTS, 32,
  14.125 +        X11_XChangeProperty(display, window, WM_HINTS, WM_HINTS, 32,
  14.126                          PropModeReplace, (unsigned char *) &MWMHints,
  14.127                          sizeof(MWMHints) / 4);
  14.128      } else {  /* set the transient hints instead, if necessary */
  14.129 -        XSetTransientForHint(display, window, RootWindow(display, screen));
  14.130 +        X11_XSetTransientForHint(display, window, RootWindow(display, screen));
  14.131      }
  14.132  }
  14.133  
  14.134 @@ -389,7 +389,7 @@
  14.135          }
  14.136          visual = vinfo->visual;
  14.137          depth = vinfo->depth;
  14.138 -        XFree(vinfo);
  14.139 +        X11_XFree(vinfo);
  14.140      } else
  14.141  #endif
  14.142      {
  14.143 @@ -410,7 +410,7 @@
  14.144          int rshift, gshift, bshift;
  14.145  
  14.146          xattr.colormap =
  14.147 -            XCreateColormap(display, RootWindow(display, screen),
  14.148 +            X11_XCreateColormap(display, RootWindow(display, screen),
  14.149                              visual, AllocAll);
  14.150  
  14.151          /* If we can't create a colormap, then we must die */
  14.152 @@ -471,16 +471,16 @@
  14.153              colorcells[i].flags = DoRed | DoGreen | DoBlue;
  14.154          }
  14.155  
  14.156 -        XStoreColors(display, xattr.colormap, colorcells, ncolors);
  14.157 +        X11_XStoreColors(display, xattr.colormap, colorcells, ncolors);
  14.158  
  14.159          SDL_free(colorcells);
  14.160      } else {
  14.161          xattr.colormap =
  14.162 -            XCreateColormap(display, RootWindow(display, screen),
  14.163 +            X11_XCreateColormap(display, RootWindow(display, screen),
  14.164                              visual, AllocNone);
  14.165      }
  14.166  
  14.167 -    w = XCreateWindow(display, RootWindow(display, screen),
  14.168 +    w = X11_XCreateWindow(display, RootWindow(display, screen),
  14.169                        window->x, window->y, window->w, window->h,
  14.170                        0, depth, InputOutput, visual,
  14.171                        (CWOverrideRedirect | CWBackPixmap | CWBorderPixel |
  14.172 @@ -492,7 +492,7 @@
  14.173      SetWindowBordered(display, screen, w,
  14.174                        (window->flags & SDL_WINDOW_BORDERLESS) == 0);
  14.175  
  14.176 -    sizehints = XAllocSizeHints();
  14.177 +    sizehints = X11_XAllocSizeHints();
  14.178      /* Setup the normal size hints */
  14.179      sizehints->flags = 0;
  14.180      if (!(window->flags & SDL_WINDOW_RESIZABLE)) {
  14.181 @@ -505,25 +505,25 @@
  14.182      sizehints->flags |= USPosition;
  14.183  
  14.184      /* Setup the input hints so we get keyboard input */
  14.185 -    wmhints = XAllocWMHints();
  14.186 +    wmhints = X11_XAllocWMHints();
  14.187      wmhints->input = True;
  14.188      wmhints->flags = InputHint;
  14.189  
  14.190      /* Setup the class hints so we can get an icon (AfterStep) */
  14.191 -    classhints = XAllocClassHint();
  14.192 +    classhints = X11_XAllocClassHint();
  14.193      classhints->res_name = data->classname;
  14.194      classhints->res_class = data->classname;
  14.195  
  14.196      /* Set the size, input and class hints, and define WM_CLIENT_MACHINE and WM_LOCALE_NAME */
  14.197 -    XSetWMProperties(display, w, NULL, NULL, NULL, 0, sizehints, wmhints, classhints);
  14.198 +    X11_XSetWMProperties(display, w, NULL, NULL, NULL, 0, sizehints, wmhints, classhints);
  14.199  
  14.200 -    XFree(sizehints);
  14.201 -    XFree(wmhints);
  14.202 -    XFree(classhints);
  14.203 +    X11_XFree(sizehints);
  14.204 +    X11_XFree(wmhints);
  14.205 +    X11_XFree(classhints);
  14.206      /* Set the PID related to the window for the given hostname, if possible */
  14.207      if (data->pid > 0) {
  14.208 -        _NET_WM_PID = XInternAtom(display, "_NET_WM_PID", False);
  14.209 -        XChangeProperty(display, w, _NET_WM_PID, XA_CARDINAL, 32, PropModeReplace,
  14.210 +        _NET_WM_PID = X11_XInternAtom(display, "_NET_WM_PID", False);
  14.211 +        X11_XChangeProperty(display, w, _NET_WM_PID, XA_CARDINAL, 32, PropModeReplace,
  14.212                          (unsigned char *)&data->pid, 1);
  14.213      }
  14.214  
  14.215 @@ -531,14 +531,14 @@
  14.216      X11_SetNetWMState(_this, w, window->flags);
  14.217  
  14.218      /* Let the window manager know we're a "normal" window */
  14.219 -    _NET_WM_WINDOW_TYPE = XInternAtom(display, "_NET_WM_WINDOW_TYPE", False);
  14.220 -    _NET_WM_WINDOW_TYPE_NORMAL = XInternAtom(display, "_NET_WM_WINDOW_TYPE_NORMAL", False);
  14.221 -    XChangeProperty(display, w, _NET_WM_WINDOW_TYPE, XA_ATOM, 32,
  14.222 +    _NET_WM_WINDOW_TYPE = X11_XInternAtom(display, "_NET_WM_WINDOW_TYPE", False);
  14.223 +    _NET_WM_WINDOW_TYPE_NORMAL = X11_XInternAtom(display, "_NET_WM_WINDOW_TYPE_NORMAL", False);
  14.224 +    X11_XChangeProperty(display, w, _NET_WM_WINDOW_TYPE, XA_ATOM, 32,
  14.225                      PropModeReplace,
  14.226                      (unsigned char *)&_NET_WM_WINDOW_TYPE_NORMAL, 1);
  14.227  
  14.228 -    _NET_WM_BYPASS_COMPOSITOR = XInternAtom(display, "_NET_WM_BYPASS_COMPOSITOR", False);
  14.229 -    XChangeProperty(display, w, _NET_WM_BYPASS_COMPOSITOR, XA_CARDINAL, 32,
  14.230 +    _NET_WM_BYPASS_COMPOSITOR = X11_XInternAtom(display, "_NET_WM_BYPASS_COMPOSITOR", False);
  14.231 +    X11_XChangeProperty(display, w, _NET_WM_BYPASS_COMPOSITOR, XA_CARDINAL, 32,
  14.232                      PropModeReplace,
  14.233                      (unsigned char *)&_NET_WM_BYPASS_COMPOSITOR_HINT_ON, 1);
  14.234  
  14.235 @@ -547,11 +547,11 @@
  14.236              data->WM_DELETE_WINDOW, /* Allow window to be deleted by the WM */
  14.237              data->_NET_WM_PING, /* Respond so WM knows we're alive */
  14.238          };
  14.239 -        XSetWMProtocols(display, w, protocols, sizeof (protocols) / sizeof (protocols[0]));
  14.240 +        X11_XSetWMProtocols(display, w, protocols, sizeof (protocols) / sizeof (protocols[0]));
  14.241      }
  14.242  
  14.243      if (SetupWindowData(_this, window, w, SDL_TRUE) < 0) {
  14.244 -        XDestroyWindow(display, w);
  14.245 +        X11_XDestroyWindow(display, w);
  14.246          return -1;
  14.247      }
  14.248      windowdata = (SDL_WindowData *) window->driverdata;
  14.249 @@ -564,7 +564,7 @@
  14.250  #endif  
  14.251      ) {
  14.252          if (!_this->egl_data) {
  14.253 -            XDestroyWindow(display, w);
  14.254 +            X11_XDestroyWindow(display, w);
  14.255              return -1;
  14.256          }
  14.257  
  14.258 @@ -572,7 +572,7 @@
  14.259          windowdata->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType) w);
  14.260  
  14.261          if (windowdata->egl_surface == EGL_NO_SURFACE) {
  14.262 -            XDestroyWindow(display, w);
  14.263 +            X11_XDestroyWindow(display, w);
  14.264              return SDL_SetError("Could not create GLES window surface");
  14.265          }
  14.266      }
  14.267 @@ -581,25 +581,25 @@
  14.268  
  14.269  #ifdef X_HAVE_UTF8_STRING
  14.270      if (SDL_X11_HAVE_UTF8 && windowdata->ic) {
  14.271 -        pXGetICValues(windowdata->ic, XNFilterEvents, &fevent, NULL);
  14.272 +        X11_XGetICValues(windowdata->ic, XNFilterEvents, &fevent, NULL);
  14.273      }
  14.274  #endif
  14.275  
  14.276      X11_Xinput2SelectTouch(_this, window);
  14.277  
  14.278 -    XSelectInput(display, w,
  14.279 +    X11_XSelectInput(display, w,
  14.280                   (FocusChangeMask | EnterWindowMask | LeaveWindowMask |
  14.281                   ExposureMask | ButtonPressMask | ButtonReleaseMask |
  14.282                   PointerMotionMask | KeyPressMask | KeyReleaseMask |
  14.283                   PropertyChangeMask | StructureNotifyMask |
  14.284                   KeymapStateMask | fevent));
  14.285  
  14.286 -    XdndAware = XInternAtom(display, "XdndAware", False);
  14.287 -    XChangeProperty(display, w, XdndAware, XA_ATOM, 32,
  14.288 +    XdndAware = X11_XInternAtom(display, "XdndAware", False);
  14.289 +    X11_XChangeProperty(display, w, XdndAware, XA_ATOM, 32,
  14.290                   PropModeReplace,
  14.291                   (unsigned char*)&xdnd_version, 1);
  14.292  
  14.293 -    XFlush(display);
  14.294 +    X11_XFlush(display);
  14.295  
  14.296      return 0;
  14.297  }
  14.298 @@ -628,14 +628,14 @@
  14.299      unsigned char *propdata;
  14.300      char *title = NULL;
  14.301  
  14.302 -    status = XGetWindowProperty(display, xwindow, data->_NET_WM_NAME,
  14.303 +    status = X11_XGetWindowProperty(display, xwindow, data->_NET_WM_NAME,
  14.304                  0L, 8192L, False, data->UTF8_STRING, &real_type, &real_format,
  14.305                  &items_read, &items_left, &propdata);
  14.306      if (status == Success && propdata) {
  14.307          title = SDL_strdup(SDL_static_cast(char*, propdata));
  14.308 -        XFree(propdata);
  14.309 +        X11_XFree(propdata);
  14.310      } else {
  14.311 -        status = XGetWindowProperty(display, xwindow, XA_WM_NAME,
  14.312 +        status = X11_XGetWindowProperty(display, xwindow, XA_WM_NAME,
  14.313                      0L, 8192L, False, XA_STRING, &real_type, &real_format,
  14.314                      &items_read, &items_left, &propdata);
  14.315          if (status == Success && propdata) {
  14.316 @@ -668,21 +668,21 @@
  14.317              SDL_OutOfMemory();
  14.318              return;
  14.319          }
  14.320 -        status = XStringListToTextProperty(&title_locale, 1, &titleprop);
  14.321 +        status = X11_XStringListToTextProperty(&title_locale, 1, &titleprop);
  14.322          SDL_free(title_locale);
  14.323          if (status) {
  14.324 -            XSetTextProperty(display, data->xwindow, &titleprop, XA_WM_NAME);
  14.325 -            XFree(titleprop.value);
  14.326 +            X11_XSetTextProperty(display, data->xwindow, &titleprop, XA_WM_NAME);
  14.327 +            X11_XFree(titleprop.value);
  14.328          }
  14.329  #ifdef X_HAVE_UTF8_STRING
  14.330          if (SDL_X11_HAVE_UTF8) {
  14.331              status =
  14.332 -                Xutf8TextListToTextProperty(display, (char **) &title, 1,
  14.333 +                X11_Xutf8TextListToTextProperty(display, (char **) &title, 1,
  14.334                                              XUTF8StringStyle, &titleprop);
  14.335              if (status == Success) {
  14.336 -                XSetTextProperty(display, data->xwindow, &titleprop,
  14.337 +                X11_XSetTextProperty(display, data->xwindow, &titleprop,
  14.338                                   _NET_WM_NAME);
  14.339 -                XFree(titleprop.value);
  14.340 +                X11_XFree(titleprop.value);
  14.341              }
  14.342          }
  14.343  #endif
  14.344 @@ -693,27 +693,27 @@
  14.345              SDL_OutOfMemory();
  14.346              return;
  14.347          }
  14.348 -        status = XStringListToTextProperty(&icon_locale, 1, &iconprop);
  14.349 +        status = X11_XStringListToTextProperty(&icon_locale, 1, &iconprop);
  14.350          SDL_free(icon_locale);
  14.351          if (status) {
  14.352 -            XSetTextProperty(display, data->xwindow, &iconprop,
  14.353 +            X11_XSetTextProperty(display, data->xwindow, &iconprop,
  14.354                               XA_WM_ICON_NAME);
  14.355 -            XFree(iconprop.value);
  14.356 +            X11_XFree(iconprop.value);
  14.357          }
  14.358  #ifdef X_HAVE_UTF8_STRING
  14.359          if (SDL_X11_HAVE_UTF8) {
  14.360              status =
  14.361 -                Xutf8TextListToTextProperty(display, (char **) &icon, 1,
  14.362 +                X11_Xutf8TextListToTextProperty(display, (char **) &icon, 1,
  14.363                                              XUTF8StringStyle, &iconprop);
  14.364              if (status == Success) {
  14.365 -                XSetTextProperty(display, data->xwindow, &iconprop,
  14.366 +                X11_XSetTextProperty(display, data->xwindow, &iconprop,
  14.367                                   _NET_WM_ICON_NAME);
  14.368 -                XFree(iconprop.value);
  14.369 +                X11_XFree(iconprop.value);
  14.370              }
  14.371          }
  14.372  #endif
  14.373      }
  14.374 -    XFlush(display);
  14.375 +    X11_XFlush(display);
  14.376  }
  14.377  
  14.378  void
  14.379 @@ -745,15 +745,15 @@
  14.380                      *dst++ = *src++;
  14.381                  }
  14.382              }
  14.383 -            XChangeProperty(display, data->xwindow, _NET_WM_ICON, XA_CARDINAL,
  14.384 +            X11_XChangeProperty(display, data->xwindow, _NET_WM_ICON, XA_CARDINAL,
  14.385                              32, PropModeReplace, (unsigned char *) propdata,
  14.386                              propsize);
  14.387          }
  14.388          SDL_free(propdata);
  14.389      } else {
  14.390 -        XDeleteProperty(display, data->xwindow, _NET_WM_ICON);
  14.391 +        X11_XDeleteProperty(display, data->xwindow, _NET_WM_ICON);
  14.392      }
  14.393 -    XFlush(display);
  14.394 +    X11_XFlush(display);
  14.395  }
  14.396  
  14.397  void
  14.398 @@ -762,8 +762,8 @@
  14.399      SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
  14.400      Display *display = data->videodata->display;
  14.401  
  14.402 -    XMoveWindow(display, data->xwindow, window->x, window->y);
  14.403 -    XFlush(display);
  14.404 +    X11_XMoveWindow(display, data->xwindow, window->x, window->y);
  14.405 +    X11_XFlush(display);
  14.406  }
  14.407  
  14.408  void
  14.409 @@ -773,26 +773,26 @@
  14.410      Display *display = data->videodata->display;
  14.411  
  14.412      if (window->flags & SDL_WINDOW_RESIZABLE) {
  14.413 -         XSizeHints *sizehints = XAllocSizeHints();
  14.414 +         XSizeHints *sizehints = X11_XAllocSizeHints();
  14.415           long userhints;
  14.416  
  14.417 -         XGetWMNormalHints(display, data->xwindow, sizehints, &userhints);
  14.418 +         X11_XGetWMNormalHints(display, data->xwindow, sizehints, &userhints);
  14.419  
  14.420           sizehints->min_width = window->min_w;
  14.421           sizehints->min_height = window->min_h;
  14.422           sizehints->flags |= PMinSize;
  14.423  
  14.424 -         XSetWMNormalHints(display, data->xwindow, sizehints);
  14.425 +         X11_XSetWMNormalHints(display, data->xwindow, sizehints);
  14.426  
  14.427 -         XFree(sizehints);
  14.428 +         X11_XFree(sizehints);
  14.429  
  14.430          /* See comment in X11_SetWindowSize. */
  14.431 -        XResizeWindow(display, data->xwindow, window->w, window->h);
  14.432 -        XMoveWindow(display, data->xwindow, window->x, window->y);
  14.433 -        XRaiseWindow(display, data->xwindow);
  14.434 +        X11_XResizeWindow(display, data->xwindow, window->w, window->h);
  14.435 +        X11_XMoveWindow(display, data->xwindow, window->x, window->y);
  14.436 +        X11_XRaiseWindow(display, data->xwindow);
  14.437      }
  14.438  
  14.439 -    XFlush(display);
  14.440 +    X11_XFlush(display);
  14.441  }
  14.442  
  14.443  void
  14.444 @@ -802,26 +802,26 @@
  14.445      Display *display = data->videodata->display;
  14.446  
  14.447      if (window->flags & SDL_WINDOW_RESIZABLE) {
  14.448 -         XSizeHints *sizehints = XAllocSizeHints();
  14.449 +         XSizeHints *sizehints = X11_XAllocSizeHints();
  14.450           long userhints;
  14.451  
  14.452 -         XGetWMNormalHints(display, data->xwindow, sizehints, &userhints);
  14.453 +         X11_XGetWMNormalHints(display, data->xwindow, sizehints, &userhints);
  14.454  
  14.455           sizehints->max_width = window->max_w;
  14.456           sizehints->max_height = window->max_h;
  14.457           sizehints->flags |= PMaxSize;
  14.458  
  14.459 -         XSetWMNormalHints(display, data->xwindow, sizehints);
  14.460 +         X11_XSetWMNormalHints(display, data->xwindow, sizehints);
  14.461  
  14.462 -         XFree(sizehints);
  14.463 +         X11_XFree(sizehints);
  14.464  
  14.465          /* See comment in X11_SetWindowSize. */
  14.466 -        XResizeWindow(display, data->xwindow, window->w, window->h);
  14.467 -        XMoveWindow(display, data->xwindow, window->x, window->y);
  14.468 -        XRaiseWindow(display, data->xwindow);
  14.469 +        X11_XResizeWindow(display, data->xwindow, window->w, window->h);
  14.470 +        X11_XMoveWindow(display, data->xwindow, window->x, window->y);
  14.471 +        X11_XRaiseWindow(display, data->xwindow);
  14.472      }
  14.473  
  14.474 -    XFlush(display);
  14.475 +    X11_XFlush(display);
  14.476  }
  14.477  
  14.478  void
  14.479 @@ -834,20 +834,20 @@
  14.480          X11_ResizeWindowShape(window);
  14.481      }
  14.482      if (!(window->flags & SDL_WINDOW_RESIZABLE)) {
  14.483 -         /* Apparently, if the X11 Window is set to a 'non-resizable' window, you cannot resize it using the XResizeWindow, thus
  14.484 +         /* Apparently, if the X11 Window is set to a 'non-resizable' window, you cannot resize it using the X11_XResizeWindow, thus
  14.485              we must set the size hints to adjust the window size. */
  14.486 -         XSizeHints *sizehints = XAllocSizeHints();
  14.487 +         XSizeHints *sizehints = X11_XAllocSizeHints();
  14.488           long userhints;
  14.489  
  14.490 -         XGetWMNormalHints(display, data->xwindow, sizehints, &userhints);
  14.491 +         X11_XGetWMNormalHints(display, data->xwindow, sizehints, &userhints);
  14.492  
  14.493           sizehints->min_width = sizehints->max_width = window->w;
  14.494           sizehints->min_height = sizehints->max_height = window->h;
  14.495           sizehints->flags |= PMinSize | PMaxSize;
  14.496  
  14.497 -         XSetWMNormalHints(display, data->xwindow, sizehints);
  14.498 +         X11_XSetWMNormalHints(display, data->xwindow, sizehints);
  14.499  
  14.500 -         XFree(sizehints);
  14.501 +         X11_XFree(sizehints);
  14.502  
  14.503          /* From Pierre-Loup:
  14.504             WMs each have their little quirks with that.  When you change the
  14.505 @@ -865,14 +865,14 @@
  14.506             hide/show, because there are supposedly subtle problems with doing so
  14.507             and transitioning from windowed to fullscreen in Unity.
  14.508           */
  14.509 -        XResizeWindow(display, data->xwindow, window->w, window->h);
  14.510 -        XMoveWindow(display, data->xwindow, window->x, window->y);
  14.511 -        XRaiseWindow(display, data->xwindow);
  14.512 +        X11_XResizeWindow(display, data->xwindow, window->w, window->h);
  14.513 +        X11_XMoveWindow(display, data->xwindow, window->x, window->y);
  14.514 +        X11_XRaiseWindow(display, data->xwindow);
  14.515      } else {
  14.516 -        XResizeWindow(display, data->xwindow, window->w, window->h);
  14.517 +        X11_XResizeWindow(display, data->xwindow, window->w, window->h);
  14.518      }
  14.519  
  14.520 -    XFlush(display);
  14.521 +    X11_XFlush(display);
  14.522  }
  14.523  
  14.524  void
  14.525 @@ -887,25 +887,25 @@
  14.526      XEvent event;
  14.527  
  14.528      SetWindowBordered(display, displaydata->screen, data->xwindow, bordered);
  14.529 -    XFlush(display);
  14.530 -    XIfEvent(display, &event, &isConfigureNotify, (XPointer)&data->xwindow);
  14.531 +    X11_XFlush(display);
  14.532 +    X11_XIfEvent(display, &event, &isConfigureNotify, (XPointer)&data->xwindow);
  14.533  
  14.534      if (visible) {
  14.535          XWindowAttributes attr;
  14.536          do {
  14.537 -            XSync(display, False);
  14.538 -            XGetWindowAttributes(display, data->xwindow, &attr);
  14.539 +            X11_XSync(display, False);
  14.540 +            X11_XGetWindowAttributes(display, data->xwindow, &attr);
  14.541          } while (attr.map_state != IsViewable);
  14.542  
  14.543          if (focused) {
  14.544 -            XSetInputFocus(display, data->xwindow, RevertToParent, CurrentTime);
  14.545 +            X11_XSetInputFocus(display, data->xwindow, RevertToParent, CurrentTime);
  14.546          }
  14.547      }
  14.548  
  14.549      /* make sure these don't make it to the real event queue if they fired here. */
  14.550 -    XSync(display, False);
  14.551 -    XCheckIfEvent(display, &event, &isUnmapNotify, (XPointer)&data->xwindow);
  14.552 -    XCheckIfEvent(display, &event, &isMapNotify, (XPointer)&data->xwindow);
  14.553 +    X11_XSync(display, False);
  14.554 +    X11_XCheckIfEvent(display, &event, &isUnmapNotify, (XPointer)&data->xwindow);
  14.555 +    X11_XCheckIfEvent(display, &event, &isMapNotify, (XPointer)&data->xwindow);
  14.556  }
  14.557  
  14.558  void
  14.559 @@ -916,12 +916,12 @@
  14.560      XEvent event;
  14.561  
  14.562      if (!X11_IsWindowMapped(_this, window)) {
  14.563 -        XMapRaised(display, data->xwindow);
  14.564 +        X11_XMapRaised(display, data->xwindow);
  14.565          /* Blocking wait for "MapNotify" event.
  14.566 -         * We use XIfEvent because XWindowEvent takes a mask rather than a type,
  14.567 +         * We use X11_XIfEvent because pXWindowEvent takes a mask rather than a type,
  14.568           * and XCheckTypedWindowEvent doesn't block */
  14.569 -        XIfEvent(display, &event, &isMapNotify, (XPointer)&data->xwindow);
  14.570 -        XFlush(display);
  14.571 +        X11_XIfEvent(display, &event, &isMapNotify, (XPointer)&data->xwindow);
  14.572 +        X11_XFlush(display);
  14.573      }
  14.574  }
  14.575  
  14.576 @@ -934,10 +934,10 @@
  14.577      XEvent event;
  14.578  
  14.579      if (X11_IsWindowMapped(_this, window)) {
  14.580 -        XWithdrawWindow(display, data->xwindow, displaydata->screen);
  14.581 +        X11_XWithdrawWindow(display, data->xwindow, displaydata->screen);
  14.582          /* Blocking wait for "UnmapNotify" event */
  14.583 -        XIfEvent(display, &event, &isUnmapNotify, (XPointer)&data->xwindow);
  14.584 -        XFlush(display);
  14.585 +        X11_XIfEvent(display, &event, &isUnmapNotify, (XPointer)&data->xwindow);
  14.586 +        X11_XFlush(display);
  14.587      }
  14.588  }
  14.589  
  14.590 @@ -962,10 +962,10 @@
  14.591          e.xclient.data.l[1] = CurrentTime;
  14.592          e.xclient.data.l[2] = 0;
  14.593  
  14.594 -        XSendEvent(display, RootWindow(display, displaydata->screen), 0,
  14.595 +        X11_XSendEvent(display, RootWindow(display, displaydata->screen), 0,
  14.596                     SubstructureNotifyMask | SubstructureRedirectMask, &e);
  14.597  
  14.598 -        XFlush(display);
  14.599 +        X11_XFlush(display);
  14.600      }
  14.601  }
  14.602  
  14.603 @@ -975,9 +975,9 @@
  14.604      SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
  14.605      Display *display = data->videodata->display;
  14.606  
  14.607 -    XRaiseWindow(display, data->xwindow);
  14.608 +    X11_XRaiseWindow(display, data->xwindow);
  14.609      SetWindowActive(_this, window);
  14.610 -    XFlush(display);
  14.611 +    X11_XFlush(display);
  14.612  }
  14.613  
  14.614  static void
  14.615 @@ -1011,12 +1011,12 @@
  14.616          e.xclient.data.l[2] = _NET_WM_STATE_MAXIMIZED_HORZ;
  14.617          e.xclient.data.l[3] = 0l;
  14.618  
  14.619 -        XSendEvent(display, RootWindow(display, displaydata->screen), 0,
  14.620 +        X11_XSendEvent(display, RootWindow(display, displaydata->screen), 0,
  14.621                     SubstructureNotifyMask | SubstructureRedirectMask, &e);
  14.622      } else {
  14.623          X11_SetNetWMState(_this, data->xwindow, window->flags);
  14.624      }
  14.625 -    XFlush(display);
  14.626 +    X11_XFlush(display);
  14.627  }
  14.628  
  14.629  void
  14.630 @@ -1033,8 +1033,8 @@
  14.631          (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata;
  14.632      Display *display = data->videodata->display;
  14.633  
  14.634 -    XIconifyWindow(display, data->xwindow, displaydata->screen);
  14.635 -    XFlush(display);
  14.636 +    X11_XIconifyWindow(display, data->xwindow, displaydata->screen);
  14.637 +    X11_XFlush(display);
  14.638  }
  14.639  
  14.640  void
  14.641 @@ -1061,9 +1061,9 @@
  14.642          if (!(window->flags & SDL_WINDOW_RESIZABLE)) {
  14.643              /* Compiz refuses fullscreen toggle if we're not resizable, so update the hints so we
  14.644                 can be resized to the fullscreen resolution (or reset so we're not resizable again) */
  14.645 -            XSizeHints *sizehints = XAllocSizeHints();
  14.646 +            XSizeHints *sizehints = X11_XAllocSizeHints();
  14.647              long flags = 0;
  14.648 -            XGetWMNormalHints(display, data->xwindow, sizehints, &flags);
  14.649 +            X11_XGetWMNormalHints(display, data->xwindow, sizehints, &flags);
  14.650              /* set the resize flags on */
  14.651              if (fullscreen) {
  14.652                  /* we are going fullscreen so turn the flags off */
  14.653 @@ -1074,8 +1074,8 @@
  14.654                  sizehints->min_width = sizehints->max_width = window->windowed.w;
  14.655                  sizehints->min_height = sizehints->max_height = window->windowed.h;
  14.656              }
  14.657 -            XSetWMNormalHints(display, data->xwindow, sizehints);
  14.658 -            XFree(sizehints);
  14.659 +            X11_XSetWMNormalHints(display, data->xwindow, sizehints);
  14.660 +            X11_XFree(sizehints);
  14.661          }
  14.662  
  14.663          SDL_zero(e);
  14.664 @@ -1088,7 +1088,7 @@
  14.665          e.xclient.data.l[1] = _NET_WM_STATE_FULLSCREEN;
  14.666          e.xclient.data.l[3] = 0l;
  14.667  
  14.668 -        XSendEvent(display, RootWindow(display, displaydata->screen), 0,
  14.669 +        X11_XSendEvent(display, RootWindow(display, displaydata->screen), 0,
  14.670                     SubstructureNotifyMask | SubstructureRedirectMask, &e);
  14.671      } else {
  14.672          Uint32 flags;
  14.673 @@ -1104,13 +1104,13 @@
  14.674  
  14.675      if (data->visual->class == DirectColor) {
  14.676          if ( fullscreen ) {
  14.677 -            XInstallColormap(display, data->colormap);
  14.678 +            X11_XInstallColormap(display, data->colormap);
  14.679          } else {
  14.680 -            XUninstallColormap(display, data->colormap);
  14.681 +            X11_XUninstallColormap(display, data->colormap);
  14.682          }
  14.683      }
  14.684  
  14.685 -    XFlush(display);
  14.686 +    X11_XFlush(display);
  14.687  }
  14.688  
  14.689  /* This handles fullscreen itself, outside the Window Manager. */
  14.690 @@ -1145,48 +1145,48 @@
  14.691      xattr.colormap = data->colormap;
  14.692      xattrmask |= CWColormap;
  14.693  
  14.694 -    data->fswindow = XCreateWindow(display, root,
  14.695 +    data->fswindow = X11_XCreateWindow(display, root,
  14.696                                     rect.x, rect.y, rect.w, rect.h, 0,
  14.697                                     displaydata->depth, InputOutput,
  14.698                                     visual, xattrmask, &xattr);
  14.699  
  14.700 -    XSelectInput(display, data->fswindow, StructureNotifyMask);
  14.701 -    XSetWindowBackground(display, data->fswindow, 0);
  14.702 -    XInstallColormap(display, data->colormap);
  14.703 -    XClearWindow(display, data->fswindow);
  14.704 -    XMapRaised(display, data->fswindow);
  14.705 +    X11_XSelectInput(display, data->fswindow, StructureNotifyMask);
  14.706 +    X11_XSetWindowBackground(display, data->fswindow, 0);
  14.707 +    X11_XInstallColormap(display, data->colormap);
  14.708 +    X11_XClearWindow(display, data->fswindow);
  14.709 +    X11_XMapRaised(display, data->fswindow);
  14.710  
  14.711      /* Make sure the fswindow is in view by warping mouse to the corner */
  14.712 -    XUngrabPointer(display, CurrentTime);
  14.713 -    XWarpPointer(display, None, root, 0, 0, 0, 0, rect.x, rect.y);
  14.714 +    X11_XUngrabPointer(display, CurrentTime);
  14.715 +    X11_XWarpPointer(display, None, root, 0, 0, 0, 0, rect.x, rect.y);
  14.716  
  14.717      /* Wait to be mapped, filter Unmap event out if it arrives. */
  14.718 -    XIfEvent(display, &ev, &isMapNotify, (XPointer)&data->fswindow);
  14.719 -    XCheckIfEvent(display, &ev, &isUnmapNotify, (XPointer)&data->fswindow);
  14.720 +    X11_XIfEvent(display, &ev, &isMapNotify, (XPointer)&data->fswindow);
  14.721 +    X11_XCheckIfEvent(display, &ev, &isUnmapNotify, (XPointer)&data->fswindow);
  14.722  
  14.723  #if SDL_VIDEO_DRIVER_X11_XVIDMODE
  14.724      if ( displaydata->use_vidmode ) {
  14.725 -        XF86VidModeLockModeSwitch(display, screen, True);
  14.726 +        X11_XF86VidModeLockModeSwitch(display, screen, True);
  14.727      }
  14.728  #endif
  14.729  
  14.730      SetWindowBordered(display, displaydata->screen, data->xwindow, SDL_FALSE);
  14.731  
  14.732      /* Center actual window within our cover-the-screen window. */
  14.733 -    XReparentWindow(display, data->xwindow, data->fswindow,
  14.734 +    X11_XReparentWindow(display, data->xwindow, data->fswindow,
  14.735                      (rect.w - window->w) / 2, (rect.h - window->h) / 2);
  14.736  
  14.737      /* Move the mouse to the upper left to make sure it's on-screen */
  14.738 -    XWarpPointer(display, None, root, 0, 0, 0, 0, rect.x, rect.y);
  14.739 +    X11_XWarpPointer(display, None, root, 0, 0, 0, 0, rect.x, rect.y);
  14.740  
  14.741      /* Center mouse in the fullscreen window. */
  14.742      rect.x += (rect.w / 2);
  14.743      rect.y += (rect.h / 2);
  14.744 -    XWarpPointer(display, None, root, 0, 0, 0, 0, rect.x, rect.y);
  14.745 +    X11_XWarpPointer(display, None, root, 0, 0, 0, 0, rect.x, rect.y);
  14.746  
  14.747      /* Wait to be mapped, filter Unmap event out if it arrives. */
  14.748 -    XIfEvent(display, &ev, &isMapNotify, (XPointer)&data->xwindow);
  14.749 -    XCheckIfEvent(display, &ev, &isUnmapNotify, (XPointer)&data->xwindow);
  14.750 +    X11_XIfEvent(display, &ev, &isMapNotify, (XPointer)&data->xwindow);
  14.751 +    X11_XCheckIfEvent(display, &ev, &isUnmapNotify, (XPointer)&data->xwindow);
  14.752  
  14.753      SDL_UpdateWindowGrab(window);
  14.754  }
  14.755 @@ -1210,27 +1210,27 @@
  14.756  
  14.757  #if SDL_VIDEO_DRIVER_X11_VIDMODE
  14.758      if ( displaydata->use_vidmode ) {
  14.759 -        XF86VidModeLockModeSwitch(display, screen, False);
  14.760 +        X11_XF86VidModeLockModeSwitch(display, screen, False);
  14.761      }
  14.762  #endif
  14.763  
  14.764      SDL_UpdateWindowGrab(window);
  14.765  
  14.766 -    XReparentWindow(display, data->xwindow, root, window->x, window->y);
  14.767 +    X11_XReparentWindow(display, data->xwindow, root, window->x, window->y);
  14.768  
  14.769      /* flush these events so they don't confuse normal event handling */
  14.770 -    XSync(display, False);
  14.771 -    XCheckIfEvent(display, &ev, &isMapNotify, (XPointer)&data->xwindow);
  14.772 -    XCheckIfEvent(display, &ev, &isUnmapNotify, (XPointer)&data->xwindow);
  14.773 +    X11_XSync(display, False);
  14.774 +    X11_XCheckIfEvent(display, &ev, &isMapNotify, (XPointer)&data->xwindow);
  14.775 +    X11_XCheckIfEvent(display, &ev, &isUnmapNotify, (XPointer)&data->xwindow);
  14.776  
  14.777      SetWindowBordered(display, screen, data->xwindow,
  14.778                        (window->flags & SDL_WINDOW_BORDERLESS) == 0);
  14.779  
  14.780 -    XWithdrawWindow(display, fswindow, screen);
  14.781 +    X11_XWithdrawWindow(display, fswindow, screen);
  14.782  
  14.783      /* Wait to be unmapped. */
  14.784 -    XIfEvent(display, &ev, &isUnmapNotify, (XPointer)&fswindow);
  14.785 -    XDestroyWindow(display, fswindow);
  14.786 +    X11_XIfEvent(display, &ev, &isUnmapNotify, (XPointer)&fswindow);
  14.787 +    X11_XDestroyWindow(display, fswindow);
  14.788  }
  14.789  
  14.790  
  14.791 @@ -1328,8 +1328,8 @@
  14.792          colorcells[i].flags = DoRed | DoGreen | DoBlue;
  14.793      }
  14.794  
  14.795 -    XStoreColors(display, colormap, colorcells, ncolors);
  14.796 -    XFlush(display);
  14.797 +    X11_XStoreColors(display, colormap, colorcells, ncolors);
  14.798 +    X11_XFlush(display);
  14.799      SDL_free(colorcells);
  14.800  
  14.801      return 0;
  14.802 @@ -1354,7 +1354,7 @@
  14.803          /* Try to grab the mouse */
  14.804          for (;;) {
  14.805              int result =
  14.806 -                XGrabPointer(display, data->xwindow, True, 0, GrabModeAsync,
  14.807 +                X11_XGrabPointer(display, data->xwindow, True, 0, GrabModeAsync,
  14.808                               GrabModeAsync, data->xwindow, None, CurrentTime);
  14.809              if (result == GrabSuccess) {
  14.810                  break;
  14.811 @@ -1363,7 +1363,7 @@
  14.812          }
  14.813  
  14.814          /* Raise the window if we grab the mouse */
  14.815 -        XRaiseWindow(display, data->xwindow);
  14.816 +        X11_XRaiseWindow(display, data->xwindow);
  14.817  
  14.818          /* Now grab the keyboard */
  14.819          hint = SDL_GetHint(SDL_HINT_GRAB_KEYBOARD);
  14.820 @@ -1376,14 +1376,14 @@
  14.821              grab_keyboard = oldstyle_fullscreen;
  14.822          }
  14.823          if (grab_keyboard) {
  14.824 -            XGrabKeyboard(display, data->xwindow, True, GrabModeAsync,
  14.825 +            X11_XGrabKeyboard(display, data->xwindow, True, GrabModeAsync,
  14.826                            GrabModeAsync, CurrentTime);
  14.827          }
  14.828      } else {
  14.829 -        XUngrabPointer(display, CurrentTime);
  14.830 -        XUngrabKeyboard(display, CurrentTime);
  14.831 +        X11_XUngrabPointer(display, CurrentTime);
  14.832 +        X11_XUngrabKeyboard(display, CurrentTime);
  14.833      }
  14.834 -    XSync(display, False);
  14.835 +    X11_XSync(display, False);
  14.836  }
  14.837  
  14.838  void
  14.839 @@ -1411,12 +1411,12 @@
  14.840          }
  14.841  #ifdef X_HAVE_UTF8_STRING
  14.842          if (data->ic) {
  14.843 -            XDestroyIC(data->ic);
  14.844 +            X11_XDestroyIC(data->ic);
  14.845          }
  14.846  #endif
  14.847          if (data->created) {
  14.848 -            XDestroyWindow(display, data->xwindow);
  14.849 -            XFlush(display);
  14.850 +            X11_XDestroyWindow(display, data->xwindow);
  14.851 +            X11_XFlush(display);
  14.852          }
  14.853          SDL_free(data);
  14.854      }
    15.1 --- a/src/video/x11/SDL_x11xinput2.c	Thu Oct 17 20:49:30 2013 -0700
    15.2 +++ b/src/video/x11/SDL_x11xinput2.c	Fri Oct 18 01:36:41 2013 -0400
    15.3 @@ -36,7 +36,7 @@
    15.4  static int xinput2_multitouch_supported = 0;
    15.5  #endif
    15.6  
    15.7 -/* Opcode returned XQueryExtension
    15.8 +/* Opcode returned X11_XQueryExtension
    15.9   * It will be used in event processing
   15.10   * to know that the event came from
   15.11   * this extension */
   15.12 @@ -82,16 +82,16 @@
   15.13      * "As XI2 progresses it becomes important that you use this call as the server may treat the client
   15.14      * differently depending on the supported version".
   15.15      *
   15.16 -    * FIXME:event and err are not needed but if not passed XQueryExtension returns SegmentationFault
   15.17 +    * FIXME:event and err are not needed but if not passed X11_XQueryExtension returns SegmentationFault
   15.18      */
   15.19      if (!SDL_X11_HAVE_XINPUT2 ||
   15.20 -        !XQueryExtension(data->display, "XInputExtension", &xinput2_opcode, &event, &err)) {
   15.21 +        !X11_XQueryExtension(data->display, "XInputExtension", &xinput2_opcode, &event, &err)) {
   15.22          return;
   15.23      }
   15.24  
   15.25      outmajor = major;
   15.26      outminor = minor;
   15.27 -    if (XIQueryVersion(data->display, &outmajor, &outminor) != Success) {
   15.28 +    if (X11_XIQueryVersion(data->display, &outmajor, &outminor) != Success) {
   15.29          return;
   15.30      }
   15.31  
   15.32 @@ -115,7 +115,7 @@
   15.33  
   15.34      XISetMask(mask, XI_RawMotion);
   15.35  
   15.36 -    if (XISelectEvents(data->display,DefaultRootWindow(data->display),&eventmask,1) != Success) {
   15.37 +    if (X11_XISelectEvents(data->display,DefaultRootWindow(data->display),&eventmask,1) != Success) {
   15.38          return;
   15.39      }
   15.40  #endif
   15.41 @@ -226,7 +226,7 @@
   15.42      XISetMask(mask, XI_TouchUpdate);
   15.43      XISetMask(mask, XI_TouchEnd);
   15.44  
   15.45 -    XISelectEvents(data->display,window_data->xwindow,&eventmask,1);
   15.46 +    X11_XISelectEvents(data->display,window_data->xwindow,&eventmask,1);
   15.47  #endif
   15.48  }
   15.49