Browse Source

Don't supply duplicate X11 symbols inside SDL.

Fixes static linking when something else also uses X11.
Ryan C. Gordon 12 years ago
parent
commit
a2bd897064

+ 13 - 13
src/video/x11/SDL_x11clipboard.c

@@ -31,7 +31,7 @@
 
 
 /* If you don't support UTF-8, you might use XA_STRING here */
 /* If you don't support UTF-8, you might use XA_STRING here */
 #ifdef X_HAVE_UTF8_STRING
 #ifdef X_HAVE_UTF8_STRING
-#define TEXT_FORMAT XInternAtom(display, "UTF8_STRING", False)
+#define TEXT_FORMAT X11_XInternAtom(display, "UTF8_STRING", False)
 #else
 #else
 #define TEXT_FORMAT XA_STRING
 #define TEXT_FORMAT XA_STRING
 #endif
 #endif
@@ -55,7 +55,7 @@ X11_SetClipboardText(_THIS, const char *text)
     Display *display = ((SDL_VideoData *) _this->driverdata)->display;
     Display *display = ((SDL_VideoData *) _this->driverdata)->display;
     Atom format;
     Atom format;
     Window window;
     Window window;
-    Atom XA_CLIPBOARD = XInternAtom(display, "CLIPBOARD", 0);
+    Atom XA_CLIPBOARD = X11_XInternAtom(display, "CLIPBOARD", 0);
 
 
     /* Get the SDL window that will own the selection */
     /* Get the SDL window that will own the selection */
     window = GetWindow(_this);
     window = GetWindow(_this);
@@ -65,17 +65,17 @@ X11_SetClipboardText(_THIS, const char *text)
 
 
     /* Save the selection on the root window */
     /* Save the selection on the root window */
     format = TEXT_FORMAT;
     format = TEXT_FORMAT;
-    XChangeProperty(display, DefaultRootWindow(display),
+    X11_XChangeProperty(display, DefaultRootWindow(display),
         XA_CUT_BUFFER0, format, 8, PropModeReplace,
         XA_CUT_BUFFER0, format, 8, PropModeReplace,
         (const unsigned char *)text, SDL_strlen(text));
         (const unsigned char *)text, SDL_strlen(text));
 
 
     if (XA_CLIPBOARD != None &&
     if (XA_CLIPBOARD != None &&
-        XGetSelectionOwner(display, XA_CLIPBOARD) != window) {
-        XSetSelectionOwner(display, XA_CLIPBOARD, window, CurrentTime);
+        X11_XGetSelectionOwner(display, XA_CLIPBOARD) != window) {
+        X11_XSetSelectionOwner(display, XA_CLIPBOARD, window, CurrentTime);
     }
     }
 
 
-    if (XGetSelectionOwner(display, XA_PRIMARY) != window) {
-        XSetSelectionOwner(display, XA_PRIMARY, window, CurrentTime);
+    if (X11_XGetSelectionOwner(display, XA_PRIMARY) != window) {
+        X11_XSetSelectionOwner(display, XA_PRIMARY, window, CurrentTime);
     }
     }
     return 0;
     return 0;
 }
 }
@@ -97,7 +97,7 @@ X11_GetClipboardText(_THIS)
     char *text;
     char *text;
     Uint32 waitStart;
     Uint32 waitStart;
     Uint32 waitElapsed;
     Uint32 waitElapsed;
-    Atom XA_CLIPBOARD = XInternAtom(display, "CLIPBOARD", 0);
+    Atom XA_CLIPBOARD = X11_XInternAtom(display, "CLIPBOARD", 0);
     if (XA_CLIPBOARD == None) {
     if (XA_CLIPBOARD == None) {
         SDL_SetError("Couldn't access X clipboard");
         SDL_SetError("Couldn't access X clipboard");
         return SDL_strdup("");
         return SDL_strdup("");
@@ -108,15 +108,15 @@ X11_GetClipboardText(_THIS)
     /* Get the window that holds the selection */
     /* Get the window that holds the selection */
     window = GetWindow(_this);
     window = GetWindow(_this);
     format = TEXT_FORMAT;
     format = TEXT_FORMAT;
-    owner = XGetSelectionOwner(display, XA_CLIPBOARD);
+    owner = X11_XGetSelectionOwner(display, XA_CLIPBOARD);
     if ((owner == None) || (owner == window)) {
     if ((owner == None) || (owner == window)) {
         owner = DefaultRootWindow(display);
         owner = DefaultRootWindow(display);
         selection = XA_CUT_BUFFER0;
         selection = XA_CUT_BUFFER0;
     } else {
     } else {
         /* Request that the selection owner copy the data to our window */
         /* Request that the selection owner copy the data to our window */
         owner = window;
         owner = window;
-        selection = XInternAtom(display, "SDL_SELECTION", False);
-        XConvertSelection(display, XA_CLIPBOARD, format, selection, owner,
+        selection = X11_XInternAtom(display, "SDL_SELECTION", False);
+        X11_XConvertSelection(display, XA_CLIPBOARD, format, selection, owner,
             CurrentTime);
             CurrentTime);
 
 
         /* When using synergy on Linux and when data has been put in the clipboard
         /* When using synergy on Linux and when data has been put in the clipboard
@@ -139,7 +139,7 @@ X11_GetClipboardText(_THIS)
         }
         }
     }
     }
 
 
-    if (XGetWindowProperty(display, owner, selection, 0, INT_MAX/4, False,
+    if (X11_XGetWindowProperty(display, owner, selection, 0, INT_MAX/4, False,
             format, &seln_type, &seln_format, &nbytes, &overflow, &src)
             format, &seln_type, &seln_format, &nbytes, &overflow, &src)
             == Success) {
             == Success) {
         if (seln_type == format) {
         if (seln_type == format) {
@@ -149,7 +149,7 @@ X11_GetClipboardText(_THIS)
                 text[nbytes] = '\0';
                 text[nbytes] = '\0';
             }
             }
         }
         }
-        XFree(src);
+        X11_XFree(src);
     }
     }
 
 
     if (!text) {
     if (!text) {

+ 20 - 26
src/video/x11/SDL_x11dyn.c

@@ -103,24 +103,19 @@ X11_GetSym(const char *fnname, int *pHasModule)
     return fn;
     return fn;
 }
 }
 
 
+#endif /* SDL_VIDEO_DRIVER_X11_DYNAMIC */
 
 
 /* Define all the function pointers and wrappers... */
 /* Define all the function pointers and wrappers... */
 #define SDL_X11_MODULE(modname)
 #define SDL_X11_MODULE(modname)
-#define SDL_X11_SYM(rc,fn,params,args,ret) \
-    typedef rc (*SDL_DYNX11FN_##fn) params; \
-    static SDL_DYNX11FN_##fn p##fn = NULL; \
-    rc fn params { ret p##fn args ; }
+#define SDL_X11_SYM(rc,fn,params,args,ret) SDL_DYNX11FN_##fn X11_##fn = NULL;
 #include "SDL_x11sym.h"
 #include "SDL_x11sym.h"
 #undef SDL_X11_MODULE
 #undef SDL_X11_MODULE
 #undef SDL_X11_SYM
 #undef SDL_X11_SYM
-#endif /* SDL_VIDEO_DRIVER_X11_DYNAMIC */
 
 
 /* Annoying varargs entry point... */
 /* Annoying varargs entry point... */
 #ifdef X_HAVE_UTF8_STRING
 #ifdef X_HAVE_UTF8_STRING
-typedef XIC(*SDL_DYNX11FN_XCreateIC) (XIM,...);
-SDL_DYNX11FN_XCreateIC pXCreateIC = NULL;
-typedef char *(*SDL_DYNX11FN_XGetICValues) (XIC, ...);
-SDL_DYNX11FN_XGetICValues pXGetICValues = NULL;
+SDL_DYNX11FN_XCreateIC X11_XCreateIC = NULL;
+SDL_DYNX11FN_XGetICValues X11_XGetICValues = NULL;
 #endif
 #endif
 
 
 /* These SDL_X11_HAVE_* flags are here whether you have dynamic X11 or not. */
 /* These SDL_X11_HAVE_* flags are here whether you have dynamic X11 or not. */
@@ -130,15 +125,11 @@ SDL_DYNX11FN_XGetICValues pXGetICValues = NULL;
 #undef SDL_X11_MODULE
 #undef SDL_X11_MODULE
 #undef SDL_X11_SYM
 #undef SDL_X11_SYM
 
 
-
-#ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC
 static int x11_load_refcount = 0;
 static int x11_load_refcount = 0;
-#endif
 
 
 void
 void
 SDL_X11_UnloadSymbols(void)
 SDL_X11_UnloadSymbols(void)
 {
 {
-#ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC
     /* Don't actually unload if more than one module is using the libs... */
     /* Don't actually unload if more than one module is using the libs... */
     if (x11_load_refcount > 0) {
     if (x11_load_refcount > 0) {
         if (--x11_load_refcount == 0) {
         if (--x11_load_refcount == 0) {
@@ -146,25 +137,26 @@ SDL_X11_UnloadSymbols(void)
 
 
             /* set all the function pointers to NULL. */
             /* set all the function pointers to NULL. */
 #define SDL_X11_MODULE(modname) SDL_X11_HAVE_##modname = 0;
 #define SDL_X11_MODULE(modname) SDL_X11_HAVE_##modname = 0;
-#define SDL_X11_SYM(rc,fn,params,args,ret) p##fn = NULL;
+#define SDL_X11_SYM(rc,fn,params,args,ret) X11_##fn = NULL;
 #include "SDL_x11sym.h"
 #include "SDL_x11sym.h"
 #undef SDL_X11_MODULE
 #undef SDL_X11_MODULE
 #undef SDL_X11_SYM
 #undef SDL_X11_SYM
 
 
 #ifdef X_HAVE_UTF8_STRING
 #ifdef X_HAVE_UTF8_STRING
-            pXCreateIC = NULL;
-            pXGetICValues = NULL;
+            X11_XCreateIC = NULL;
+            X11_XGetICValues = NULL;
 #endif
 #endif
 
 
+#ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC
             for (i = 0; i < SDL_TABLESIZE(x11libs); i++) {
             for (i = 0; i < SDL_TABLESIZE(x11libs); i++) {
                 if (x11libs[i].lib != NULL) {
                 if (x11libs[i].lib != NULL) {
                     SDL_UnloadObject(x11libs[i].lib);
                     SDL_UnloadObject(x11libs[i].lib);
                     x11libs[i].lib = NULL;
                     x11libs[i].lib = NULL;
                 }
                 }
             }
             }
+#endif
         }
         }
     }
     }
-#endif
 }
 }
 
 
 /* returns non-zero if all needed symbols were loaded. */
 /* returns non-zero if all needed symbols were loaded. */
@@ -173,9 +165,9 @@ SDL_X11_LoadSymbols(void)
 {
 {
     int rc = 1;                 /* always succeed if not using Dynamic X11 stuff. */
     int rc = 1;                 /* always succeed if not using Dynamic X11 stuff. */
 
 
-#ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC
     /* deal with multiple modules (dga, x11, etc) needing these symbols... */
     /* deal with multiple modules (dga, x11, etc) needing these symbols... */
     if (x11_load_refcount++ == 0) {
     if (x11_load_refcount++ == 0) {
+#ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC
         int i;
         int i;
         int *thismod = NULL;
         int *thismod = NULL;
         for (i = 0; i < SDL_TABLESIZE(x11libs); i++) {
         for (i = 0; i < SDL_TABLESIZE(x11libs); i++) {
@@ -191,15 +183,15 @@ SDL_X11_LoadSymbols(void)
 #undef SDL_X11_SYM
 #undef SDL_X11_SYM
 
 
 #define SDL_X11_MODULE(modname) thismod = &SDL_X11_HAVE_##modname;
 #define SDL_X11_MODULE(modname) thismod = &SDL_X11_HAVE_##modname;
-#define SDL_X11_SYM(a,fn,x,y,z) p##fn = (SDL_DYNX11FN_##fn) X11_GetSym(#fn,thismod);
+#define SDL_X11_SYM(a,fn,x,y,z) X11_##fn = (SDL_DYNX11FN_##fn) X11_GetSym(#fn,thismod);
 #include "SDL_x11sym.h"
 #include "SDL_x11sym.h"
 #undef SDL_X11_MODULE
 #undef SDL_X11_MODULE
 #undef SDL_X11_SYM
 #undef SDL_X11_SYM
 
 
 #ifdef X_HAVE_UTF8_STRING
 #ifdef X_HAVE_UTF8_STRING
-        pXCreateIC = (SDL_DYNX11FN_XCreateIC)
+        X11_XCreateIC = (SDL_DYNX11FN_XCreateIC)
                         X11_GetSym("XCreateIC", &SDL_X11_HAVE_UTF8);
                         X11_GetSym("XCreateIC", &SDL_X11_HAVE_UTF8);
-        pXGetICValues = (SDL_DYNX11FN_XGetICValues)
+        X11_XGetICValues = (SDL_DYNX11FN_XGetICValues)
                         X11_GetSym("XGetICValues", &SDL_X11_HAVE_UTF8);
                         X11_GetSym("XGetICValues", &SDL_X11_HAVE_UTF8);
 #endif
 #endif
 
 
@@ -211,19 +203,21 @@ SDL_X11_LoadSymbols(void)
             SDL_X11_UnloadSymbols();
             SDL_X11_UnloadSymbols();
             rc = 0;
             rc = 0;
         }
         }
-    }
-#else
+
+#else  /* no dynamic X11 */
+
 #define SDL_X11_MODULE(modname) SDL_X11_HAVE_##modname = 1; /* default yes */
 #define SDL_X11_MODULE(modname) SDL_X11_HAVE_##modname = 1; /* default yes */
-#define SDL_X11_SYM(a,fn,x,y,z)
+#define SDL_X11_SYM(a,fn,x,y,z) X11_##fn = fn;
 #include "SDL_x11sym.h"
 #include "SDL_x11sym.h"
 #undef SDL_X11_MODULE
 #undef SDL_X11_MODULE
 #undef SDL_X11_SYM
 #undef SDL_X11_SYM
 
 
 #ifdef X_HAVE_UTF8_STRING
 #ifdef X_HAVE_UTF8_STRING
-    pXCreateIC = XCreateIC;
-    pXGetICValues = XGetICValues;
+        X11_XCreateIC = XCreateIC;
+        X11_XGetICValues = XGetICValues;
 #endif
 #endif
 #endif
 #endif
+    }
 
 
     return rc;
     return rc;
 }
 }

+ 20 - 22
src/video/x11/SDL_x11dyn.h

@@ -69,35 +69,34 @@
 #include <X11/extensions/xf86vmode.h>
 #include <X11/extensions/xf86vmode.h>
 #endif
 #endif
 
 
-/*
- * When using the "dynamic X11" functionality, we duplicate all the Xlib
- *  symbols that would be referenced by SDL inside of SDL itself.
- *  These duplicated symbols just serve as passthroughs to the functions
- *  in Xlib, that was dynamically loaded.
- *
- * This allows us to use Xlib as-is when linking against it directly, but
- *  also handles all the strange cases where there was code in the Xlib
- *  headers that may or may not exist or vary on a given platform.
- */
 #ifdef __cplusplus
 #ifdef __cplusplus
 extern "C"
 extern "C"
 {
 {
 #endif
 #endif
 
 
 /* evil function signatures... */
 /* evil function signatures... */
-    typedef Bool(*SDL_X11_XESetWireToEventRetType) (Display *, XEvent *,
-                                                    xEvent *);
-    typedef int (*SDL_X11_XSynchronizeRetType) (Display *);
-    typedef Status(*SDL_X11_XESetEventToWireRetType) (Display *, XEvent *,
-                                                      xEvent *);
-
-    int SDL_X11_LoadSymbols(void);
-    void SDL_X11_UnloadSymbols(void);
+typedef Bool(*SDL_X11_XESetWireToEventRetType) (Display *, XEvent *, xEvent *);
+typedef int (*SDL_X11_XSynchronizeRetType) (Display *);
+typedef Status(*SDL_X11_XESetEventToWireRetType) (Display *, XEvent *, xEvent *);
+
+int SDL_X11_LoadSymbols(void);
+void SDL_X11_UnloadSymbols(void);
+
+/* Declare all the function pointers and wrappers... */
+#define SDL_X11_MODULE(modname)
+#define SDL_X11_SYM(rc,fn,params,args,ret) \
+    typedef rc (*SDL_DYNX11FN_##fn) params; \
+    extern SDL_DYNX11FN_##fn X11_##fn;
+#include "SDL_x11sym.h"
+#undef SDL_X11_MODULE
+#undef SDL_X11_SYM
 
 
-/* That's really annoying...make these function pointers no matter what. */
+/* Annoying varargs entry point... */
 #ifdef X_HAVE_UTF8_STRING
 #ifdef X_HAVE_UTF8_STRING
-    extern XIC(*pXCreateIC) (XIM, ...);
-    extern char *(*pXGetICValues) (XIC, ...);
+typedef XIC(*SDL_DYNX11FN_XCreateIC) (XIM,...);
+typedef char *(*SDL_DYNX11FN_XGetICValues) (XIC, ...);
+extern SDL_DYNX11FN_XCreateIC X11_XCreateIC;
+extern SDL_DYNX11FN_XGetICValues X11_XGetICValues;
 #endif
 #endif
 
 
 /* These SDL_X11_HAVE_* flags are here whether you have dynamic X11 or not. */
 /* These SDL_X11_HAVE_* flags are here whether you have dynamic X11 or not. */
@@ -107,7 +106,6 @@ extern "C"
 #undef SDL_X11_MODULE
 #undef SDL_X11_MODULE
 #undef SDL_X11_SYM
 #undef SDL_X11_SYM
 
 
-
 #ifdef __cplusplus
 #ifdef __cplusplus
 }
 }
 #endif
 #endif

+ 54 - 54
src/video/x11/SDL_x11events.c

@@ -48,7 +48,7 @@ typedef struct {
 } SDL_x11Prop;
 } SDL_x11Prop;
 
 
 /* Reads property
 /* Reads property
-   Must call XFree on results
+   Must call X11_XFree on results
  */
  */
 static void X11_ReadProperty(SDL_x11Prop *p, Display *disp, Window w, Atom prop)
 static void X11_ReadProperty(SDL_x11Prop *p, Display *disp, Window w, Atom prop)
 {
 {
@@ -60,8 +60,8 @@ static void X11_ReadProperty(SDL_x11Prop *p, Display *disp, Window w, Atom prop)
     int bytes_fetch = 0;
     int bytes_fetch = 0;
 
 
     do {
     do {
-        if (ret != 0) XFree(ret);
-        XGetWindowProperty(disp, w, prop, 0, bytes_fetch, False, AnyPropertyType, &type, &fmt, &count, &bytes_left, &ret);
+        if (ret != 0) X11_XFree(ret);
+        X11_XGetWindowProperty(disp, w, prop, 0, bytes_fetch, False, AnyPropertyType, &type, &fmt, &count, &bytes_left, &ret);
         bytes_fetch += bytes_left;
         bytes_fetch += bytes_left;
     } while (bytes_left != 0);
     } while (bytes_left != 0);
 
 
@@ -79,9 +79,9 @@ static Atom X11_PickTarget(Display *disp, Atom list[], int list_count)
     char *name;
     char *name;
     int i;
     int i;
     for (i=0; i < list_count && request == None; i++) {
     for (i=0; i < list_count && request == None; i++) {
-        name = XGetAtomName(disp, list[i]);
+        name = X11_XGetAtomName(disp, list[i]);
         if (strcmp("text/uri-list", name)==0) request = list[i];
         if (strcmp("text/uri-list", name)==0) request = list[i];
-        XFree(name);
+        X11_XFree(name);
     }
     }
     return request;
     return request;
 }
 }
@@ -125,8 +125,8 @@ static SDL_bool X11_KeyRepeat(Display *display, XEvent *event)
     struct KeyRepeatCheckData d;
     struct KeyRepeatCheckData d;
     d.event = event;
     d.event = event;
     d.found = SDL_FALSE;
     d.found = SDL_FALSE;
-    if (XPending(display))
-        XCheckIfEvent(display, &dummyev, X11_KeyRepeatCheckIfEvent,
+    if (X11_XPending(display))
+        X11_XCheckIfEvent(display, &dummyev, X11_KeyRepeatCheckIfEvent,
             (XPointer) &d);
             (XPointer) &d);
     return d.found;
     return d.found;
 }
 }
@@ -147,7 +147,7 @@ static Bool X11_IsWheelCheckIfEvent(Display *display, XEvent *chkev,
 static SDL_bool X11_IsWheelEvent(Display * display,XEvent * event,int * ticks)
 static SDL_bool X11_IsWheelEvent(Display * display,XEvent * event,int * ticks)
 {
 {
     XEvent relevent;
     XEvent relevent;
-    if (XPending(display)) {
+    if (X11_XPending(display)) {
         /* according to the xlib docs, no specific mouse wheel events exist.
         /* according to the xlib docs, no specific mouse wheel events exist.
            however, mouse wheel events trigger a button press and a button release
            however, mouse wheel events trigger a button press and a button release
            immediately. thus, checking if the same button was released at the same
            immediately. thus, checking if the same button was released at the same
@@ -158,7 +158,7 @@ static SDL_bool X11_IsWheelEvent(Display * display,XEvent * event,int * ticks)
              generated (or synthesised) immediately.
              generated (or synthesised) immediately.
            - False negative: a wheel which, when rolled, doesn't have
            - False negative: a wheel which, when rolled, doesn't have
              a release event generated immediately. */
              a release event generated immediately. */
-        if (XCheckIfEvent(display, &relevent, X11_IsWheelCheckIfEvent,
+        if (X11_XCheckIfEvent(display, &relevent, X11_IsWheelCheckIfEvent,
             (XPointer) event)) {
             (XPointer) event)) {
 
 
             /* by default, X11 only knows 5 buttons. on most 3 button + wheel mouse,
             /* by default, X11 only knows 5 buttons. on most 3 button + wheel mouse,
@@ -217,9 +217,9 @@ static void X11_HandleGenericEvent(SDL_VideoData *videodata,XEvent event)
 {
 {
     /* event is a union, so cookie == &event, but this is type safe. */
     /* event is a union, so cookie == &event, but this is type safe. */
     XGenericEventCookie *cookie = &event.xcookie;
     XGenericEventCookie *cookie = &event.xcookie;
-    if (XGetEventData(videodata->display, cookie)) {
+    if (X11_XGetEventData(videodata->display, cookie)) {
         X11_HandleXinput2Event(videodata, cookie);
         X11_HandleXinput2Event(videodata, cookie);
-        XFreeEventData(videodata->display, cookie);
+        X11_XFreeEventData(videodata->display, cookie);
     }
     }
 }
 }
 #endif /* SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS */
 #endif /* SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS */
@@ -234,7 +234,7 @@ X11_DispatchFocusIn(SDL_WindowData *data)
     SDL_SetKeyboardFocus(data->window);
     SDL_SetKeyboardFocus(data->window);
 #ifdef X_HAVE_UTF8_STRING
 #ifdef X_HAVE_UTF8_STRING
     if (data->ic) {
     if (data->ic) {
-        XSetICFocus(data->ic);
+        X11_XSetICFocus(data->ic);
     }
     }
 #endif
 #endif
 }
 }
@@ -248,7 +248,7 @@ X11_DispatchFocusOut(SDL_WindowData *data)
     SDL_SetKeyboardFocus(NULL);
     SDL_SetKeyboardFocus(NULL);
 #ifdef X_HAVE_UTF8_STRING
 #ifdef X_HAVE_UTF8_STRING
     if (data->ic) {
     if (data->ic) {
-        XUnsetICFocus(data->ic);
+        X11_XUnsetICFocus(data->ic);
     }
     }
 #endif
 #endif
 }
 }
@@ -278,11 +278,11 @@ X11_DispatchEvent(_THIS)
     XClientMessageEvent m;
     XClientMessageEvent m;
 
 
     SDL_zero(xevent);           /* valgrind fix. --ryan. */
     SDL_zero(xevent);           /* valgrind fix. --ryan. */
-    XNextEvent(display, &xevent);
+    X11_XNextEvent(display, &xevent);
 
 
     /* filter events catchs XIM events and sends them to the correct
     /* filter events catchs XIM events and sends them to the correct
        handler */
        handler */
-    if (XFilterEvent(&xevent, None) == True) {
+    if (X11_XFilterEvent(&xevent, None) == True) {
 #if 0
 #if 0
         printf("Filtered event type = %d display = %d window = %d\n",
         printf("Filtered event type = %d display = %d window = %d\n",
                xevent.type, xevent.xany.display, xevent.xany.window);
                xevent.type, xevent.xany.display, xevent.xany.window);
@@ -451,23 +451,23 @@ X11_DispatchEvent(_THIS)
 #if 1
 #if 1
             if (videodata->key_layout[keycode] == SDL_SCANCODE_UNKNOWN && keycode) {
             if (videodata->key_layout[keycode] == SDL_SCANCODE_UNKNOWN && keycode) {
                 int min_keycode, max_keycode;
                 int min_keycode, max_keycode;
-                XDisplayKeycodes(display, &min_keycode, &max_keycode);
+                X11_XDisplayKeycodes(display, &min_keycode, &max_keycode);
 #if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM
 #if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM
-                keysym = XkbKeycodeToKeysym(display, keycode, 0, 0);
+                keysym = X11_XkbKeycodeToKeysym(display, keycode, 0, 0);
 #else
 #else
                 keysym = XKeycodeToKeysym(display, keycode, 0);
                 keysym = XKeycodeToKeysym(display, keycode, 0);
 #endif
 #endif
                 fprintf(stderr,
                 fprintf(stderr,
                         "The key you just pressed is not recognized by SDL. To help get this fixed, please report this to the SDL mailing list <[email protected]> X11 KeyCode %d (%d), X11 KeySym 0x%lX (%s).\n",
                         "The key you just pressed is not recognized by SDL. To help get this fixed, please report this to the SDL mailing list <[email protected]> X11 KeyCode %d (%d), X11 KeySym 0x%lX (%s).\n",
                         keycode, keycode - min_keycode, keysym,
                         keycode, keycode - min_keycode, keysym,
-                        XKeysymToString(keysym));
+                        X11_XKeysymToString(keysym));
             }
             }
 #endif
 #endif
             /* */
             /* */
             SDL_zero(text);
             SDL_zero(text);
 #ifdef X_HAVE_UTF8_STRING
 #ifdef X_HAVE_UTF8_STRING
             if (data->ic) {
             if (data->ic) {
-                Xutf8LookupString(data->ic, &xevent.xkey, text, sizeof(text),
+                X11_Xutf8LookupString(data->ic, &xevent.xkey, text, sizeof(text),
                                   &keysym, &status);
                                   &keysym, &status);
             }
             }
 #else
 #else
@@ -549,7 +549,7 @@ X11_DispatchEvent(_THIS)
                     X11_ReadProperty(&p, display, data->xdnd_source, videodata->XdndTypeList);
                     X11_ReadProperty(&p, display, data->xdnd_source, videodata->XdndTypeList);
                     /* pick one */
                     /* pick one */
                     data->xdnd_req = X11_PickTarget(display, (Atom*)p.data, p.count);
                     data->xdnd_req = X11_PickTarget(display, (Atom*)p.data, p.count);
-                    XFree(p.data);
+                    X11_XFree(p.data);
                 } else {
                 } else {
                     /* pick from list of three */
                     /* pick from list of three */
                     data->xdnd_req = X11_PickTargetFromAtoms(display, xevent.xclient.data.l[2], xevent.xclient.data.l[3], xevent.xclient.data.l[4]);
                     data->xdnd_req = X11_PickTargetFromAtoms(display, xevent.xclient.data.l[2], xevent.xclient.data.l[3], xevent.xclient.data.l[4]);
@@ -570,8 +570,8 @@ X11_DispatchEvent(_THIS)
                 m.data.l[3] = 0;
                 m.data.l[3] = 0;
                 m.data.l[4] = videodata->XdndActionCopy; /* we only accept copying anyway */
                 m.data.l[4] = videodata->XdndActionCopy; /* we only accept copying anyway */
 
 
-                XSendEvent(display, xevent.xclient.data.l[0], False, NoEventMask, (XEvent*)&m);
-                XFlush(display);
+                X11_XSendEvent(display, xevent.xclient.data.l[0], False, NoEventMask, (XEvent*)&m);
+                X11_XFlush(display);
             }
             }
             else if(xevent.xclient.message_type == videodata->XdndDrop) {
             else if(xevent.xclient.message_type == videodata->XdndDrop) {
                 if (data->xdnd_req == None) {
                 if (data->xdnd_req == None) {
@@ -585,13 +585,13 @@ X11_DispatchEvent(_THIS)
                     m.data.l[0] = data->xwindow;
                     m.data.l[0] = data->xwindow;
                     m.data.l[1] = 0;
                     m.data.l[1] = 0;
                     m.data.l[2] = None; /* fail! */
                     m.data.l[2] = None; /* fail! */
-                    XSendEvent(display, xevent.xclient.data.l[0], False, NoEventMask, (XEvent*)&m);
+                    X11_XSendEvent(display, xevent.xclient.data.l[0], False, NoEventMask, (XEvent*)&m);
                 } else {
                 } else {
                     /* convert */
                     /* convert */
                     if(xdnd_version >= 1) {
                     if(xdnd_version >= 1) {
-                        XConvertSelection(display, videodata->XdndSelection, data->xdnd_req, videodata->PRIMARY, data->xwindow, xevent.xclient.data.l[2]);
+                        X11_XConvertSelection(display, videodata->XdndSelection, data->xdnd_req, videodata->PRIMARY, data->xwindow, xevent.xclient.data.l[2]);
                     } else {
                     } else {
-                        XConvertSelection(display, videodata->XdndSelection, data->xdnd_req, videodata->PRIMARY, data->xwindow, CurrentTime);
+                        X11_XConvertSelection(display, videodata->XdndSelection, data->xdnd_req, videodata->PRIMARY, data->xwindow, CurrentTime);
                     }
                     }
                 }
                 }
             }
             }
@@ -604,7 +604,7 @@ X11_DispatchEvent(_THIS)
                 printf("window %p: _NET_WM_PING\n", data);
                 printf("window %p: _NET_WM_PING\n", data);
 #endif
 #endif
                 xevent.xclient.window = root;
                 xevent.xclient.window = root;
-                XSendEvent(display, root, False, SubstructureRedirectMask | SubstructureNotifyMask, &xevent);
+                X11_XSendEvent(display, root, False, SubstructureRedirectMask | SubstructureNotifyMask, &xevent);
                 break;
                 break;
             }
             }
 
 
@@ -664,13 +664,13 @@ X11_DispatchEvent(_THIS)
             Atom real_type;
             Atom real_type;
             unsigned long items_read, items_left, i;
             unsigned long items_read, items_left, i;
 
 
-            char *name = XGetAtomName(display, xevent.xproperty.atom);
+            char *name = X11_XGetAtomName(display, xevent.xproperty.atom);
             if (name) {
             if (name) {
                 printf("window %p: PropertyNotify: %s %s\n", data, name, (xevent.xproperty.state == PropertyDelete) ? "deleted" : "changed");
                 printf("window %p: PropertyNotify: %s %s\n", data, name, (xevent.xproperty.state == PropertyDelete) ? "deleted" : "changed");
-                XFree(name);
+                X11_XFree(name);
             }
             }
 
 
-            status = XGetWindowProperty(display, data->xwindow, xevent.xproperty.atom, 0L, 8192L, False, AnyPropertyType, &real_type, &real_format, &items_read, &items_left, &propdata);
+            status = X11_XGetWindowProperty(display, data->xwindow, xevent.xproperty.atom, 0L, 8192L, False, AnyPropertyType, &real_type, &real_format, &items_read, &items_left, &propdata);
             if (status == Success && items_read > 0) {
             if (status == Success && items_read > 0) {
                 if (real_type == XA_INTEGER) {
                 if (real_type == XA_INTEGER) {
                     int *values = (int *)propdata;
                     int *values = (int *)propdata;
@@ -714,23 +714,23 @@ X11_DispatchEvent(_THIS)
 
 
                     printf("{");
                     printf("{");
                     for (i = 0; i < items_read; i++) {
                     for (i = 0; i < items_read; i++) {
-                        char *name = XGetAtomName(display, atoms[i]);
+                        char *name = X11_XGetAtomName(display, atoms[i]);
                         if (name) {
                         if (name) {
                             printf(" %s", name);
                             printf(" %s", name);
-                            XFree(name);
+                            X11_XFree(name);
                         }
                         }
                     }
                     }
                     printf(" }\n");
                     printf(" }\n");
                 } else {
                 } else {
-                    char *name = XGetAtomName(display, real_type);
+                    char *name = X11_XGetAtomName(display, real_type);
                     printf("Unknown type: %ld (%s)\n", real_type, name ? name : "UNKNOWN");
                     printf("Unknown type: %ld (%s)\n", real_type, name ? name : "UNKNOWN");
                     if (name) {
                     if (name) {
-                        XFree(name);
+                        X11_XFree(name);
                     }
                     }
                 }
                 }
             }
             }
             if (status == Success) {
             if (status == Success) {
-                XFree(propdata);
+                X11_XFree(propdata);
             }
             }
 #endif /* DEBUG_XEVENTS */
 #endif /* DEBUG_XEVENTS */
 
 
@@ -774,28 +774,28 @@ X11_DispatchEvent(_THIS)
             sevent.xselection.property = None;
             sevent.xselection.property = None;
             sevent.xselection.requestor = req->requestor;
             sevent.xselection.requestor = req->requestor;
             sevent.xselection.time = req->time;
             sevent.xselection.time = req->time;
-            if (XGetWindowProperty(display, DefaultRootWindow(display),
+            if (X11_XGetWindowProperty(display, DefaultRootWindow(display),
                     XA_CUT_BUFFER0, 0, INT_MAX/4, False, req->target,
                     XA_CUT_BUFFER0, 0, INT_MAX/4, False, req->target,
                     &sevent.xselection.target, &seln_format, &nbytes,
                     &sevent.xselection.target, &seln_format, &nbytes,
                     &overflow, &seln_data) == Success) {
                     &overflow, &seln_data) == Success) {
-                Atom XA_TARGETS = XInternAtom(display, "TARGETS", 0);
+                Atom XA_TARGETS = X11_XInternAtom(display, "TARGETS", 0);
                 if (sevent.xselection.target == req->target) {
                 if (sevent.xselection.target == req->target) {
-                    XChangeProperty(display, req->requestor, req->property,
+                    X11_XChangeProperty(display, req->requestor, req->property,
                         sevent.xselection.target, seln_format, PropModeReplace,
                         sevent.xselection.target, seln_format, PropModeReplace,
                         seln_data, nbytes);
                         seln_data, nbytes);
                     sevent.xselection.property = req->property;
                     sevent.xselection.property = req->property;
                 } else if (XA_TARGETS == req->target) {
                 } else if (XA_TARGETS == req->target) {
                     Atom SupportedFormats[] = { sevent.xselection.target, XA_TARGETS };
                     Atom SupportedFormats[] = { sevent.xselection.target, XA_TARGETS };
-                    XChangeProperty(display, req->requestor, req->property,
+                    X11_XChangeProperty(display, req->requestor, req->property,
                         XA_ATOM, 32, PropModeReplace,
                         XA_ATOM, 32, PropModeReplace,
                         (unsigned char*)SupportedFormats,
                         (unsigned char*)SupportedFormats,
                         sizeof(SupportedFormats)/sizeof(*SupportedFormats));
                         sizeof(SupportedFormats)/sizeof(*SupportedFormats));
                     sevent.xselection.property = req->property;
                     sevent.xselection.property = req->property;
                 }
                 }
-                XFree(seln_data);
+                X11_XFree(seln_data);
             }
             }
-            XSendEvent(display, req->requestor, False, 0, &sevent);
-            XSync(display, False);
+            X11_XSendEvent(display, req->requestor, False, 0, &sevent);
+            X11_XSync(display, False);
         }
         }
         break;
         break;
 
 
@@ -845,7 +845,7 @@ X11_DispatchEvent(_THIS)
                     }
                     }
                 }
                 }
 
 
-                XFree(p.data);
+                X11_XFree(p.data);
 
 
                 /* send reply */
                 /* send reply */
                 SDL_memset(&m, 0, sizeof(XClientMessageEvent));
                 SDL_memset(&m, 0, sizeof(XClientMessageEvent));
@@ -857,9 +857,9 @@ X11_DispatchEvent(_THIS)
                 m.data.l[0] = data->xwindow;
                 m.data.l[0] = data->xwindow;
                 m.data.l[1] = 1;
                 m.data.l[1] = 1;
                 m.data.l[2] = videodata->XdndActionCopy;
                 m.data.l[2] = videodata->XdndActionCopy;
-                XSendEvent(display, data->xdnd_source, False, NoEventMask, (XEvent*)&m);
+                X11_XSendEvent(display, data->xdnd_source, False, NoEventMask, (XEvent*)&m);
 
 
-                XSync(display, False);
+                X11_XSync(display, False);
 
 
             } else {
             } else {
                 videodata->selection_waiting = SDL_FALSE;
                 videodata->selection_waiting = SDL_FALSE;
@@ -899,13 +899,13 @@ X11_HandleFocusChanges(_THIS)
         }
         }
     }
     }
 }
 }
-/* Ack!  XPending() actually performs a blocking read if no events available */
+/* Ack!  X11_XPending() actually performs a blocking read if no events available */
 static int
 static int
 X11_Pending(Display * display)
 X11_Pending(Display * display)
 {
 {
     /* Flush the display connection and look to see if events are queued */
     /* Flush the display connection and look to see if events are queued */
-    XFlush(display);
-    if (XEventsQueued(display, QueuedAlready)) {
+    X11_XFlush(display);
+    if (X11_XEventsQueued(display, QueuedAlready)) {
         return (1);
         return (1);
     }
     }
 
 
@@ -919,7 +919,7 @@ X11_Pending(Display * display)
         FD_ZERO(&fdset);
         FD_ZERO(&fdset);
         FD_SET(x11_fd, &fdset);
         FD_SET(x11_fd, &fdset);
         if (select(x11_fd + 1, &fdset, NULL, NULL, &zero_time) == 1) {
         if (select(x11_fd + 1, &fdset, NULL, NULL, &zero_time) == 1) {
-            return (XPending(display));
+            return (X11_XPending(display));
         }
         }
     }
     }
 
 
@@ -942,7 +942,7 @@ X11_PumpEvents(_THIS)
         Uint32 now = SDL_GetTicks();
         Uint32 now = SDL_GetTicks();
         if (!data->screensaver_activity ||
         if (!data->screensaver_activity ||
             (int) (now - data->screensaver_activity) >= 30000) {
             (int) (now - data->screensaver_activity) >= 30000) {
-            XResetScreenSaver(data->display);
+            X11_XResetScreenSaver(data->display);
 
 
             #if SDL_USE_LIBDBUS
             #if SDL_USE_LIBDBUS
             SDL_dbus_screensaver_tickle(_this);
             SDL_dbus_screensaver_tickle(_this);
@@ -971,16 +971,16 @@ X11_SuspendScreenSaver(_THIS)
     int major_version, minor_version;
     int major_version, minor_version;
 
 
     if (SDL_X11_HAVE_XSS) {
     if (SDL_X11_HAVE_XSS) {
-        /* XScreenSaverSuspend was introduced in MIT-SCREEN-SAVER 1.1 */
-        if (!XScreenSaverQueryExtension(data->display, &dummy, &dummy) ||
-            !XScreenSaverQueryVersion(data->display,
+        /* X11_XScreenSaverSuspend was introduced in MIT-SCREEN-SAVER 1.1 */
+        if (!X11_XScreenSaverQueryExtension(data->display, &dummy, &dummy) ||
+            !X11_XScreenSaverQueryVersion(data->display,
                                       &major_version, &minor_version) ||
                                       &major_version, &minor_version) ||
             major_version < 1 || (major_version == 1 && minor_version < 1)) {
             major_version < 1 || (major_version == 1 && minor_version < 1)) {
             return;
             return;
         }
         }
 
 
-        XScreenSaverSuspend(data->display, _this->suspend_screensaver);
-        XResetScreenSaver(data->display);
+        X11_XScreenSaverSuspend(data->display, _this->suspend_screensaver);
+        X11_XResetScreenSaver(data->display);
     }
     }
 #endif
 #endif
 
 

+ 17 - 17
src/video/x11/SDL_x11framebuffer.c

@@ -43,8 +43,8 @@ static int shm_errhandler(Display *d, XErrorEvent *e)
 static SDL_bool have_mitshm(void)
 static SDL_bool have_mitshm(void)
 {
 {
     /* Only use shared memory on local X servers */
     /* Only use shared memory on local X servers */
-    if ( (SDL_strncmp(XDisplayName(NULL), ":", 1) == 0) ||
-         (SDL_strncmp(XDisplayName(NULL), "unix:", 5) == 0) ) {
+    if ( (SDL_strncmp(X11_XDisplayName(NULL), ":", 1) == 0) ||
+         (SDL_strncmp(X11_XDisplayName(NULL), "unix:", 5) == 0) ) {
         return SDL_X11_HAVE_SHM;
         return SDL_X11_HAVE_SHM;
     }
     }
     return SDL_FALSE;
     return SDL_FALSE;
@@ -66,7 +66,7 @@ X11_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format,
 
 
     /* Create the graphics context for drawing */
     /* Create the graphics context for drawing */
     gcv.graphics_exposures = False;
     gcv.graphics_exposures = False;
-    data->gc = XCreateGC(display, data->xwindow, GCGraphicsExposures, &gcv);
+    data->gc = X11_XCreateGC(display, data->xwindow, GCGraphicsExposures, &gcv);
     if (!data->gc) {
     if (!data->gc) {
         return SDL_SetError("Couldn't create graphics context");
         return SDL_SetError("Couldn't create graphics context");
     }
     }
@@ -95,10 +95,10 @@ X11_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format,
             shminfo->readOnly = False;
             shminfo->readOnly = False;
             if ( shminfo->shmaddr != (char *)-1 ) {
             if ( shminfo->shmaddr != (char *)-1 ) {
                 shm_error = False;
                 shm_error = False;
-                X_handler = XSetErrorHandler(shm_errhandler);
-                XShmAttach(display, shminfo);
-                XSync(display, True);
-                XSetErrorHandler(X_handler);
+                X_handler = X11_XSetErrorHandler(shm_errhandler);
+                X11_XShmAttach(display, shminfo);
+                X11_XSync(display, True);
+                X11_XSetErrorHandler(X_handler);
                 if ( shm_error )
                 if ( shm_error )
                     shmdt(shminfo->shmaddr);
                     shmdt(shminfo->shmaddr);
             } else {
             } else {
@@ -109,13 +109,13 @@ X11_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format,
             shm_error = True;
             shm_error = True;
         }
         }
         if (!shm_error) {
         if (!shm_error) {
-            data->ximage = XShmCreateImage(display, data->visual,
+            data->ximage = X11_XShmCreateImage(display, data->visual,
                              vinfo.depth, ZPixmap,
                              vinfo.depth, ZPixmap,
                              shminfo->shmaddr, shminfo,
                              shminfo->shmaddr, shminfo,
                              window->w, window->h);
                              window->w, window->h);
             if (!data->ximage) {
             if (!data->ximage) {
-                XShmDetach(display, shminfo);
-                XSync(display, False);
+                X11_XShmDetach(display, shminfo);
+                X11_XSync(display, False);
                 shmdt(shminfo->shmaddr);
                 shmdt(shminfo->shmaddr);
             } else {
             } else {
                 /* Done! */
                 /* Done! */
@@ -132,7 +132,7 @@ X11_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format,
         return SDL_OutOfMemory();
         return SDL_OutOfMemory();
     }
     }
 
 
-    data->ximage = XCreateImage(display, data->visual,
+    data->ximage = X11_XCreateImage(display, data->visual,
                       vinfo.depth, ZPixmap, 0, (char *)(*pixels),
                       vinfo.depth, ZPixmap, 0, (char *)(*pixels),
                       window->w, window->h, 32, 0);
                       window->w, window->h, 32, 0);
     if (!data->ximage) {
     if (!data->ximage) {
@@ -177,7 +177,7 @@ X11_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rect * rects,
             if (y + h > window->h)
             if (y + h > window->h)
                 h = window->h - y;
                 h = window->h - y;
 
 
-            XShmPutImage(display, data->xwindow, data->gc, data->ximage,
+            X11_XShmPutImage(display, data->xwindow, data->gc, data->ximage,
                 x, y, x, y, w, h, False);
                 x, y, x, y, w, h, False);
         }
         }
     }
     }
@@ -209,12 +209,12 @@ X11_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rect * rects,
             if (y + h > window->h)
             if (y + h > window->h)
                 h = window->h - y;
                 h = window->h - y;
 
 
-            XPutImage(display, data->xwindow, data->gc, data->ximage,
+            X11_XPutImage(display, data->xwindow, data->gc, data->ximage,
                 x, y, x, y, w, h);
                 x, y, x, y, w, h);
         }
         }
     }
     }
 
 
-    XSync(display, False);
+    X11_XSync(display, False);
 
 
     return 0;
     return 0;
 }
 }
@@ -237,8 +237,8 @@ X11_DestroyWindowFramebuffer(_THIS, SDL_Window * window)
 
 
 #ifndef NO_SHARED_MEMORY
 #ifndef NO_SHARED_MEMORY
         if (data->use_mitshm) {
         if (data->use_mitshm) {
-            XShmDetach(display, &data->shminfo);
-            XSync(display, False);
+            X11_XShmDetach(display, &data->shminfo);
+            X11_XSync(display, False);
             shmdt(data->shminfo.shmaddr);
             shmdt(data->shminfo.shmaddr);
             data->use_mitshm = SDL_FALSE;
             data->use_mitshm = SDL_FALSE;
         }
         }
@@ -247,7 +247,7 @@ X11_DestroyWindowFramebuffer(_THIS, SDL_Window * window)
         data->ximage = NULL;
         data->ximage = NULL;
     }
     }
     if (data->gc) {
     if (data->gc) {
-        XFreeGC(display, data->gc);
+        X11_XFreeGC(display, data->gc);
         data->gc = NULL;
         data->gc = NULL;
     }
     }
 }
 }

+ 7 - 7
src/video/x11/SDL_x11keyboard.c

@@ -152,7 +152,7 @@ X11_KeyCodeToSDLScancode(Display *display, KeyCode keycode)
     int i;
     int i;
 
 
 #if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM
 #if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM
-    keysym = XkbKeycodeToKeysym(display, keycode, 0, 0);
+    keysym = X11_XkbKeycodeToKeysym(display, keycode, 0, 0);
 #else
 #else
     keysym = XKeycodeToKeysym(display, keycode, 0);
     keysym = XKeycodeToKeysym(display, keycode, 0);
 #endif
 #endif
@@ -182,7 +182,7 @@ X11_KeyCodeToUcs4(Display *display, KeyCode keycode)
     KeySym keysym;
     KeySym keysym;
 
 
 #if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM
 #if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM
-    keysym = XkbKeycodeToKeysym(display, keycode, 0, 0);
+    keysym = X11_XkbKeycodeToKeysym(display, keycode, 0, 0);
 #else
 #else
     keysym = XKeycodeToKeysym(display, keycode, 0);
     keysym = XKeycodeToKeysym(display, keycode, 0);
 #endif
 #endif
@@ -211,14 +211,14 @@ X11_InitKeyboard(_THIS)
     };
     };
     SDL_bool fingerprint_detected;
     SDL_bool fingerprint_detected;
 
 
-    XAutoRepeatOn(data->display);
+    X11_XAutoRepeatOn(data->display);
 
 
     /* Try to determine which scancodes are being used based on fingerprint */
     /* Try to determine which scancodes are being used based on fingerprint */
     fingerprint_detected = SDL_FALSE;
     fingerprint_detected = SDL_FALSE;
-    XDisplayKeycodes(data->display, &min_keycode, &max_keycode);
+    X11_XDisplayKeycodes(data->display, &min_keycode, &max_keycode);
     for (i = 0; i < SDL_arraysize(fingerprint); ++i) {
     for (i = 0; i < SDL_arraysize(fingerprint); ++i) {
         fingerprint[i].value =
         fingerprint[i].value =
-            XKeysymToKeycode(data->display, fingerprint[i].keysym) -
+            X11_XKeysymToKeycode(data->display, fingerprint[i].keysym) -
             min_keycode;
             min_keycode;
     }
     }
     for (i = 0; i < SDL_arraysize(scancode_set); ++i) {
     for (i = 0; i < SDL_arraysize(scancode_set); ++i) {
@@ -258,14 +258,14 @@ X11_InitKeyboard(_THIS)
         for (i = min_keycode; i <= max_keycode; ++i) {
         for (i = min_keycode; i <= max_keycode; ++i) {
             KeySym sym;
             KeySym sym;
 #if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM
 #if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM
-            sym = XkbKeycodeToKeysym(data->display, i, 0, 0);
+            sym = X11_XkbKeycodeToKeysym(data->display, i, 0, 0);
 #else
 #else
             sym = XKeycodeToKeysym(data->display, i, 0);
             sym = XKeycodeToKeysym(data->display, i, 0);
 #endif
 #endif
             if (sym != NoSymbol) {
             if (sym != NoSymbol) {
                 SDL_Scancode scancode;
                 SDL_Scancode scancode;
                 printf("code = %d, sym = 0x%X (%s) ", i - min_keycode,
                 printf("code = %d, sym = 0x%X (%s) ", i - min_keycode,
-                       (unsigned int) sym, XKeysymToString(sym));
+                       (unsigned int) sym, X11_XKeysymToString(sym));
                 scancode = X11_KeyCodeToSDLScancode(data->display, i);
                 scancode = X11_KeyCodeToSDLScancode(data->display, i);
                 data->key_layout[i] = scancode;
                 data->key_layout[i] = scancode;
                 if (scancode == SDL_SCANCODE_UNKNOWN) {
                 if (scancode == SDL_SCANCODE_UNKNOWN) {

+ 45 - 45
src/video/x11/SDL_x11messagebox.c

@@ -124,13 +124,13 @@ GetTextWidthHeight( SDL_MessageBoxDataX11 *data, const char *str, int nbytes, in
 {
 {
     if (SDL_X11_HAVE_UTF8) {
     if (SDL_X11_HAVE_UTF8) {
         XRectangle overall_ink, overall_logical;
         XRectangle overall_ink, overall_logical;
-        Xutf8TextExtents(data->font_set, str, nbytes, &overall_ink, &overall_logical);
+        X11_Xutf8TextExtents(data->font_set, str, nbytes, &overall_ink, &overall_logical);
         *pwidth = overall_logical.width;
         *pwidth = overall_logical.width;
         *pheight = overall_logical.height;
         *pheight = overall_logical.height;
     } else {
     } else {
         XCharStruct text_structure;
         XCharStruct text_structure;
         int font_direction, font_ascent, font_descent;
         int font_direction, font_ascent, font_descent;
-        XTextExtents( data->font_struct, str, nbytes,
+        X11_XTextExtents( data->font_struct, str, nbytes,
                       &font_direction, &font_ascent, &font_descent,
                       &font_direction, &font_ascent, &font_descent,
                       &text_structure );
                       &text_structure );
         *pwidth = text_structure.width;
         *pwidth = text_structure.width;
@@ -180,7 +180,7 @@ X11_MessageBoxInit( SDL_MessageBoxDataX11 *data, const SDL_MessageBoxData * mess
     data->numbuttons = numbuttons;
     data->numbuttons = numbuttons;
     data->pbuttonid = pbuttonid;
     data->pbuttonid = pbuttonid;
 
 
-    data->display = XOpenDisplay( NULL );
+    data->display = X11_XOpenDisplay( NULL );
     if ( !data->display ) {
     if ( !data->display ) {
         return SDL_SetError("Couldn't open X11 display");
         return SDL_SetError("Couldn't open X11 display");
     }
     }
@@ -188,16 +188,16 @@ X11_MessageBoxInit( SDL_MessageBoxDataX11 *data, const SDL_MessageBoxData * mess
     if (SDL_X11_HAVE_UTF8) {
     if (SDL_X11_HAVE_UTF8) {
         char **missing = NULL;
         char **missing = NULL;
         int num_missing = 0;
         int num_missing = 0;
-        data->font_set = XCreateFontSet(data->display, g_MessageBoxFont,
+        data->font_set = X11_XCreateFontSet(data->display, g_MessageBoxFont,
                                         &missing, &num_missing, NULL);
                                         &missing, &num_missing, NULL);
         if ( missing != NULL ) {
         if ( missing != NULL ) {
-            XFreeStringList(missing);
+            X11_XFreeStringList(missing);
         }
         }
         if ( data->font_set == NULL ) {
         if ( data->font_set == NULL ) {
             return SDL_SetError("Couldn't load font %s", g_MessageBoxFont);
             return SDL_SetError("Couldn't load font %s", g_MessageBoxFont);
         }
         }
     } else {
     } else {
-        data->font_struct = XLoadQueryFont( data->display, g_MessageBoxFontLatin1 );
+        data->font_struct = X11_XLoadQueryFont( data->display, g_MessageBoxFontLatin1 );
         if ( data->font_struct == NULL ) {
         if ( data->font_struct == NULL ) {
             return SDL_SetError("Couldn't load font %s", g_MessageBoxFontLatin1);
             return SDL_SetError("Couldn't load font %s", g_MessageBoxFontLatin1);
         }
         }
@@ -338,23 +338,23 @@ static void
 X11_MessageBoxShutdown( SDL_MessageBoxDataX11 *data )
 X11_MessageBoxShutdown( SDL_MessageBoxDataX11 *data )
 {
 {
     if ( data->font_set != NULL ) {
     if ( data->font_set != NULL ) {
-        XFreeFontSet( data->display, data->font_set );
+        X11_XFreeFontSet( data->display, data->font_set );
         data->font_set = NULL;
         data->font_set = NULL;
     }
     }
 
 
     if ( data->font_struct != NULL ) {
     if ( data->font_struct != NULL ) {
-        XFreeFont( data->display, data->font_struct );
+        X11_XFreeFont( data->display, data->font_struct );
         data->font_struct = NULL;
         data->font_struct = NULL;
     }
     }
 
 
     if ( data->display ) {
     if ( data->display ) {
         if ( data->window != None ) {
         if ( data->window != None ) {
-            XWithdrawWindow( data->display, data->window, data->screen );
-            XDestroyWindow( data->display, data->window );
+            X11_XWithdrawWindow( data->display, data->window, data->screen );
+            X11_XDestroyWindow( data->display, data->window );
             data->window = None;
             data->window = None;
         }
         }
 
 
-        XCloseDisplay( data->display );
+        X11_XCloseDisplay( data->display );
         data->display = NULL;
         data->display = NULL;
     }
     }
 }
 }
@@ -384,7 +384,7 @@ X11_MessageBoxCreateWindow( SDL_MessageBoxDataX11 *data )
                        StructureNotifyMask | FocusChangeMask | PointerMotionMask;
                        StructureNotifyMask | FocusChangeMask | PointerMotionMask;
     wnd_attr.event_mask = data->event_mask;
     wnd_attr.event_mask = data->event_mask;
 
 
-    data->window = XCreateWindow(
+    data->window = X11_XCreateWindow(
                        display, RootWindow(display, data->screen),
                        display, RootWindow(display, data->screen),
                        0, 0,
                        0, 0,
                        data->dialog_width, data->dialog_height,
                        data->dialog_width, data->dialog_height,
@@ -396,31 +396,31 @@ X11_MessageBoxCreateWindow( SDL_MessageBoxDataX11 *data )
 
 
     if ( windowdata ) {
     if ( windowdata ) {
         /* http://tronche.com/gui/x/icccm/sec-4.html#WM_TRANSIENT_FOR */
         /* http://tronche.com/gui/x/icccm/sec-4.html#WM_TRANSIENT_FOR */
-        XSetTransientForHint( display, data->window, windowdata->xwindow );
+        X11_XSetTransientForHint( display, data->window, windowdata->xwindow );
     }
     }
 
 
-    XStoreName( display, data->window, messageboxdata->title );
+    X11_XStoreName( display, data->window, messageboxdata->title );
 
 
     /* Allow the window to be deleted by the window manager */
     /* Allow the window to be deleted by the window manager */
-    data->wm_protocols = XInternAtom( display, "WM_PROTOCOLS", False );
-    data->wm_delete_message = XInternAtom( display, "WM_DELETE_WINDOW", False );
-    XSetWMProtocols( display, data->window, &data->wm_delete_message, 1 );
+    data->wm_protocols = X11_XInternAtom( display, "WM_PROTOCOLS", False );
+    data->wm_delete_message = X11_XInternAtom( display, "WM_DELETE_WINDOW", False );
+    X11_XSetWMProtocols( display, data->window, &data->wm_delete_message, 1 );
 
 
     if ( windowdata ) {
     if ( windowdata ) {
         XWindowAttributes attrib;
         XWindowAttributes attrib;
         Window dummy;
         Window dummy;
 
 
-        XGetWindowAttributes(display, windowdata->xwindow, &attrib);
+        X11_XGetWindowAttributes(display, windowdata->xwindow, &attrib);
         x = attrib.x + ( attrib.width - data->dialog_width ) / 2;
         x = attrib.x + ( attrib.width - data->dialog_width ) / 2;
         y = attrib.y + ( attrib.height - data->dialog_height ) / 3 ;
         y = attrib.y + ( attrib.height - data->dialog_height ) / 3 ;
-        XTranslateCoordinates(display, windowdata->xwindow, RootWindow(display, data->screen), x, y, &x, &y, &dummy);
+        X11_XTranslateCoordinates(display, windowdata->xwindow, RootWindow(display, data->screen), x, y, &x, &y, &dummy);
     } else {
     } else {
         x = ( DisplayWidth( display, data->screen ) - data->dialog_width ) / 2;
         x = ( DisplayWidth( display, data->screen ) - data->dialog_width ) / 2;
         y = ( DisplayHeight( display, data->screen ) - data->dialog_height ) / 3 ;
         y = ( DisplayHeight( display, data->screen ) - data->dialog_height ) / 3 ;
     }
     }
-    XMoveWindow( display, data->window, x, y );
+    X11_XMoveWindow( display, data->window, x, y );
 
 
-    sizehints = XAllocSizeHints();
+    sizehints = X11_XAllocSizeHints();
     if ( sizehints ) {
     if ( sizehints ) {
         sizehints->flags = USPosition | USSize | PMaxSize | PMinSize;
         sizehints->flags = USPosition | USSize | PMaxSize | PMinSize;
         sizehints->x = x;
         sizehints->x = x;
@@ -431,12 +431,12 @@ X11_MessageBoxCreateWindow( SDL_MessageBoxDataX11 *data )
         sizehints->min_width = sizehints->max_width = data->dialog_width;
         sizehints->min_width = sizehints->max_width = data->dialog_width;
         sizehints->min_height = sizehints->max_height = data->dialog_height;
         sizehints->min_height = sizehints->max_height = data->dialog_height;
 
 
-        XSetWMNormalHints( display, data->window, sizehints );
+        X11_XSetWMNormalHints( display, data->window, sizehints );
 
 
-        XFree( sizehints );
+        X11_XFree( sizehints );
     }
     }
 
 
-    XMapRaised( display, data->window );
+    X11_XMapRaised( display, data->window );
     return 0;
     return 0;
 }
 }
 
 
@@ -448,19 +448,19 @@ X11_MessageBoxDraw( SDL_MessageBoxDataX11 *data, GC ctx )
     Window window = data->window;
     Window window = data->window;
     Display *display = data->display;
     Display *display = data->display;
 
 
-    XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_BACKGROUND ] );
-    XFillRectangle( display, window, ctx, 0, 0, data->dialog_width, data->dialog_height );
+    X11_XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_BACKGROUND ] );
+    X11_XFillRectangle( display, window, ctx, 0, 0, data->dialog_width, data->dialog_height );
 
 
-    XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_TEXT ] );
+    X11_XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_TEXT ] );
     for ( i = 0; i < data->numlines; i++ ) {
     for ( i = 0; i < data->numlines; i++ ) {
         TextLineData *plinedata = &data->linedata[ i ];
         TextLineData *plinedata = &data->linedata[ i ];
 
 
         if (SDL_X11_HAVE_UTF8) {
         if (SDL_X11_HAVE_UTF8) {
-            Xutf8DrawString( display, window, data->font_set, ctx,
+            X11_Xutf8DrawString( display, window, data->font_set, ctx,
                              data->xtext, data->ytext + i * data->text_height,
                              data->xtext, data->ytext + i * data->text_height,
                              plinedata->text, plinedata->length );
                              plinedata->text, plinedata->length );
         } else {
         } else {
-            XDrawString( display, window, ctx,
+            X11_XDrawString( display, window, ctx,
                          data->xtext, data->ytext + i * data->text_height,
                          data->xtext, data->ytext + i * data->text_height,
                          plinedata->text, plinedata->length );
                          plinedata->text, plinedata->length );
         }
         }
@@ -472,27 +472,27 @@ X11_MessageBoxDraw( SDL_MessageBoxDataX11 *data, GC ctx )
         int border = ( buttondata->flags & SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT ) ? 2 : 0;
         int border = ( buttondata->flags & SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT ) ? 2 : 0;
         int offset = ( ( data->mouse_over_index == i ) && ( data->button_press_index == data->mouse_over_index ) ) ? 1 : 0;
         int offset = ( ( data->mouse_over_index == i ) && ( data->button_press_index == data->mouse_over_index ) ) ? 1 : 0;
 
 
-        XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND ] );
-        XFillRectangle( display, window, ctx,
+        X11_XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND ] );
+        X11_XFillRectangle( display, window, ctx,
                         buttondatax11->rect.x - border, buttondatax11->rect.y - border,
                         buttondatax11->rect.x - border, buttondatax11->rect.y - border,
                         buttondatax11->rect.w + 2 * border, buttondatax11->rect.h + 2 * border );
                         buttondatax11->rect.w + 2 * border, buttondatax11->rect.h + 2 * border );
 
 
-        XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_BUTTON_BORDER ] );
-        XDrawRectangle( display, window, ctx,
+        X11_XSetForeground( display, ctx, data->color[ SDL_MESSAGEBOX_COLOR_BUTTON_BORDER ] );
+        X11_XDrawRectangle( display, window, ctx,
                         buttondatax11->rect.x, buttondatax11->rect.y,
                         buttondatax11->rect.x, buttondatax11->rect.y,
                         buttondatax11->rect.w, buttondatax11->rect.h );
                         buttondatax11->rect.w, buttondatax11->rect.h );
 
 
-        XSetForeground( display, ctx, ( data->mouse_over_index == i ) ?
+        X11_XSetForeground( display, ctx, ( data->mouse_over_index == i ) ?
                         data->color[ SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED ] :
                         data->color[ SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED ] :
                         data->color[ SDL_MESSAGEBOX_COLOR_TEXT ] );
                         data->color[ SDL_MESSAGEBOX_COLOR_TEXT ] );
 
 
         if (SDL_X11_HAVE_UTF8) {
         if (SDL_X11_HAVE_UTF8) {
-            Xutf8DrawString( display, window, data->font_set, ctx,
+            X11_Xutf8DrawString( display, window, data->font_set, ctx,
                              buttondatax11->x + offset,
                              buttondatax11->x + offset,
                              buttondatax11->y + offset,
                              buttondatax11->y + offset,
                              buttondata->text, buttondatax11->length );
                              buttondata->text, buttondatax11->length );
         } else {
         } else {
-            XDrawString( display, window, ctx,
+            X11_XDrawString( display, window, ctx,
                          buttondatax11->x + offset, buttondatax11->y + offset,
                          buttondatax11->x + offset, buttondatax11->y + offset,
                          buttondata->text, buttondatax11->length );
                          buttondata->text, buttondatax11->length );
         }
         }
@@ -519,7 +519,7 @@ X11_MessageBoxLoop( SDL_MessageBoxDataX11 *data )
         ctx_vals.font = data->font_struct->fid;
         ctx_vals.font = data->font_struct->fid;
     }
     }
 
 
-    ctx = XCreateGC( data->display, data->window, gcflags, &ctx_vals );
+    ctx = X11_XCreateGC( data->display, data->window, gcflags, &ctx_vals );
     if ( ctx == None ) {
     if ( ctx == None ) {
         return SDL_SetError("Couldn't create graphics context");
         return SDL_SetError("Couldn't create graphics context");
     }
     }
@@ -531,11 +531,11 @@ X11_MessageBoxLoop( SDL_MessageBoxDataX11 *data )
         XEvent e;
         XEvent e;
         SDL_bool draw = SDL_TRUE;
         SDL_bool draw = SDL_TRUE;
 
 
-        XWindowEvent( data->display, data->window, data->event_mask, &e );
+        X11_XWindowEvent( data->display, data->window, data->event_mask, &e );
 
 
-        /* If XFilterEvent returns True, then some input method has filtered the
+        /* If X11_XFilterEvent returns True, then some input method has filtered the
            event, and the client should discard the event. */
            event, and the client should discard the event. */
-        if ( ( e.type != Expose ) && XFilterEvent( &e, None ) )
+        if ( ( e.type != Expose ) && X11_XFilterEvent( &e, None ) )
             continue;
             continue;
 
 
         switch( e.type ) {
         switch( e.type ) {
@@ -574,12 +574,12 @@ X11_MessageBoxLoop( SDL_MessageBoxDataX11 *data )
 
 
         case KeyPress:
         case KeyPress:
             /* Store key press - we make sure in key release that we got both. */
             /* Store key press - we make sure in key release that we got both. */
-            last_key_pressed = XLookupKeysym( &e.xkey, 0 );
+            last_key_pressed = X11_XLookupKeysym( &e.xkey, 0 );
             break;
             break;
 
 
         case KeyRelease: {
         case KeyRelease: {
             Uint32 mask = 0;
             Uint32 mask = 0;
-            KeySym key = XLookupKeysym( &e.xkey, 0 );
+            KeySym key = X11_XLookupKeysym( &e.xkey, 0 );
 
 
             /* If this is a key release for something we didn't get the key down for, then bail. */
             /* If this is a key release for something we didn't get the key down for, then bail. */
             if ( key != last_key_pressed )
             if ( key != last_key_pressed )
@@ -637,7 +637,7 @@ X11_MessageBoxLoop( SDL_MessageBoxDataX11 *data )
         }
         }
     }
     }
 
 
-    XFreeGC( data->display, ctx );
+    X11_XFreeGC( data->display, ctx );
     return 0;
     return 0;
 }
 }
 
 
@@ -667,7 +667,7 @@ X11_ShowMessageBoxImpl(const SDL_MessageBoxData *messageboxdata, int *buttonid)
 #endif
 #endif
 
 
     /* This code could get called from multiple threads maybe? */
     /* This code could get called from multiple threads maybe? */
-    XInitThreads();
+    X11_XInitThreads();
 
 
     /* Initialize the return buttonid value to -1 (for error or dialogbox closed). */
     /* Initialize the return buttonid value to -1 (for error or dialogbox closed). */
     *buttonid = -1;
     *buttonid = -1;
@@ -707,7 +707,7 @@ X11_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
     int status = 0;
     int status = 0;
 
 
     /* Need to flush here in case someone has turned grab off and it hasn't gone through yet, etc. */
     /* Need to flush here in case someone has turned grab off and it hasn't gone through yet, etc. */
-    XFlush(data->display);
+    X11_XFlush(data->display);
 
 
     if (pipe(fds) == -1) {
     if (pipe(fds) == -1) {
         return X11_ShowMessageBoxImpl(messageboxdata, buttonid); /* oh well. */
         return X11_ShowMessageBoxImpl(messageboxdata, buttonid); /* oh well. */

+ 58 - 58
src/video/x11/SDL_x11modes.c

@@ -54,20 +54,20 @@ get_visualinfo(Display * display, int screen, XVisualInfo * vinfo)
 
 
         SDL_zero(template);
         SDL_zero(template);
         template.visualid = SDL_strtol(visual_id, NULL, 0);
         template.visualid = SDL_strtol(visual_id, NULL, 0);
-        vi = XGetVisualInfo(display, VisualIDMask, &template, &nvis);
+        vi = X11_XGetVisualInfo(display, VisualIDMask, &template, &nvis);
         if (vi) {
         if (vi) {
             *vinfo = *vi;
             *vinfo = *vi;
-            XFree(vi);
+            X11_XFree(vi);
             return 0;
             return 0;
         }
         }
     }
     }
 
 
     depth = DefaultDepth(display, screen);
     depth = DefaultDepth(display, screen);
     if ((X11_UseDirectColorVisuals() &&
     if ((X11_UseDirectColorVisuals() &&
-         XMatchVisualInfo(display, screen, depth, DirectColor, vinfo)) ||
-        XMatchVisualInfo(display, screen, depth, TrueColor, vinfo) ||
-        XMatchVisualInfo(display, screen, depth, PseudoColor, vinfo) ||
-        XMatchVisualInfo(display, screen, depth, StaticColor, vinfo)) {
+         X11_XMatchVisualInfo(display, screen, depth, DirectColor, vinfo)) ||
+        X11_XMatchVisualInfo(display, screen, depth, TrueColor, vinfo) ||
+        X11_XMatchVisualInfo(display, screen, depth, PseudoColor, vinfo) ||
+        X11_XMatchVisualInfo(display, screen, depth, StaticColor, vinfo)) {
         return 0;
         return 0;
     }
     }
     return -1;
     return -1;
@@ -79,11 +79,11 @@ X11_GetVisualInfoFromVisual(Display * display, Visual * visual, XVisualInfo * vi
     XVisualInfo *vi;
     XVisualInfo *vi;
     int nvis;
     int nvis;
 
 
-    vinfo->visualid = XVisualIDFromVisual(visual);
-    vi = XGetVisualInfo(display, VisualIDMask, vinfo, &nvis);
+    vinfo->visualid = X11_XVisualIDFromVisual(visual);
+    vi = X11_XGetVisualInfo(display, VisualIDMask, vinfo, &nvis);
     if (vi) {
     if (vi) {
         *vinfo = *vi;
         *vinfo = *vi;
-        XFree(vi);
+        X11_XFree(vi);
         return 0;
         return 0;
     }
     }
     return -1;
     return -1;
@@ -108,7 +108,7 @@ X11_GetPixelFormatFromVisualInfo(Display * display, XVisualInfo * vinfo)
         bpp = vinfo->depth;
         bpp = vinfo->depth;
         if (bpp == 24) {
         if (bpp == 24) {
             int i, n;
             int i, n;
-            XPixmapFormatValues *p = XListPixmapFormats(display, &n);
+            XPixmapFormatValues *p = X11_XListPixmapFormats(display, &n);
             if (p) {
             if (p) {
                 for (i = 0; i < n; ++i) {
                 for (i = 0; i < n; ++i) {
                     if (p[i].depth == 24) {
                     if (p[i].depth == 24) {
@@ -116,7 +116,7 @@ X11_GetPixelFormatFromVisualInfo(Display * display, XVisualInfo * vinfo)
                         break;
                         break;
                     }
                     }
                 }
                 }
-                XFree(p);
+                X11_XFree(p);
             }
             }
         }
         }
 
 
@@ -178,9 +178,9 @@ CheckXinerama(Display * display, int *major, int *minor)
     }
     }
 
 
     /* Query the extension version */
     /* Query the extension version */
-    if (!XineramaQueryExtension(display, &event_base, &error_base) ||
-        !XineramaQueryVersion(display, major, minor) ||
-        !XineramaIsActive(display)) {
+    if (!X11_XineramaQueryExtension(display, &event_base, &error_base) ||
+        !X11_XineramaQueryVersion(display, major, minor) ||
+        !X11_XineramaIsActive(display)) {
 #ifdef X11MODES_DEBUG
 #ifdef X11MODES_DEBUG
         printf("Xinerama not active on the display\n");
         printf("Xinerama not active on the display\n");
 #endif
 #endif
@@ -228,7 +228,7 @@ CheckXRandR(Display * display, int *major, int *minor)
     }
     }
 
 
     /* Query the extension version */
     /* Query the extension version */
-    if (!XRRQueryVersion(display, major, minor)) {
+    if (!X11_XRRQueryVersion(display, major, minor)) {
 #ifdef X11MODES_DEBUG
 #ifdef X11MODES_DEBUG
         printf("XRandR not active on the display\n");
         printf("XRandR not active on the display\n");
 #endif
 #endif
@@ -261,10 +261,10 @@ SetXRandRModeInfo(Display *display, XRRScreenResources *res, XRROutputInfo *outp
             Rotation rotation = 0;
             Rotation rotation = 0;
             const XRRModeInfo *info = &res->modes[i];
             const XRRModeInfo *info = &res->modes[i];
 
 
-            crtc = XRRGetCrtcInfo(display, res, output_info->crtc);
+            crtc = X11_XRRGetCrtcInfo(display, res, output_info->crtc);
             if (crtc) {
             if (crtc) {
                 rotation = crtc->rotation;
                 rotation = crtc->rotation;
-                XRRFreeCrtcInfo(crtc);
+                X11_XRRFreeCrtcInfo(crtc);
             }
             }
 
 
             if (rotation & (XRANDR_ROTATION_LEFT|XRANDR_ROTATION_RIGHT)) {
             if (rotation & (XRANDR_ROTATION_LEFT|XRANDR_ROTATION_RIGHT)) {
@@ -313,8 +313,8 @@ CheckVidMode(Display * display, int *major, int *minor)
 
 
     /* Query the extension version */
     /* Query the extension version */
     vm_error = -1;
     vm_error = -1;
-    if (!XF86VidModeQueryExtension(display, &vm_event, &vm_error)
-        || !XF86VidModeQueryVersion(display, major, minor)) {
+    if (!X11_XF86VidModeQueryExtension(display, &vm_event, &vm_error)
+        || !X11_XF86VidModeQueryVersion(display, major, minor)) {
 #ifdef X11MODES_DEBUG
 #ifdef X11MODES_DEBUG
         printf("XVidMode not active on the display\n");
         printf("XVidMode not active on the display\n");
 #endif
 #endif
@@ -335,7 +335,7 @@ Bool XF86VidModeGetModeInfo(Display * dpy, int scr,
     XF86VidModeModeLine l;
     XF86VidModeModeLine l;
     SDL_zerop(info);
     SDL_zerop(info);
     SDL_zero(l);
     SDL_zero(l);
-    retval = XF86VidModeGetModeLine(dpy, scr, &dotclock, &l);
+    retval = X11_XF86VidModeGetModeLine(dpy, scr, &dotclock, &l);
     info->dotclock = dotclock;
     info->dotclock = dotclock;
     info->hdisplay = l.hdisplay;
     info->hdisplay = l.hdisplay;
     info->hsyncstart = l.hsyncstart;
     info->hsyncstart = l.hsyncstart;
@@ -397,7 +397,7 @@ X11_InitModes(_THIS)
      *       or newer of the Nvidia binary drivers
      *       or newer of the Nvidia binary drivers
      */
      */
     if (CheckXinerama(data->display, &xinerama_major, &xinerama_minor)) {
     if (CheckXinerama(data->display, &xinerama_major, &xinerama_minor)) {
-        xinerama = XineramaQueryScreens(data->display, &screencount);
+        xinerama = X11_XineramaQueryScreens(data->display, &screencount);
         if (xinerama) {
         if (xinerama) {
             use_xinerama = xinerama_major * 100 + xinerama_minor;
             use_xinerama = xinerama_major * 100 + xinerama_minor;
         }
         }
@@ -501,7 +501,7 @@ X11_InitModes(_THIS)
         displaydata->depth = vinfo.depth;
         displaydata->depth = vinfo.depth;
 
 
         displaydata->scanline_pad = SDL_BYTESPERPIXEL(mode.format) * 8;
         displaydata->scanline_pad = SDL_BYTESPERPIXEL(mode.format) * 8;
-        pixmapFormats = XListPixmapFormats(data->display, &n);
+        pixmapFormats = X11_XListPixmapFormats(data->display, &n);
         if (pixmapFormats) {
         if (pixmapFormats) {
             for (i = 0; i < n; ++i) {
             for (i = 0; i < n; ++i) {
                 if (pixmapFormats[i].depth == displaydata->depth) {
                 if (pixmapFormats[i].depth == displaydata->depth) {
@@ -509,7 +509,7 @@ X11_InitModes(_THIS)
                     break;
                     break;
                 }
                 }
             }
             }
-            XFree(pixmapFormats);
+            X11_XFree(pixmapFormats);
         }
         }
 
 
 #if SDL_VIDEO_DRIVER_X11_XINERAMA
 #if SDL_VIDEO_DRIVER_X11_XINERAMA
@@ -526,13 +526,13 @@ X11_InitModes(_THIS)
 
 
 #if SDL_VIDEO_DRIVER_X11_XRANDR
 #if SDL_VIDEO_DRIVER_X11_XRANDR
         if (use_xrandr) {
         if (use_xrandr) {
-            res = XRRGetScreenResources(data->display, RootWindow(data->display, displaydata->screen));
+            res = X11_XRRGetScreenResources(data->display, RootWindow(data->display, displaydata->screen));
         }
         }
         if (res) {
         if (res) {
             XRROutputInfo *output_info;
             XRROutputInfo *output_info;
             XRRCrtcInfo *crtc;
             XRRCrtcInfo *crtc;
             int output;
             int output;
-            Atom EDID = XInternAtom(data->display, "EDID", False);
+            Atom EDID = X11_XInternAtom(data->display, "EDID", False);
             Atom *props;
             Atom *props;
             int nprop;
             int nprop;
             unsigned long width_mm;
             unsigned long width_mm;
@@ -540,10 +540,10 @@ X11_InitModes(_THIS)
             int inches = 0;
             int inches = 0;
 
 
             for (output = 0; output < res->noutput; output++) {
             for (output = 0; output < res->noutput; output++) {
-                output_info = XRRGetOutputInfo(data->display, res, res->outputs[output]);
+                output_info = X11_XRRGetOutputInfo(data->display, res, res->outputs[output]);
                 if (!output_info || !output_info->crtc ||
                 if (!output_info || !output_info->crtc ||
                     output_info->connection == RR_Disconnected) {
                     output_info->connection == RR_Disconnected) {
-                    XRRFreeOutputInfo(output_info);
+                    X11_XRRFreeOutputInfo(output_info);
                     continue;
                     continue;
                 }
                 }
 
 
@@ -551,10 +551,10 @@ X11_InitModes(_THIS)
                    We're checking the crtc position, but that may not be a valid test
                    We're checking the crtc position, but that may not be a valid test
                    in all cases.  Anybody want to give this some love?
                    in all cases.  Anybody want to give this some love?
                  */
                  */
-                crtc = XRRGetCrtcInfo(data->display, res, output_info->crtc);
+                crtc = X11_XRRGetCrtcInfo(data->display, res, output_info->crtc);
                 if (!crtc || crtc->x != displaydata->x || crtc->y != displaydata->y) {
                 if (!crtc || crtc->x != displaydata->x || crtc->y != displaydata->y) {
-                    XRRFreeOutputInfo(output_info);
-                    XRRFreeCrtcInfo(crtc);
+                    X11_XRRFreeOutputInfo(output_info);
+                    X11_XRRFreeCrtcInfo(crtc);
                     continue;
                     continue;
                 }
                 }
 
 
@@ -570,7 +570,7 @@ X11_InitModes(_THIS)
                 SDL_strlcpy(display_name, output_info->name, sizeof(display_name));
                 SDL_strlcpy(display_name, output_info->name, sizeof(display_name));
 
 
                 /* See if we can get the EDID data for the real monitor name */
                 /* See if we can get the EDID data for the real monitor name */
-                props = XRRListOutputProperties(data->display, res->outputs[output], &nprop);
+                props = X11_XRRListOutputProperties(data->display, res->outputs[output], &nprop);
                 for (i = 0; i < nprop; ++i) {
                 for (i = 0; i < nprop; ++i) {
                     unsigned char *prop;
                     unsigned char *prop;
                     int actual_format;
                     int actual_format;
@@ -578,7 +578,7 @@ X11_InitModes(_THIS)
                     Atom actual_type;
                     Atom actual_type;
 
 
                     if (props[i] == EDID) {
                     if (props[i] == EDID) {
-                        if (XRRGetOutputProperty(data->display,
+                        if (X11_XRRGetOutputProperty(data->display,
                                                  res->outputs[output], props[i],
                                                  res->outputs[output], props[i],
                                                  0, 100, False, False,
                                                  0, 100, False, False,
                                                  AnyPropertyType,
                                                  AnyPropertyType,
@@ -593,13 +593,13 @@ X11_InitModes(_THIS)
                                 SDL_strlcpy(display_name, info->dsc_product_name, sizeof(display_name));
                                 SDL_strlcpy(display_name, info->dsc_product_name, sizeof(display_name));
                                 free(info);
                                 free(info);
                             }
                             }
-                            XFree(prop);
+                            X11_XFree(prop);
                         }
                         }
                         break;
                         break;
                     }
                     }
                 }
                 }
                 if (props) {
                 if (props) {
-                    XFree(props);
+                    X11_XFree(props);
                 }
                 }
 
 
                 if (*display_name && inches) {
                 if (*display_name && inches) {
@@ -610,8 +610,8 @@ X11_InitModes(_THIS)
                 printf("Display name: %s\n", display_name);
                 printf("Display name: %s\n", display_name);
 #endif
 #endif
 
 
-                XRRFreeOutputInfo(output_info);
-                XRRFreeCrtcInfo(crtc);
+                X11_XRRFreeOutputInfo(output_info);
+                X11_XRRFreeCrtcInfo(crtc);
                 break;
                 break;
             }
             }
 #ifdef X11MODES_DEBUG
 #ifdef X11MODES_DEBUG
@@ -619,7 +619,7 @@ X11_InitModes(_THIS)
                 printf("Couldn't find XRandR CRTC at %d,%d\n", displaydata->x, displaydata->y);
                 printf("Couldn't find XRandR CRTC at %d,%d\n", displaydata->x, displaydata->y);
             }
             }
 #endif
 #endif
-            XRRFreeScreenResources(res);
+            X11_XRRFreeScreenResources(res);
         }
         }
 #endif /* SDL_VIDEO_DRIVER_X11_XRANDR */
 #endif /* SDL_VIDEO_DRIVER_X11_XRANDR */
 
 
@@ -652,7 +652,7 @@ X11_InitModes(_THIS)
     }
     }
 
 
 #if SDL_VIDEO_DRIVER_X11_XINERAMA
 #if SDL_VIDEO_DRIVER_X11_XINERAMA
-    if (xinerama) XFree(xinerama);
+    if (xinerama) X11_XFree(xinerama);
 #endif
 #endif
 
 
     if (_this->num_displays == 0) {
     if (_this->num_displays == 0) {
@@ -725,13 +725,13 @@ X11_GetDisplayModes(_THIS, SDL_VideoDisplay * sdl_display)
     if (data->use_xrandr) {
     if (data->use_xrandr) {
         XRRScreenResources *res;
         XRRScreenResources *res;
 
 
-        res = XRRGetScreenResources (display, RootWindow(display, data->screen));
+        res = X11_XRRGetScreenResources (display, RootWindow(display, data->screen));
         if (res) {
         if (res) {
             SDL_DisplayModeData *modedata;
             SDL_DisplayModeData *modedata;
             XRROutputInfo *output_info;
             XRROutputInfo *output_info;
             int i;
             int i;
 
 
-            output_info = XRRGetOutputInfo(display, res, data->xrandr_output);
+            output_info = X11_XRRGetOutputInfo(display, res, data->xrandr_output);
             if (output_info && output_info->connection != RR_Disconnected) {
             if (output_info && output_info->connection != RR_Disconnected) {
                 for (i = 0; i < output_info->nmode; ++i) {
                 for (i = 0; i < output_info->nmode; ++i) {
                     modedata = (SDL_DisplayModeData *) SDL_calloc(1, sizeof(SDL_DisplayModeData));
                     modedata = (SDL_DisplayModeData *) SDL_calloc(1, sizeof(SDL_DisplayModeData));
@@ -747,8 +747,8 @@ X11_GetDisplayModes(_THIS, SDL_VideoDisplay * sdl_display)
                     }
                     }
                 }
                 }
             }
             }
-            XRRFreeOutputInfo(output_info);
-            XRRFreeScreenResources(res);
+            X11_XRRFreeOutputInfo(output_info);
+            X11_XRRFreeScreenResources(res);
         }
         }
         return;
         return;
     }
     }
@@ -756,7 +756,7 @@ X11_GetDisplayModes(_THIS, SDL_VideoDisplay * sdl_display)
 
 
 #if SDL_VIDEO_DRIVER_X11_XVIDMODE
 #if SDL_VIDEO_DRIVER_X11_XVIDMODE
     if (data->use_vidmode &&
     if (data->use_vidmode &&
-        XF86VidModeGetAllModeLines(display, data->vidmode_screen, &nmodes, &modes)) {
+        X11_XF86VidModeGetAllModeLines(display, data->vidmode_screen, &nmodes, &modes)) {
         int i;
         int i;
 
 
 #ifdef X11MODES_DEBUG
 #ifdef X11MODES_DEBUG
@@ -780,7 +780,7 @@ X11_GetDisplayModes(_THIS, SDL_VideoDisplay * sdl_display)
                 SDL_free(modedata);
                 SDL_free(modedata);
             }
             }
         }
         }
-        XFree(modes);
+        X11_XFree(modes);
         return;
         return;
     }
     }
 #endif /* SDL_VIDEO_DRIVER_X11_XVIDMODE */
 #endif /* SDL_VIDEO_DRIVER_X11_XVIDMODE */
@@ -811,41 +811,41 @@ X11_SetDisplayMode(_THIS, SDL_VideoDisplay * sdl_display, SDL_DisplayMode * mode
         XRRCrtcInfo *crtc;
         XRRCrtcInfo *crtc;
         Status status;
         Status status;
 
 
-        res = XRRGetScreenResources (display, RootWindow(display, data->screen));
+        res = X11_XRRGetScreenResources (display, RootWindow(display, data->screen));
         if (!res) {
         if (!res) {
             return SDL_SetError("Couldn't get XRandR screen resources");
             return SDL_SetError("Couldn't get XRandR screen resources");
         }
         }
 
 
-        output_info = XRRGetOutputInfo(display, res, data->xrandr_output);
+        output_info = X11_XRRGetOutputInfo(display, res, data->xrandr_output);
         if (!output_info || output_info->connection == RR_Disconnected) {
         if (!output_info || output_info->connection == RR_Disconnected) {
-            XRRFreeScreenResources(res);
+            X11_XRRFreeScreenResources(res);
             return SDL_SetError("Couldn't get XRandR output info");
             return SDL_SetError("Couldn't get XRandR output info");
         }
         }
 
 
-        crtc = XRRGetCrtcInfo(display, res, output_info->crtc);
+        crtc = X11_XRRGetCrtcInfo(display, res, output_info->crtc);
         if (!crtc) {
         if (!crtc) {
-            XRRFreeOutputInfo(output_info);
-            XRRFreeScreenResources(res);
+            X11_XRRFreeOutputInfo(output_info);
+            X11_XRRFreeScreenResources(res);
             return SDL_SetError("Couldn't get XRandR crtc info");
             return SDL_SetError("Couldn't get XRandR crtc info");
         }
         }
 
 
-        status = XRRSetCrtcConfig (display, res, output_info->crtc, CurrentTime,
+        status = X11_XRRSetCrtcConfig (display, res, output_info->crtc, CurrentTime,
           crtc->x, crtc->y, modedata->xrandr_mode, crtc->rotation,
           crtc->x, crtc->y, modedata->xrandr_mode, crtc->rotation,
           &data->xrandr_output, 1);
           &data->xrandr_output, 1);
 
 
-        XRRFreeCrtcInfo(crtc);
-        XRRFreeOutputInfo(output_info);
-        XRRFreeScreenResources(res);
+        X11_XRRFreeCrtcInfo(crtc);
+        X11_XRRFreeOutputInfo(output_info);
+        X11_XRRFreeScreenResources(res);
 
 
         if (status != Success) {
         if (status != Success) {
-            return SDL_SetError("XRRSetCrtcConfig failed");
+            return SDL_SetError("X11_XRRSetCrtcConfig failed");
         }
         }
     }
     }
 #endif /* SDL_VIDEO_DRIVER_X11_XRANDR */
 #endif /* SDL_VIDEO_DRIVER_X11_XRANDR */
 
 
 #if SDL_VIDEO_DRIVER_X11_XVIDMODE
 #if SDL_VIDEO_DRIVER_X11_XVIDMODE
     if (data->use_vidmode) {
     if (data->use_vidmode) {
-        XF86VidModeSwitchToMode(display, data->vidmode_screen, &modedata->vm_mode);
+        X11_XF86VidModeSwitchToMode(display, data->vidmode_screen, &modedata->vm_mode);
     }
     }
 #endif /* SDL_VIDEO_DRIVER_X11_XVIDMODE */
 #endif /* SDL_VIDEO_DRIVER_X11_XVIDMODE */
 
 
@@ -872,11 +872,11 @@ X11_GetDisplayBounds(_THIS, SDL_VideoDisplay * sdl_display, SDL_Rect * rect)
     if (data->use_xinerama) {
     if (data->use_xinerama) {
         Display *display = ((SDL_VideoData *) _this->driverdata)->display;
         Display *display = ((SDL_VideoData *) _this->driverdata)->display;
         int screencount;
         int screencount;
-        XineramaScreenInfo *xinerama = XineramaQueryScreens(display, &screencount);
+        XineramaScreenInfo *xinerama = X11_XineramaQueryScreens(display, &screencount);
         if (xinerama) {
         if (xinerama) {
             rect->x = xinerama[data->xinerama_screen].x_org;
             rect->x = xinerama[data->xinerama_screen].x_org;
             rect->y = xinerama[data->xinerama_screen].y_org;
             rect->y = xinerama[data->xinerama_screen].y_org;
-            XFree(xinerama);
+            X11_XFree(xinerama);
         }
         }
     }
     }
 #endif /* SDL_VIDEO_DRIVER_X11_XINERAMA */
 #endif /* SDL_VIDEO_DRIVER_X11_XINERAMA */

+ 19 - 19
src/video/x11/SDL_x11mouse.c

@@ -50,12 +50,12 @@ X11_CreateEmptyCursor()
 
 
         SDL_zero(data);
         SDL_zero(data);
         color.red = color.green = color.blue = 0;
         color.red = color.green = color.blue = 0;
-        pixmap = XCreateBitmapFromData(display, DefaultRootWindow(display),
+        pixmap = X11_XCreateBitmapFromData(display, DefaultRootWindow(display),
                                        data, 1, 1);
                                        data, 1, 1);
         if (pixmap) {
         if (pixmap) {
-            x11_empty_cursor = XCreatePixmapCursor(display, pixmap, pixmap,
+            x11_empty_cursor = X11_XCreatePixmapCursor(display, pixmap, pixmap,
                                                    &color, &color, 0, 0);
                                                    &color, &color, 0, 0);
-            XFreePixmap(display, pixmap);
+            X11_XFreePixmap(display, pixmap);
         }
         }
     }
     }
     return x11_empty_cursor;
     return x11_empty_cursor;
@@ -65,7 +65,7 @@ static void
 X11_DestroyEmptyCursor(void)
 X11_DestroyEmptyCursor(void)
 {
 {
     if (x11_empty_cursor != None) {
     if (x11_empty_cursor != None) {
-        XFreeCursor(GetDisplay(), x11_empty_cursor);
+        X11_XFreeCursor(GetDisplay(), x11_empty_cursor);
         x11_empty_cursor = None;
         x11_empty_cursor = None;
     }
     }
 }
 }
@@ -94,7 +94,7 @@ X11_CreateXCursorCursor(SDL_Surface * surface, int hot_x, int hot_y)
     Cursor cursor = None;
     Cursor cursor = None;
     XcursorImage *image;
     XcursorImage *image;
 
 
-    image = XcursorImageCreate(surface->w, surface->h);
+    image = X11_XcursorImageCreate(surface->w, surface->h);
     if (!image) {
     if (!image) {
         SDL_OutOfMemory();
         SDL_OutOfMemory();
         return None;
         return None;
@@ -107,9 +107,9 @@ X11_CreateXCursorCursor(SDL_Surface * surface, int hot_x, int hot_y)
     SDL_assert(surface->pitch == surface->w * 4);
     SDL_assert(surface->pitch == surface->w * 4);
     SDL_memcpy(image->pixels, surface->pixels, surface->h * surface->pitch);
     SDL_memcpy(image->pixels, surface->pixels, surface->h * surface->pitch);
 
 
-    cursor = XcursorImageLoadCursor(display, image);
+    cursor = X11_XcursorImageLoadCursor(display, image);
 
 
-    XcursorImageDestroy(image);
+    X11_XcursorImageDestroy(image);
 
 
     return cursor;
     return cursor;
 }
 }
@@ -186,16 +186,16 @@ X11_CreatePixmapCursor(SDL_Surface * surface, int hot_x, int hot_y)
     }
     }
     else bg.red = bg.green = bg.blue = 0;
     else bg.red = bg.green = bg.blue = 0;
 
 
-    data_pixmap = XCreateBitmapFromData(display, DefaultRootWindow(display),
+    data_pixmap = X11_XCreateBitmapFromData(display, DefaultRootWindow(display),
                                         (char*)data_bits,
                                         (char*)data_bits,
                                         surface->w, surface->h);
                                         surface->w, surface->h);
-    mask_pixmap = XCreateBitmapFromData(display, DefaultRootWindow(display),
+    mask_pixmap = X11_XCreateBitmapFromData(display, DefaultRootWindow(display),
                                         (char*)mask_bits,
                                         (char*)mask_bits,
                                         surface->w, surface->h);
                                         surface->w, surface->h);
-    cursor = XCreatePixmapCursor(display, data_pixmap, mask_pixmap,
+    cursor = X11_XCreatePixmapCursor(display, data_pixmap, mask_pixmap,
                                  &fg, &bg, hot_x, hot_y);
                                  &fg, &bg, hot_x, hot_y);
-    XFreePixmap(display, data_pixmap);
-    XFreePixmap(display, mask_pixmap);
+    X11_XFreePixmap(display, data_pixmap);
+    X11_XFreePixmap(display, mask_pixmap);
 
 
     return cursor;
     return cursor;
 }
 }
@@ -256,7 +256,7 @@ X11_CreateSystemCursor(SDL_SystemCursor id)
     if (cursor) {
     if (cursor) {
         Cursor x11_cursor;
         Cursor x11_cursor;
 
 
-        x11_cursor = XCreateFontCursor(GetDisplay(), shape);
+        x11_cursor = X11_XCreateFontCursor(GetDisplay(), shape);
 
 
         cursor->driverdata = (void*)x11_cursor;
         cursor->driverdata = (void*)x11_cursor;
     } else {
     } else {
@@ -272,7 +272,7 @@ X11_FreeCursor(SDL_Cursor * cursor)
     Cursor x11_cursor = (Cursor)cursor->driverdata;
     Cursor x11_cursor = (Cursor)cursor->driverdata;
 
 
     if (x11_cursor != None) {
     if (x11_cursor != None) {
-        XFreeCursor(GetDisplay(), x11_cursor);
+        X11_XFreeCursor(GetDisplay(), x11_cursor);
     }
     }
     SDL_free(cursor);
     SDL_free(cursor);
 }
 }
@@ -298,12 +298,12 @@ X11_ShowCursor(SDL_Cursor * cursor)
         for (window = video->windows; window; window = window->next) {
         for (window = video->windows; window; window = window->next) {
             data = (SDL_WindowData *)window->driverdata;
             data = (SDL_WindowData *)window->driverdata;
             if (x11_cursor != None) {
             if (x11_cursor != None) {
-                XDefineCursor(display, data->xwindow, x11_cursor);
+                X11_XDefineCursor(display, data->xwindow, x11_cursor);
             } else {
             } else {
-                XUndefineCursor(display, data->xwindow);
+                X11_XUndefineCursor(display, data->xwindow);
             }
             }
         }
         }
-        XFlush(display);
+        X11_XFlush(display);
     }
     }
     return 0;
     return 0;
 }
 }
@@ -314,8 +314,8 @@ X11_WarpMouse(SDL_Window * window, int x, int y)
     SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
     SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
     Display *display = data->videodata->display;
     Display *display = data->videodata->display;
 
 
-    XWarpPointer(display, None, data->xwindow, 0, 0, 0, 0, x, y);
-    XSync(display, False);
+    X11_XWarpPointer(display, None, data->xwindow, 0, 0, 0, 0, x, y);
+    X11_XSync(display, False);
 }
 }
 
 
 static int
 static int

+ 13 - 13
src/video/x11/SDL_x11opengl.c

@@ -320,16 +320,16 @@ X11_GL_InitExtensions(_THIS)
     xattr.background_pixel = 0;
     xattr.background_pixel = 0;
     xattr.border_pixel = 0;
     xattr.border_pixel = 0;
     xattr.colormap =
     xattr.colormap =
-        XCreateColormap(display, RootWindow(display, screen), vinfo->visual,
+        X11_XCreateColormap(display, RootWindow(display, screen), vinfo->visual,
                         AllocNone);
                         AllocNone);
-    w = XCreateWindow(display, RootWindow(display, screen), 0, 0, 32, 32, 0,
+    w = X11_XCreateWindow(display, RootWindow(display, screen), 0, 0, 32, 32, 0,
                       vinfo->depth, InputOutput, vinfo->visual,
                       vinfo->depth, InputOutput, vinfo->visual,
                       (CWBackPixel | CWBorderPixel | CWColormap), &xattr);
                       (CWBackPixel | CWBorderPixel | CWColormap), &xattr);
     context = _this->gl_data->glXCreateContext(display, vinfo, NULL, True);
     context = _this->gl_data->glXCreateContext(display, vinfo, NULL, True);
     if (context) {
     if (context) {
         _this->gl_data->glXMakeCurrent(display, w, context);
         _this->gl_data->glXMakeCurrent(display, w, context);
     }
     }
-    XFree(vinfo);
+    X11_XFree(vinfo);
 
 
     glXQueryExtensionsStringFunc =
     glXQueryExtensionsStringFunc =
         (const char *(*)(Display *, int)) X11_GL_GetProcAddress(_this,
         (const char *(*)(Display *, int)) X11_GL_GetProcAddress(_this,
@@ -385,7 +385,7 @@ X11_GL_InitExtensions(_THIS)
         _this->gl_data->glXMakeCurrent(display, None, NULL);
         _this->gl_data->glXMakeCurrent(display, None, NULL);
         _this->gl_data->glXDestroyContext(display, context);
         _this->gl_data->glXDestroyContext(display, context);
     }
     }
-    XDestroyWindow(display, w);
+    X11_XDestroyWindow(display, w);
     X11_PumpEvents(_this);
     X11_PumpEvents(_this);
 }
 }
 
 
@@ -566,13 +566,13 @@ X11_GL_CreateContext(_THIS, SDL_Window * window)
     }
     }
 
 
     /* We do this to create a clean separation between X and GLX errors. */
     /* We do this to create a clean separation between X and GLX errors. */
-    XSync(display, False);
+    X11_XSync(display, False);
     errorBase = _this->gl_data->errorBase;
     errorBase = _this->gl_data->errorBase;
-    handler = XSetErrorHandler(X11_GL_CreateContextErrorHandler);
-    XGetWindowAttributes(display, data->xwindow, &xattr);
+    handler = X11_XSetErrorHandler(X11_GL_CreateContextErrorHandler);
+    X11_XGetWindowAttributes(display, data->xwindow, &xattr);
     v.screen = screen;
     v.screen = screen;
-    v.visualid = XVisualIDFromVisual(xattr.visual);
-    vinfo = XGetVisualInfo(display, VisualScreenMask | VisualIDMask, &v, &n);
+    v.visualid = X11_XVisualIDFromVisual(xattr.visual);
+    vinfo = X11_XGetVisualInfo(display, VisualScreenMask | VisualIDMask, &v, &n);
     if (vinfo) {
     if (vinfo) {
         if (_this->gl_config.major_version < 3 &&
         if (_this->gl_config.major_version < 3 &&
             _this->gl_config.profile_mask == 0 &&
             _this->gl_config.profile_mask == 0 &&
@@ -656,10 +656,10 @@ X11_GL_CreateContext(_THIS, SDL_Window * window)
                 }
                 }
             }
             }
         }
         }
-        XFree(vinfo);
+        X11_XFree(vinfo);
     }
     }
-    XSync(display, False);
-    XSetErrorHandler(handler);
+    X11_XSync(display, False);
+    X11_XSetErrorHandler(handler);
 
 
     if (!context) {
     if (!context) {
         SDL_SetError("Could not create GL context");
         SDL_SetError("Could not create GL context");
@@ -801,7 +801,7 @@ X11_GL_DeleteContext(_THIS, SDL_GLContext context)
         return;
         return;
     }
     }
     _this->gl_data->glXDestroyContext(display, glx_context);
     _this->gl_data->glXDestroyContext(display, glx_context);
-    XSync(display, False);
+    X11_XSync(display, False);
 }
 }
 
 
 #endif /* SDL_VIDEO_OPENGL_GLX */
 #endif /* SDL_VIDEO_OPENGL_GLX */

+ 4 - 4
src/video/x11/SDL_x11opengles.c

@@ -74,13 +74,13 @@ X11_GLES_GetVisual(_THIS, Display * display, int screen)
                                             &visual_id) == EGL_FALSE || !visual_id) {
                                             &visual_id) == EGL_FALSE || !visual_id) {
         /* Use the default visual when all else fails */
         /* Use the default visual when all else fails */
         vi_in.screen = screen;
         vi_in.screen = screen;
-        egl_visualinfo = XGetVisualInfo(display,
+        egl_visualinfo = X11_XGetVisualInfo(display,
                                         VisualScreenMask,
                                         VisualScreenMask,
                                         &vi_in, &out_count);
                                         &vi_in, &out_count);
     } else {
     } else {
         vi_in.screen = screen;
         vi_in.screen = screen;
         vi_in.visualid = visual_id;
         vi_in.visualid = visual_id;
-        egl_visualinfo = XGetVisualInfo(display, VisualScreenMask | VisualIDMask, &vi_in, &out_count);
+        egl_visualinfo = X11_XGetVisualInfo(display, VisualScreenMask | VisualIDMask, &vi_in, &out_count);
     }
     }
 
 
     return egl_visualinfo;
     return egl_visualinfo;
@@ -93,9 +93,9 @@ X11_GLES_CreateContext(_THIS, SDL_Window * window)
     SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
     SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
     Display *display = data->videodata->display;
     Display *display = data->videodata->display;
 
 
-    XSync(display, False);
+    X11_XSync(display, False);
     context = SDL_EGL_CreateContext(_this, data->egl_surface);
     context = SDL_EGL_CreateContext(_this, data->egl_surface);
-    XSync(display, False);
+    X11_XSync(display, False);
 
 
     return context;
     return context;
 }
 }

+ 4 - 4
src/video/x11/SDL_x11shape.c

@@ -106,12 +106,12 @@ X11_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMo
     SDL_CalculateShapeBitmap(shaper->mode,shape,data->bitmap,8);
     SDL_CalculateShapeBitmap(shaper->mode,shape,data->bitmap,8);
 
 
     windowdata = (SDL_WindowData*)(shaper->window->driverdata);
     windowdata = (SDL_WindowData*)(shaper->window->driverdata);
-    shapemask = XCreateBitmapFromData(windowdata->videodata->display,windowdata->xwindow,data->bitmap,shaper->window->w,shaper->window->h);
+    shapemask = X11_XCreateBitmapFromData(windowdata->videodata->display,windowdata->xwindow,data->bitmap,shaper->window->w,shaper->window->h);
 
 
-    XShapeCombineMask(windowdata->videodata->display,windowdata->xwindow, ShapeBounding, 0, 0,shapemask, ShapeSet);
-    XSync(windowdata->videodata->display,False);
+    X11_XShapeCombineMask(windowdata->videodata->display,windowdata->xwindow, ShapeBounding, 0, 0,shapemask, ShapeSet);
+    X11_XSync(windowdata->videodata->display,False);
 
 
-    XFreePixmap(windowdata->videodata->display,shapemask);
+    X11_XFreePixmap(windowdata->videodata->display,shapemask);
 #endif
 #endif
 
 
     return 0;
     return 0;

+ 22 - 22
src/video/x11/SDL_x11video.c

@@ -230,9 +230,9 @@ X11_Available(void)
 {
 {
     Display *display = NULL;
     Display *display = NULL;
     if (SDL_X11_LoadSymbols()) {
     if (SDL_X11_LoadSymbols()) {
-        display = XOpenDisplay(NULL);
+        display = X11_XOpenDisplay(NULL);
         if (display != NULL) {
         if (display != NULL) {
-            XCloseDisplay(display);
+            X11_XCloseDisplay(display);
         }
         }
         SDL_X11_UnloadSymbols();
         SDL_X11_UnloadSymbols();
     }
     }
@@ -244,7 +244,7 @@ X11_DeleteDevice(SDL_VideoDevice * device)
 {
 {
     SDL_VideoData *data = (SDL_VideoData *) device->driverdata;
     SDL_VideoData *data = (SDL_VideoData *) device->driverdata;
     if (data->display) {
     if (data->display) {
-        XCloseDisplay(data->display);
+        X11_XCloseDisplay(data->display);
     }
     }
     SDL_free(data->windowlist);
     SDL_free(data->windowlist);
     SDL_free(device->driverdata);
     SDL_free(device->driverdata);
@@ -296,7 +296,7 @@ X11_CreateDevice(int devindex)
 
 
     /* Need for threading gl calls. This is also required for the proprietary
     /* Need for threading gl calls. This is also required for the proprietary
         nVidia driver to be threaded. */
         nVidia driver to be threaded. */
-    XInitThreads();
+    X11_XInitThreads();
 
 
     /* Initialize all variables that we clean on shutdown */
     /* Initialize all variables that we clean on shutdown */
     device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
     device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
@@ -313,14 +313,14 @@ X11_CreateDevice(int devindex)
     device->driverdata = data;
     device->driverdata = data;
 
 
     /* FIXME: Do we need this?
     /* FIXME: Do we need this?
-       if ( (SDL_strncmp(XDisplayName(display), ":", 1) == 0) ||
-       (SDL_strncmp(XDisplayName(display), "unix:", 5) == 0) ) {
+       if ( (SDL_strncmp(X11_XDisplayName(display), ":", 1) == 0) ||
+       (SDL_strncmp(X11_XDisplayName(display), "unix:", 5) == 0) ) {
        local_X11 = 1;
        local_X11 = 1;
        } else {
        } else {
        local_X11 = 0;
        local_X11 = 0;
        }
        }
      */
      */
-    data->display = XOpenDisplay(display);
+    data->display = X11_XOpenDisplay(display);
 #if defined(__osf__) && defined(SDL_VIDEO_DRIVER_X11_DYNAMIC)
 #if defined(__osf__) && defined(SDL_VIDEO_DRIVER_X11_DYNAMIC)
     /* On Tru64 if linking without -lX11, it fails and you get following message.
     /* On Tru64 if linking without -lX11, it fails and you get following message.
      * Xlib: connection to ":0.0" refused by server
      * Xlib: connection to ":0.0" refused by server
@@ -331,7 +331,7 @@ X11_CreateDevice(int devindex)
      */
      */
     if (data->display == NULL) {
     if (data->display == NULL) {
         SDL_Delay(1000);
         SDL_Delay(1000);
-        data->display = XOpenDisplay(display);
+        data->display = X11_XOpenDisplay(display);
     }
     }
 #endif
 #endif
     if (data->display == NULL) {
     if (data->display == NULL) {
@@ -341,12 +341,12 @@ X11_CreateDevice(int devindex)
         return NULL;
         return NULL;
     }
     }
 #ifdef X11_DEBUG
 #ifdef X11_DEBUG
-    XSynchronize(data->display, True);
+    X11_XSynchronize(data->display, True);
 #endif
 #endif
 
 
     /* Hook up an X11 error handler to recover the desktop resolution. */
     /* Hook up an X11 error handler to recover the desktop resolution. */
     safety_net_triggered = SDL_FALSE;
     safety_net_triggered = SDL_FALSE;
-    orig_x11_errhandler = XSetErrorHandler(X11_SafetyNetErrHandler);
+    orig_x11_errhandler = X11_XSetErrorHandler(X11_SafetyNetErrHandler);
 
 
     /* Set the function pointers */
     /* Set the function pointers */
     device->VideoInit = X11_VideoInit;
     device->VideoInit = X11_VideoInit;
@@ -448,31 +448,31 @@ X11_CheckWindowManager(_THIS)
 #endif
 #endif
 
 
     /* Set up a handler to gracefully catch errors */
     /* Set up a handler to gracefully catch errors */
-    XSync(display, False);
-    handler = XSetErrorHandler(X11_CheckWindowManagerErrorHandler);
+    X11_XSync(display, False);
+    handler = X11_XSetErrorHandler(X11_CheckWindowManagerErrorHandler);
 
 
-    _NET_SUPPORTING_WM_CHECK = XInternAtom(display, "_NET_SUPPORTING_WM_CHECK", False);
-    status = XGetWindowProperty(display, DefaultRootWindow(display), _NET_SUPPORTING_WM_CHECK, 0L, 1L, False, XA_WINDOW, &real_type, &real_format, &items_read, &items_left, &propdata);
+    _NET_SUPPORTING_WM_CHECK = X11_XInternAtom(display, "_NET_SUPPORTING_WM_CHECK", False);
+    status = X11_XGetWindowProperty(display, DefaultRootWindow(display), _NET_SUPPORTING_WM_CHECK, 0L, 1L, False, XA_WINDOW, &real_type, &real_format, &items_read, &items_left, &propdata);
     if (status == Success && items_read) {
     if (status == Success && items_read) {
         wm_window = ((Window*)propdata)[0];
         wm_window = ((Window*)propdata)[0];
     }
     }
     if (propdata) {
     if (propdata) {
-        XFree(propdata);
+        X11_XFree(propdata);
     }
     }
 
 
     if (wm_window) {
     if (wm_window) {
-        status = XGetWindowProperty(display, wm_window, _NET_SUPPORTING_WM_CHECK, 0L, 1L, False, XA_WINDOW, &real_type, &real_format, &items_read, &items_left, &propdata);
+        status = X11_XGetWindowProperty(display, wm_window, _NET_SUPPORTING_WM_CHECK, 0L, 1L, False, XA_WINDOW, &real_type, &real_format, &items_read, &items_left, &propdata);
         if (status != Success || !items_read || wm_window != ((Window*)propdata)[0]) {
         if (status != Success || !items_read || wm_window != ((Window*)propdata)[0]) {
             wm_window = None;
             wm_window = None;
         }
         }
         if (propdata) {
         if (propdata) {
-            XFree(propdata);
+            X11_XFree(propdata);
         }
         }
     }
     }
 
 
     /* Reset the error handler, we're done checking */
     /* Reset the error handler, we're done checking */
-    XSync(display, False);
-    XSetErrorHandler(handler);
+    X11_XSync(display, False);
+    X11_XSetErrorHandler(handler);
 
 
     if (!wm_window) {
     if (!wm_window) {
 #ifdef DEBUG_WINDOW_MANAGER
 #ifdef DEBUG_WINDOW_MANAGER
@@ -505,12 +505,12 @@ X11_VideoInit(_THIS)
 #ifdef X_HAVE_UTF8_STRING
 #ifdef X_HAVE_UTF8_STRING
     if (SDL_X11_HAVE_UTF8) {
     if (SDL_X11_HAVE_UTF8) {
         data->im =
         data->im =
-            XOpenIM(data->display, NULL, data->classname, data->classname);
+            X11_XOpenIM(data->display, NULL, data->classname, data->classname);
     }
     }
 #endif
 #endif
 
 
     /* Look up some useful Atoms */
     /* Look up some useful Atoms */
-#define GET_ATOM(X) data->X = XInternAtom(data->display, #X, False)
+#define GET_ATOM(X) data->X = X11_XInternAtom(data->display, #X, False)
     GET_ATOM(WM_PROTOCOLS);
     GET_ATOM(WM_PROTOCOLS);
     GET_ATOM(WM_DELETE_WINDOW);
     GET_ATOM(WM_DELETE_WINDOW);
     GET_ATOM(_NET_WM_STATE);
     GET_ATOM(_NET_WM_STATE);
@@ -568,7 +568,7 @@ X11_VideoQuit(_THIS)
     SDL_free(data->classname);
     SDL_free(data->classname);
 #ifdef X_HAVE_UTF8_STRING
 #ifdef X_HAVE_UTF8_STRING
     if (data->im) {
     if (data->im) {
-        XCloseIM(data->im);
+        X11_XCloseIM(data->im);
     }
     }
 #endif
 #endif
 
 

+ 157 - 157
src/video/x11/SDL_x11window.c

@@ -61,11 +61,11 @@ static Bool isConfigureNotify(Display *dpy, XEvent *ev, XPointer win)
 
 
 /*
 /*
 static Bool
 static Bool
-XIfEventTimeout(Display *display, XEvent *event_return, Bool (*predicate)(), XPointer arg, int timeoutMS)
+X11_XIfEventTimeout(Display *display, XEvent *event_return, Bool (*predicate)(), XPointer arg, int timeoutMS)
 {
 {
     Uint32 start = SDL_GetTicks();
     Uint32 start = SDL_GetTicks();
 
 
-    while (!XCheckIfEvent(display, event_return, predicate, arg)) {
+    while (!X11_XCheckIfEvent(display, event_return, predicate, arg)) {
         if ((SDL_GetTicks() - start) >= timeoutMS) {
         if ((SDL_GetTicks() - start) >= timeoutMS) {
             return False;
             return False;
         }
         }
@@ -88,7 +88,7 @@ X11_IsWindowMapped(_THIS, SDL_Window * window)
     SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
     SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
     XWindowAttributes attr;
     XWindowAttributes attr;
 
 
-    XGetWindowAttributes(videodata->display, data->xwindow, &attr);
+    X11_XGetWindowAttributes(videodata->display, data->xwindow, &attr);
     if (attr.map_state != IsUnmapped) {
     if (attr.map_state != IsUnmapped) {
         return SDL_TRUE;
         return SDL_TRUE;
     } else {
     } else {
@@ -110,7 +110,7 @@ X11_IsActionAllowed(SDL_Window *window, Atom action)
     Atom *list;
     Atom *list;
     SDL_bool ret = SDL_FALSE;
     SDL_bool ret = SDL_FALSE;
 
 
-    if (XGetWindowProperty(display, data->xwindow, _NET_WM_ALLOWED_ACTIONS, 0, 1024, False, XA_ATOM, &type, &form, &len, &remain, (unsigned char **)&list) == Success)
+    if (X11_XGetWindowProperty(display, data->xwindow, _NET_WM_ALLOWED_ACTIONS, 0, 1024, False, XA_ATOM, &type, &form, &len, &remain, (unsigned char **)&list) == Success)
     {
     {
         for (i=0; i<len; ++i)
         for (i=0; i<len; ++i)
         {
         {
@@ -119,7 +119,7 @@ X11_IsActionAllowed(SDL_Window *window, Atom action)
                 break;
                 break;
             }
             }
         }
         }
-        XFree(list);
+        X11_XFree(list);
     }
     }
     return ret;
     return ret;
 }
 }
@@ -141,7 +141,7 @@ X11_SetNetWMState(_THIS, Window xwindow, Uint32 flags)
 
 
     /* The window manager sets this property, we shouldn't set it.
     /* The window manager sets this property, we shouldn't set it.
        If we did, this would indicate to the window manager that we don't
        If we did, this would indicate to the window manager that we don't
-       actually want to be mapped during XMapRaised(), which would be bad.
+       actually want to be mapped during X11_XMapRaised(), which would be bad.
      *
      *
     if (flags & SDL_WINDOW_HIDDEN) {
     if (flags & SDL_WINDOW_HIDDEN) {
         atoms[count++] = _NET_WM_STATE_HIDDEN;
         atoms[count++] = _NET_WM_STATE_HIDDEN;
@@ -158,10 +158,10 @@ X11_SetNetWMState(_THIS, Window xwindow, Uint32 flags)
         atoms[count++] = _NET_WM_STATE_FULLSCREEN;
         atoms[count++] = _NET_WM_STATE_FULLSCREEN;
     }
     }
     if (count > 0) {
     if (count > 0) {
-        XChangeProperty(display, xwindow, _NET_WM_STATE, XA_ATOM, 32,
+        X11_XChangeProperty(display, xwindow, _NET_WM_STATE, XA_ATOM, 32,
                         PropModeReplace, (unsigned char *)atoms, count);
                         PropModeReplace, (unsigned char *)atoms, count);
     } else {
     } else {
-        XDeleteProperty(display, xwindow, _NET_WM_STATE);
+        X11_XDeleteProperty(display, xwindow, _NET_WM_STATE);
     }
     }
 }
 }
 
 
@@ -183,7 +183,7 @@ X11_GetNetWMState(_THIS, Window xwindow)
     long maxLength = 1024;
     long maxLength = 1024;
     Uint32 flags = 0;
     Uint32 flags = 0;
 
 
-    if (XGetWindowProperty(display, xwindow, _NET_WM_STATE,
+    if (X11_XGetWindowProperty(display, xwindow, _NET_WM_STATE,
                            0l, maxLength, False, XA_ATOM, &actualType,
                            0l, maxLength, False, XA_ATOM, &actualType,
                            &actualFormat, &numItems, &bytesAfter,
                            &actualFormat, &numItems, &bytesAfter,
                            &propertyValue) == Success) {
                            &propertyValue) == Success) {
@@ -209,7 +209,7 @@ X11_GetNetWMState(_THIS, Window xwindow)
         }  else if (fullscreen == 1) {
         }  else if (fullscreen == 1) {
             flags |= SDL_WINDOW_FULLSCREEN;
             flags |= SDL_WINDOW_FULLSCREEN;
         }
         }
-        XFree(propertyValue);
+        X11_XFree(propertyValue);
     }
     }
 
 
     /* FIXME, check the size hints for resizable */
     /* FIXME, check the size hints for resizable */
@@ -237,7 +237,7 @@ SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created)
 #ifdef X_HAVE_UTF8_STRING
 #ifdef X_HAVE_UTF8_STRING
     if (SDL_X11_HAVE_UTF8 && videodata->im) {
     if (SDL_X11_HAVE_UTF8 && videodata->im) {
         data->ic =
         data->ic =
-            pXCreateIC(videodata->im, XNClientWindow, w, XNFocusWindow, w,
+            X11_XCreateIC(videodata->im, XNClientWindow, w, XNFocusWindow, w,
                        XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
                        XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
                        XNResourceName, videodata->classname, XNResourceClass,
                        XNResourceName, videodata->classname, XNResourceClass,
                        videodata->classname, NULL);
                        videodata->classname, NULL);
@@ -270,7 +270,7 @@ SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created)
     {
     {
         XWindowAttributes attrib;
         XWindowAttributes attrib;
 
 
-        XGetWindowAttributes(data->videodata->display, w, &attrib);
+        X11_XGetWindowAttributes(data->videodata->display, w, &attrib);
         window->x = attrib.x;
         window->x = attrib.x;
         window->y = attrib.y;
         window->y = attrib.y;
         window->w = attrib.width;
         window->w = attrib.width;
@@ -289,7 +289,7 @@ SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created)
     {
     {
         Window FocalWindow;
         Window FocalWindow;
         int RevertTo=0;
         int RevertTo=0;
-        XGetInputFocus(data->videodata->display, &FocalWindow, &RevertTo);
+        X11_XGetInputFocus(data->videodata->display, &FocalWindow, &RevertTo);
         if (FocalWindow==w)
         if (FocalWindow==w)
         {
         {
             window->flags |= SDL_WINDOW_INPUT_FOCUS;
             window->flags |= SDL_WINDOW_INPUT_FOCUS;
@@ -318,7 +318,7 @@ SetWindowBordered(Display *display, int screen, Window window, SDL_bool border)
      *  Gnome is similar: just use the Motif atom.
      *  Gnome is similar: just use the Motif atom.
      */
      */
 
 
-    Atom WM_HINTS = XInternAtom(display, "_MOTIF_WM_HINTS", True);
+    Atom WM_HINTS = X11_XInternAtom(display, "_MOTIF_WM_HINTS", True);
     if (WM_HINTS != None) {
     if (WM_HINTS != None) {
         /* Hints used by Motif compliant window managers */
         /* Hints used by Motif compliant window managers */
         struct
         struct
@@ -332,11 +332,11 @@ SetWindowBordered(Display *display, int screen, Window window, SDL_bool border)
             (1L << 1), 0, border ? 1 : 0, 0, 0
             (1L << 1), 0, border ? 1 : 0, 0, 0
         };
         };
 
 
-        XChangeProperty(display, window, WM_HINTS, WM_HINTS, 32,
+        X11_XChangeProperty(display, window, WM_HINTS, WM_HINTS, 32,
                         PropModeReplace, (unsigned char *) &MWMHints,
                         PropModeReplace, (unsigned char *) &MWMHints,
                         sizeof(MWMHints) / 4);
                         sizeof(MWMHints) / 4);
     } else {  /* set the transient hints instead, if necessary */
     } else {  /* set the transient hints instead, if necessary */
-        XSetTransientForHint(display, window, RootWindow(display, screen));
+        X11_XSetTransientForHint(display, window, RootWindow(display, screen));
     }
     }
 }
 }
 
 
@@ -389,7 +389,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
         }
         }
         visual = vinfo->visual;
         visual = vinfo->visual;
         depth = vinfo->depth;
         depth = vinfo->depth;
-        XFree(vinfo);
+        X11_XFree(vinfo);
     } else
     } else
 #endif
 #endif
     {
     {
@@ -410,7 +410,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
         int rshift, gshift, bshift;
         int rshift, gshift, bshift;
 
 
         xattr.colormap =
         xattr.colormap =
-            XCreateColormap(display, RootWindow(display, screen),
+            X11_XCreateColormap(display, RootWindow(display, screen),
                             visual, AllocAll);
                             visual, AllocAll);
 
 
         /* If we can't create a colormap, then we must die */
         /* If we can't create a colormap, then we must die */
@@ -471,16 +471,16 @@ X11_CreateWindow(_THIS, SDL_Window * window)
             colorcells[i].flags = DoRed | DoGreen | DoBlue;
             colorcells[i].flags = DoRed | DoGreen | DoBlue;
         }
         }
 
 
-        XStoreColors(display, xattr.colormap, colorcells, ncolors);
+        X11_XStoreColors(display, xattr.colormap, colorcells, ncolors);
 
 
         SDL_free(colorcells);
         SDL_free(colorcells);
     } else {
     } else {
         xattr.colormap =
         xattr.colormap =
-            XCreateColormap(display, RootWindow(display, screen),
+            X11_XCreateColormap(display, RootWindow(display, screen),
                             visual, AllocNone);
                             visual, AllocNone);
     }
     }
 
 
-    w = XCreateWindow(display, RootWindow(display, screen),
+    w = X11_XCreateWindow(display, RootWindow(display, screen),
                       window->x, window->y, window->w, window->h,
                       window->x, window->y, window->w, window->h,
                       0, depth, InputOutput, visual,
                       0, depth, InputOutput, visual,
                       (CWOverrideRedirect | CWBackPixmap | CWBorderPixel |
                       (CWOverrideRedirect | CWBackPixmap | CWBorderPixel |
@@ -492,7 +492,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
     SetWindowBordered(display, screen, w,
     SetWindowBordered(display, screen, w,
                       (window->flags & SDL_WINDOW_BORDERLESS) == 0);
                       (window->flags & SDL_WINDOW_BORDERLESS) == 0);
 
 
-    sizehints = XAllocSizeHints();
+    sizehints = X11_XAllocSizeHints();
     /* Setup the normal size hints */
     /* Setup the normal size hints */
     sizehints->flags = 0;
     sizehints->flags = 0;
     if (!(window->flags & SDL_WINDOW_RESIZABLE)) {
     if (!(window->flags & SDL_WINDOW_RESIZABLE)) {
@@ -505,25 +505,25 @@ X11_CreateWindow(_THIS, SDL_Window * window)
     sizehints->flags |= USPosition;
     sizehints->flags |= USPosition;
 
 
     /* Setup the input hints so we get keyboard input */
     /* Setup the input hints so we get keyboard input */
-    wmhints = XAllocWMHints();
+    wmhints = X11_XAllocWMHints();
     wmhints->input = True;
     wmhints->input = True;
     wmhints->flags = InputHint;
     wmhints->flags = InputHint;
 
 
     /* Setup the class hints so we can get an icon (AfterStep) */
     /* Setup the class hints so we can get an icon (AfterStep) */
-    classhints = XAllocClassHint();
+    classhints = X11_XAllocClassHint();
     classhints->res_name = data->classname;
     classhints->res_name = data->classname;
     classhints->res_class = data->classname;
     classhints->res_class = data->classname;
 
 
     /* Set the size, input and class hints, and define WM_CLIENT_MACHINE and WM_LOCALE_NAME */
     /* Set the size, input and class hints, and define WM_CLIENT_MACHINE and WM_LOCALE_NAME */
-    XSetWMProperties(display, w, NULL, NULL, NULL, 0, sizehints, wmhints, classhints);
+    X11_XSetWMProperties(display, w, NULL, NULL, NULL, 0, sizehints, wmhints, classhints);
 
 
-    XFree(sizehints);
-    XFree(wmhints);
-    XFree(classhints);
+    X11_XFree(sizehints);
+    X11_XFree(wmhints);
+    X11_XFree(classhints);
     /* Set the PID related to the window for the given hostname, if possible */
     /* Set the PID related to the window for the given hostname, if possible */
     if (data->pid > 0) {
     if (data->pid > 0) {
-        _NET_WM_PID = XInternAtom(display, "_NET_WM_PID", False);
-        XChangeProperty(display, w, _NET_WM_PID, XA_CARDINAL, 32, PropModeReplace,
+        _NET_WM_PID = X11_XInternAtom(display, "_NET_WM_PID", False);
+        X11_XChangeProperty(display, w, _NET_WM_PID, XA_CARDINAL, 32, PropModeReplace,
                         (unsigned char *)&data->pid, 1);
                         (unsigned char *)&data->pid, 1);
     }
     }
 
 
@@ -531,14 +531,14 @@ X11_CreateWindow(_THIS, SDL_Window * window)
     X11_SetNetWMState(_this, w, window->flags);
     X11_SetNetWMState(_this, w, window->flags);
 
 
     /* Let the window manager know we're a "normal" window */
     /* Let the window manager know we're a "normal" window */
-    _NET_WM_WINDOW_TYPE = XInternAtom(display, "_NET_WM_WINDOW_TYPE", False);
-    _NET_WM_WINDOW_TYPE_NORMAL = XInternAtom(display, "_NET_WM_WINDOW_TYPE_NORMAL", False);
-    XChangeProperty(display, w, _NET_WM_WINDOW_TYPE, XA_ATOM, 32,
+    _NET_WM_WINDOW_TYPE = X11_XInternAtom(display, "_NET_WM_WINDOW_TYPE", False);
+    _NET_WM_WINDOW_TYPE_NORMAL = X11_XInternAtom(display, "_NET_WM_WINDOW_TYPE_NORMAL", False);
+    X11_XChangeProperty(display, w, _NET_WM_WINDOW_TYPE, XA_ATOM, 32,
                     PropModeReplace,
                     PropModeReplace,
                     (unsigned char *)&_NET_WM_WINDOW_TYPE_NORMAL, 1);
                     (unsigned char *)&_NET_WM_WINDOW_TYPE_NORMAL, 1);
 
 
-    _NET_WM_BYPASS_COMPOSITOR = XInternAtom(display, "_NET_WM_BYPASS_COMPOSITOR", False);
-    XChangeProperty(display, w, _NET_WM_BYPASS_COMPOSITOR, XA_CARDINAL, 32,
+    _NET_WM_BYPASS_COMPOSITOR = X11_XInternAtom(display, "_NET_WM_BYPASS_COMPOSITOR", False);
+    X11_XChangeProperty(display, w, _NET_WM_BYPASS_COMPOSITOR, XA_CARDINAL, 32,
                     PropModeReplace,
                     PropModeReplace,
                     (unsigned char *)&_NET_WM_BYPASS_COMPOSITOR_HINT_ON, 1);
                     (unsigned char *)&_NET_WM_BYPASS_COMPOSITOR_HINT_ON, 1);
 
 
@@ -547,11 +547,11 @@ X11_CreateWindow(_THIS, SDL_Window * window)
             data->WM_DELETE_WINDOW, /* Allow window to be deleted by the WM */
             data->WM_DELETE_WINDOW, /* Allow window to be deleted by the WM */
             data->_NET_WM_PING, /* Respond so WM knows we're alive */
             data->_NET_WM_PING, /* Respond so WM knows we're alive */
         };
         };
-        XSetWMProtocols(display, w, protocols, sizeof (protocols) / sizeof (protocols[0]));
+        X11_XSetWMProtocols(display, w, protocols, sizeof (protocols) / sizeof (protocols[0]));
     }
     }
 
 
     if (SetupWindowData(_this, window, w, SDL_TRUE) < 0) {
     if (SetupWindowData(_this, window, w, SDL_TRUE) < 0) {
-        XDestroyWindow(display, w);
+        X11_XDestroyWindow(display, w);
         return -1;
         return -1;
     }
     }
     windowdata = (SDL_WindowData *) window->driverdata;
     windowdata = (SDL_WindowData *) window->driverdata;
@@ -564,7 +564,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
 #endif  
 #endif  
     ) {
     ) {
         if (!_this->egl_data) {
         if (!_this->egl_data) {
-            XDestroyWindow(display, w);
+            X11_XDestroyWindow(display, w);
             return -1;
             return -1;
         }
         }
 
 
@@ -572,7 +572,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
         windowdata->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType) w);
         windowdata->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType) w);
 
 
         if (windowdata->egl_surface == EGL_NO_SURFACE) {
         if (windowdata->egl_surface == EGL_NO_SURFACE) {
-            XDestroyWindow(display, w);
+            X11_XDestroyWindow(display, w);
             return SDL_SetError("Could not create GLES window surface");
             return SDL_SetError("Could not create GLES window surface");
         }
         }
     }
     }
@@ -581,25 +581,25 @@ X11_CreateWindow(_THIS, SDL_Window * window)
 
 
 #ifdef X_HAVE_UTF8_STRING
 #ifdef X_HAVE_UTF8_STRING
     if (SDL_X11_HAVE_UTF8 && windowdata->ic) {
     if (SDL_X11_HAVE_UTF8 && windowdata->ic) {
-        pXGetICValues(windowdata->ic, XNFilterEvents, &fevent, NULL);
+        X11_XGetICValues(windowdata->ic, XNFilterEvents, &fevent, NULL);
     }
     }
 #endif
 #endif
 
 
     X11_Xinput2SelectTouch(_this, window);
     X11_Xinput2SelectTouch(_this, window);
 
 
-    XSelectInput(display, w,
+    X11_XSelectInput(display, w,
                  (FocusChangeMask | EnterWindowMask | LeaveWindowMask |
                  (FocusChangeMask | EnterWindowMask | LeaveWindowMask |
                  ExposureMask | ButtonPressMask | ButtonReleaseMask |
                  ExposureMask | ButtonPressMask | ButtonReleaseMask |
                  PointerMotionMask | KeyPressMask | KeyReleaseMask |
                  PointerMotionMask | KeyPressMask | KeyReleaseMask |
                  PropertyChangeMask | StructureNotifyMask |
                  PropertyChangeMask | StructureNotifyMask |
                  KeymapStateMask | fevent));
                  KeymapStateMask | fevent));
 
 
-    XdndAware = XInternAtom(display, "XdndAware", False);
-    XChangeProperty(display, w, XdndAware, XA_ATOM, 32,
+    XdndAware = X11_XInternAtom(display, "XdndAware", False);
+    X11_XChangeProperty(display, w, XdndAware, XA_ATOM, 32,
                  PropModeReplace,
                  PropModeReplace,
                  (unsigned char*)&xdnd_version, 1);
                  (unsigned char*)&xdnd_version, 1);
 
 
-    XFlush(display);
+    X11_XFlush(display);
 
 
     return 0;
     return 0;
 }
 }
@@ -628,14 +628,14 @@ X11_GetWindowTitle(_THIS, Window xwindow)
     unsigned char *propdata;
     unsigned char *propdata;
     char *title = NULL;
     char *title = NULL;
 
 
-    status = XGetWindowProperty(display, xwindow, data->_NET_WM_NAME,
+    status = X11_XGetWindowProperty(display, xwindow, data->_NET_WM_NAME,
                 0L, 8192L, False, data->UTF8_STRING, &real_type, &real_format,
                 0L, 8192L, False, data->UTF8_STRING, &real_type, &real_format,
                 &items_read, &items_left, &propdata);
                 &items_read, &items_left, &propdata);
     if (status == Success && propdata) {
     if (status == Success && propdata) {
         title = SDL_strdup(SDL_static_cast(char*, propdata));
         title = SDL_strdup(SDL_static_cast(char*, propdata));
-        XFree(propdata);
+        X11_XFree(propdata);
     } else {
     } else {
-        status = XGetWindowProperty(display, xwindow, XA_WM_NAME,
+        status = X11_XGetWindowProperty(display, xwindow, XA_WM_NAME,
                     0L, 8192L, False, XA_STRING, &real_type, &real_format,
                     0L, 8192L, False, XA_STRING, &real_type, &real_format,
                     &items_read, &items_left, &propdata);
                     &items_read, &items_left, &propdata);
         if (status == Success && propdata) {
         if (status == Success && propdata) {
@@ -668,21 +668,21 @@ X11_SetWindowTitle(_THIS, SDL_Window * window)
             SDL_OutOfMemory();
             SDL_OutOfMemory();
             return;
             return;
         }
         }
-        status = XStringListToTextProperty(&title_locale, 1, &titleprop);
+        status = X11_XStringListToTextProperty(&title_locale, 1, &titleprop);
         SDL_free(title_locale);
         SDL_free(title_locale);
         if (status) {
         if (status) {
-            XSetTextProperty(display, data->xwindow, &titleprop, XA_WM_NAME);
-            XFree(titleprop.value);
+            X11_XSetTextProperty(display, data->xwindow, &titleprop, XA_WM_NAME);
+            X11_XFree(titleprop.value);
         }
         }
 #ifdef X_HAVE_UTF8_STRING
 #ifdef X_HAVE_UTF8_STRING
         if (SDL_X11_HAVE_UTF8) {
         if (SDL_X11_HAVE_UTF8) {
             status =
             status =
-                Xutf8TextListToTextProperty(display, (char **) &title, 1,
+                X11_Xutf8TextListToTextProperty(display, (char **) &title, 1,
                                             XUTF8StringStyle, &titleprop);
                                             XUTF8StringStyle, &titleprop);
             if (status == Success) {
             if (status == Success) {
-                XSetTextProperty(display, data->xwindow, &titleprop,
+                X11_XSetTextProperty(display, data->xwindow, &titleprop,
                                  _NET_WM_NAME);
                                  _NET_WM_NAME);
-                XFree(titleprop.value);
+                X11_XFree(titleprop.value);
             }
             }
         }
         }
 #endif
 #endif
@@ -693,27 +693,27 @@ X11_SetWindowTitle(_THIS, SDL_Window * window)
             SDL_OutOfMemory();
             SDL_OutOfMemory();
             return;
             return;
         }
         }
-        status = XStringListToTextProperty(&icon_locale, 1, &iconprop);
+        status = X11_XStringListToTextProperty(&icon_locale, 1, &iconprop);
         SDL_free(icon_locale);
         SDL_free(icon_locale);
         if (status) {
         if (status) {
-            XSetTextProperty(display, data->xwindow, &iconprop,
+            X11_XSetTextProperty(display, data->xwindow, &iconprop,
                              XA_WM_ICON_NAME);
                              XA_WM_ICON_NAME);
-            XFree(iconprop.value);
+            X11_XFree(iconprop.value);
         }
         }
 #ifdef X_HAVE_UTF8_STRING
 #ifdef X_HAVE_UTF8_STRING
         if (SDL_X11_HAVE_UTF8) {
         if (SDL_X11_HAVE_UTF8) {
             status =
             status =
-                Xutf8TextListToTextProperty(display, (char **) &icon, 1,
+                X11_Xutf8TextListToTextProperty(display, (char **) &icon, 1,
                                             XUTF8StringStyle, &iconprop);
                                             XUTF8StringStyle, &iconprop);
             if (status == Success) {
             if (status == Success) {
-                XSetTextProperty(display, data->xwindow, &iconprop,
+                X11_XSetTextProperty(display, data->xwindow, &iconprop,
                                  _NET_WM_ICON_NAME);
                                  _NET_WM_ICON_NAME);
-                XFree(iconprop.value);
+                X11_XFree(iconprop.value);
             }
             }
         }
         }
 #endif
 #endif
     }
     }
-    XFlush(display);
+    X11_XFlush(display);
 }
 }
 
 
 void
 void
@@ -745,15 +745,15 @@ X11_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon)
                     *dst++ = *src++;
                     *dst++ = *src++;
                 }
                 }
             }
             }
-            XChangeProperty(display, data->xwindow, _NET_WM_ICON, XA_CARDINAL,
+            X11_XChangeProperty(display, data->xwindow, _NET_WM_ICON, XA_CARDINAL,
                             32, PropModeReplace, (unsigned char *) propdata,
                             32, PropModeReplace, (unsigned char *) propdata,
                             propsize);
                             propsize);
         }
         }
         SDL_free(propdata);
         SDL_free(propdata);
     } else {
     } else {
-        XDeleteProperty(display, data->xwindow, _NET_WM_ICON);
+        X11_XDeleteProperty(display, data->xwindow, _NET_WM_ICON);
     }
     }
-    XFlush(display);
+    X11_XFlush(display);
 }
 }
 
 
 void
 void
@@ -762,8 +762,8 @@ X11_SetWindowPosition(_THIS, SDL_Window * window)
     SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
     SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
     Display *display = data->videodata->display;
     Display *display = data->videodata->display;
 
 
-    XMoveWindow(display, data->xwindow, window->x, window->y);
-    XFlush(display);
+    X11_XMoveWindow(display, data->xwindow, window->x, window->y);
+    X11_XFlush(display);
 }
 }
 
 
 void
 void
@@ -773,26 +773,26 @@ X11_SetWindowMinimumSize(_THIS, SDL_Window * window)
     Display *display = data->videodata->display;
     Display *display = data->videodata->display;
 
 
     if (window->flags & SDL_WINDOW_RESIZABLE) {
     if (window->flags & SDL_WINDOW_RESIZABLE) {
-         XSizeHints *sizehints = XAllocSizeHints();
+         XSizeHints *sizehints = X11_XAllocSizeHints();
          long userhints;
          long userhints;
 
 
-         XGetWMNormalHints(display, data->xwindow, sizehints, &userhints);
+         X11_XGetWMNormalHints(display, data->xwindow, sizehints, &userhints);
 
 
          sizehints->min_width = window->min_w;
          sizehints->min_width = window->min_w;
          sizehints->min_height = window->min_h;
          sizehints->min_height = window->min_h;
          sizehints->flags |= PMinSize;
          sizehints->flags |= PMinSize;
 
 
-         XSetWMNormalHints(display, data->xwindow, sizehints);
+         X11_XSetWMNormalHints(display, data->xwindow, sizehints);
 
 
-         XFree(sizehints);
+         X11_XFree(sizehints);
 
 
         /* See comment in X11_SetWindowSize. */
         /* See comment in X11_SetWindowSize. */
-        XResizeWindow(display, data->xwindow, window->w, window->h);
-        XMoveWindow(display, data->xwindow, window->x, window->y);
-        XRaiseWindow(display, data->xwindow);
+        X11_XResizeWindow(display, data->xwindow, window->w, window->h);
+        X11_XMoveWindow(display, data->xwindow, window->x, window->y);
+        X11_XRaiseWindow(display, data->xwindow);
     }
     }
 
 
-    XFlush(display);
+    X11_XFlush(display);
 }
 }
 
 
 void
 void
@@ -802,26 +802,26 @@ X11_SetWindowMaximumSize(_THIS, SDL_Window * window)
     Display *display = data->videodata->display;
     Display *display = data->videodata->display;
 
 
     if (window->flags & SDL_WINDOW_RESIZABLE) {
     if (window->flags & SDL_WINDOW_RESIZABLE) {
-         XSizeHints *sizehints = XAllocSizeHints();
+         XSizeHints *sizehints = X11_XAllocSizeHints();
          long userhints;
          long userhints;
 
 
-         XGetWMNormalHints(display, data->xwindow, sizehints, &userhints);
+         X11_XGetWMNormalHints(display, data->xwindow, sizehints, &userhints);
 
 
          sizehints->max_width = window->max_w;
          sizehints->max_width = window->max_w;
          sizehints->max_height = window->max_h;
          sizehints->max_height = window->max_h;
          sizehints->flags |= PMaxSize;
          sizehints->flags |= PMaxSize;
 
 
-         XSetWMNormalHints(display, data->xwindow, sizehints);
+         X11_XSetWMNormalHints(display, data->xwindow, sizehints);
 
 
-         XFree(sizehints);
+         X11_XFree(sizehints);
 
 
         /* See comment in X11_SetWindowSize. */
         /* See comment in X11_SetWindowSize. */
-        XResizeWindow(display, data->xwindow, window->w, window->h);
-        XMoveWindow(display, data->xwindow, window->x, window->y);
-        XRaiseWindow(display, data->xwindow);
+        X11_XResizeWindow(display, data->xwindow, window->w, window->h);
+        X11_XMoveWindow(display, data->xwindow, window->x, window->y);
+        X11_XRaiseWindow(display, data->xwindow);
     }
     }
 
 
-    XFlush(display);
+    X11_XFlush(display);
 }
 }
 
 
 void
 void
@@ -834,20 +834,20 @@ X11_SetWindowSize(_THIS, SDL_Window * window)
         X11_ResizeWindowShape(window);
         X11_ResizeWindowShape(window);
     }
     }
     if (!(window->flags & SDL_WINDOW_RESIZABLE)) {
     if (!(window->flags & SDL_WINDOW_RESIZABLE)) {
-         /* Apparently, if the X11 Window is set to a 'non-resizable' window, you cannot resize it using the XResizeWindow, thus
+         /* Apparently, if the X11 Window is set to a 'non-resizable' window, you cannot resize it using the X11_XResizeWindow, thus
             we must set the size hints to adjust the window size. */
             we must set the size hints to adjust the window size. */
-         XSizeHints *sizehints = XAllocSizeHints();
+         XSizeHints *sizehints = X11_XAllocSizeHints();
          long userhints;
          long userhints;
 
 
-         XGetWMNormalHints(display, data->xwindow, sizehints, &userhints);
+         X11_XGetWMNormalHints(display, data->xwindow, sizehints, &userhints);
 
 
          sizehints->min_width = sizehints->max_width = window->w;
          sizehints->min_width = sizehints->max_width = window->w;
          sizehints->min_height = sizehints->max_height = window->h;
          sizehints->min_height = sizehints->max_height = window->h;
          sizehints->flags |= PMinSize | PMaxSize;
          sizehints->flags |= PMinSize | PMaxSize;
 
 
-         XSetWMNormalHints(display, data->xwindow, sizehints);
+         X11_XSetWMNormalHints(display, data->xwindow, sizehints);
 
 
-         XFree(sizehints);
+         X11_XFree(sizehints);
 
 
         /* From Pierre-Loup:
         /* From Pierre-Loup:
            WMs each have their little quirks with that.  When you change the
            WMs each have their little quirks with that.  When you change the
@@ -865,14 +865,14 @@ X11_SetWindowSize(_THIS, SDL_Window * window)
            hide/show, because there are supposedly subtle problems with doing so
            hide/show, because there are supposedly subtle problems with doing so
            and transitioning from windowed to fullscreen in Unity.
            and transitioning from windowed to fullscreen in Unity.
          */
          */
-        XResizeWindow(display, data->xwindow, window->w, window->h);
-        XMoveWindow(display, data->xwindow, window->x, window->y);
-        XRaiseWindow(display, data->xwindow);
+        X11_XResizeWindow(display, data->xwindow, window->w, window->h);
+        X11_XMoveWindow(display, data->xwindow, window->x, window->y);
+        X11_XRaiseWindow(display, data->xwindow);
     } else {
     } else {
-        XResizeWindow(display, data->xwindow, window->w, window->h);
+        X11_XResizeWindow(display, data->xwindow, window->w, window->h);
     }
     }
 
 
-    XFlush(display);
+    X11_XFlush(display);
 }
 }
 
 
 void
 void
@@ -887,25 +887,25 @@ X11_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered)
     XEvent event;
     XEvent event;
 
 
     SetWindowBordered(display, displaydata->screen, data->xwindow, bordered);
     SetWindowBordered(display, displaydata->screen, data->xwindow, bordered);
-    XFlush(display);
-    XIfEvent(display, &event, &isConfigureNotify, (XPointer)&data->xwindow);
+    X11_XFlush(display);
+    X11_XIfEvent(display, &event, &isConfigureNotify, (XPointer)&data->xwindow);
 
 
     if (visible) {
     if (visible) {
         XWindowAttributes attr;
         XWindowAttributes attr;
         do {
         do {
-            XSync(display, False);
-            XGetWindowAttributes(display, data->xwindow, &attr);
+            X11_XSync(display, False);
+            X11_XGetWindowAttributes(display, data->xwindow, &attr);
         } while (attr.map_state != IsViewable);
         } while (attr.map_state != IsViewable);
 
 
         if (focused) {
         if (focused) {
-            XSetInputFocus(display, data->xwindow, RevertToParent, CurrentTime);
+            X11_XSetInputFocus(display, data->xwindow, RevertToParent, CurrentTime);
         }
         }
     }
     }
 
 
     /* make sure these don't make it to the real event queue if they fired here. */
     /* make sure these don't make it to the real event queue if they fired here. */
-    XSync(display, False);
-    XCheckIfEvent(display, &event, &isUnmapNotify, (XPointer)&data->xwindow);
-    XCheckIfEvent(display, &event, &isMapNotify, (XPointer)&data->xwindow);
+    X11_XSync(display, False);
+    X11_XCheckIfEvent(display, &event, &isUnmapNotify, (XPointer)&data->xwindow);
+    X11_XCheckIfEvent(display, &event, &isMapNotify, (XPointer)&data->xwindow);
 }
 }
 
 
 void
 void
@@ -916,12 +916,12 @@ X11_ShowWindow(_THIS, SDL_Window * window)
     XEvent event;
     XEvent event;
 
 
     if (!X11_IsWindowMapped(_this, window)) {
     if (!X11_IsWindowMapped(_this, window)) {
-        XMapRaised(display, data->xwindow);
+        X11_XMapRaised(display, data->xwindow);
         /* Blocking wait for "MapNotify" event.
         /* Blocking wait for "MapNotify" event.
-         * We use XIfEvent because XWindowEvent takes a mask rather than a type,
+         * We use X11_XIfEvent because pXWindowEvent takes a mask rather than a type,
          * and XCheckTypedWindowEvent doesn't block */
          * and XCheckTypedWindowEvent doesn't block */
-        XIfEvent(display, &event, &isMapNotify, (XPointer)&data->xwindow);
-        XFlush(display);
+        X11_XIfEvent(display, &event, &isMapNotify, (XPointer)&data->xwindow);
+        X11_XFlush(display);
     }
     }
 }
 }
 
 
@@ -934,10 +934,10 @@ X11_HideWindow(_THIS, SDL_Window * window)
     XEvent event;
     XEvent event;
 
 
     if (X11_IsWindowMapped(_this, window)) {
     if (X11_IsWindowMapped(_this, window)) {
-        XWithdrawWindow(display, data->xwindow, displaydata->screen);
+        X11_XWithdrawWindow(display, data->xwindow, displaydata->screen);
         /* Blocking wait for "UnmapNotify" event */
         /* Blocking wait for "UnmapNotify" event */
-        XIfEvent(display, &event, &isUnmapNotify, (XPointer)&data->xwindow);
-        XFlush(display);
+        X11_XIfEvent(display, &event, &isUnmapNotify, (XPointer)&data->xwindow);
+        X11_XFlush(display);
     }
     }
 }
 }
 
 
@@ -962,10 +962,10 @@ SetWindowActive(_THIS, SDL_Window * window)
         e.xclient.data.l[1] = CurrentTime;
         e.xclient.data.l[1] = CurrentTime;
         e.xclient.data.l[2] = 0;
         e.xclient.data.l[2] = 0;
 
 
-        XSendEvent(display, RootWindow(display, displaydata->screen), 0,
+        X11_XSendEvent(display, RootWindow(display, displaydata->screen), 0,
                    SubstructureNotifyMask | SubstructureRedirectMask, &e);
                    SubstructureNotifyMask | SubstructureRedirectMask, &e);
 
 
-        XFlush(display);
+        X11_XFlush(display);
     }
     }
 }
 }
 
 
@@ -975,9 +975,9 @@ X11_RaiseWindow(_THIS, SDL_Window * window)
     SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
     SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
     Display *display = data->videodata->display;
     Display *display = data->videodata->display;
 
 
-    XRaiseWindow(display, data->xwindow);
+    X11_XRaiseWindow(display, data->xwindow);
     SetWindowActive(_this, window);
     SetWindowActive(_this, window);
-    XFlush(display);
+    X11_XFlush(display);
 }
 }
 
 
 static void
 static void
@@ -1011,12 +1011,12 @@ SetWindowMaximized(_THIS, SDL_Window * window, SDL_bool maximized)
         e.xclient.data.l[2] = _NET_WM_STATE_MAXIMIZED_HORZ;
         e.xclient.data.l[2] = _NET_WM_STATE_MAXIMIZED_HORZ;
         e.xclient.data.l[3] = 0l;
         e.xclient.data.l[3] = 0l;
 
 
-        XSendEvent(display, RootWindow(display, displaydata->screen), 0,
+        X11_XSendEvent(display, RootWindow(display, displaydata->screen), 0,
                    SubstructureNotifyMask | SubstructureRedirectMask, &e);
                    SubstructureNotifyMask | SubstructureRedirectMask, &e);
     } else {
     } else {
         X11_SetNetWMState(_this, data->xwindow, window->flags);
         X11_SetNetWMState(_this, data->xwindow, window->flags);
     }
     }
-    XFlush(display);
+    X11_XFlush(display);
 }
 }
 
 
 void
 void
@@ -1033,8 +1033,8 @@ X11_MinimizeWindow(_THIS, SDL_Window * window)
         (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata;
         (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata;
     Display *display = data->videodata->display;
     Display *display = data->videodata->display;
 
 
-    XIconifyWindow(display, data->xwindow, displaydata->screen);
-    XFlush(display);
+    X11_XIconifyWindow(display, data->xwindow, displaydata->screen);
+    X11_XFlush(display);
 }
 }
 
 
 void
 void
@@ -1061,9 +1061,9 @@ X11_SetWindowFullscreenViaWM(_THIS, SDL_Window * window, SDL_VideoDisplay * _dis
         if (!(window->flags & SDL_WINDOW_RESIZABLE)) {
         if (!(window->flags & SDL_WINDOW_RESIZABLE)) {
             /* Compiz refuses fullscreen toggle if we're not resizable, so update the hints so we
             /* Compiz refuses fullscreen toggle if we're not resizable, so update the hints so we
                can be resized to the fullscreen resolution (or reset so we're not resizable again) */
                can be resized to the fullscreen resolution (or reset so we're not resizable again) */
-            XSizeHints *sizehints = XAllocSizeHints();
+            XSizeHints *sizehints = X11_XAllocSizeHints();
             long flags = 0;
             long flags = 0;
-            XGetWMNormalHints(display, data->xwindow, sizehints, &flags);
+            X11_XGetWMNormalHints(display, data->xwindow, sizehints, &flags);
             /* set the resize flags on */
             /* set the resize flags on */
             if (fullscreen) {
             if (fullscreen) {
                 /* we are going fullscreen so turn the flags off */
                 /* we are going fullscreen so turn the flags off */
@@ -1074,8 +1074,8 @@ X11_SetWindowFullscreenViaWM(_THIS, SDL_Window * window, SDL_VideoDisplay * _dis
                 sizehints->min_width = sizehints->max_width = window->windowed.w;
                 sizehints->min_width = sizehints->max_width = window->windowed.w;
                 sizehints->min_height = sizehints->max_height = window->windowed.h;
                 sizehints->min_height = sizehints->max_height = window->windowed.h;
             }
             }
-            XSetWMNormalHints(display, data->xwindow, sizehints);
-            XFree(sizehints);
+            X11_XSetWMNormalHints(display, data->xwindow, sizehints);
+            X11_XFree(sizehints);
         }
         }
 
 
         SDL_zero(e);
         SDL_zero(e);
@@ -1088,7 +1088,7 @@ X11_SetWindowFullscreenViaWM(_THIS, SDL_Window * window, SDL_VideoDisplay * _dis
         e.xclient.data.l[1] = _NET_WM_STATE_FULLSCREEN;
         e.xclient.data.l[1] = _NET_WM_STATE_FULLSCREEN;
         e.xclient.data.l[3] = 0l;
         e.xclient.data.l[3] = 0l;
 
 
-        XSendEvent(display, RootWindow(display, displaydata->screen), 0,
+        X11_XSendEvent(display, RootWindow(display, displaydata->screen), 0,
                    SubstructureNotifyMask | SubstructureRedirectMask, &e);
                    SubstructureNotifyMask | SubstructureRedirectMask, &e);
     } else {
     } else {
         Uint32 flags;
         Uint32 flags;
@@ -1104,13 +1104,13 @@ X11_SetWindowFullscreenViaWM(_THIS, SDL_Window * window, SDL_VideoDisplay * _dis
 
 
     if (data->visual->class == DirectColor) {
     if (data->visual->class == DirectColor) {
         if ( fullscreen ) {
         if ( fullscreen ) {
-            XInstallColormap(display, data->colormap);
+            X11_XInstallColormap(display, data->colormap);
         } else {
         } else {
-            XUninstallColormap(display, data->colormap);
+            X11_XUninstallColormap(display, data->colormap);
         }
         }
     }
     }
 
 
-    XFlush(display);
+    X11_XFlush(display);
 }
 }
 
 
 /* This handles fullscreen itself, outside the Window Manager. */
 /* This handles fullscreen itself, outside the Window Manager. */
@@ -1145,48 +1145,48 @@ X11_BeginWindowFullscreenLegacy(_THIS, SDL_Window * window, SDL_VideoDisplay * _
     xattr.colormap = data->colormap;
     xattr.colormap = data->colormap;
     xattrmask |= CWColormap;
     xattrmask |= CWColormap;
 
 
-    data->fswindow = XCreateWindow(display, root,
+    data->fswindow = X11_XCreateWindow(display, root,
                                    rect.x, rect.y, rect.w, rect.h, 0,
                                    rect.x, rect.y, rect.w, rect.h, 0,
                                    displaydata->depth, InputOutput,
                                    displaydata->depth, InputOutput,
                                    visual, xattrmask, &xattr);
                                    visual, xattrmask, &xattr);
 
 
-    XSelectInput(display, data->fswindow, StructureNotifyMask);
-    XSetWindowBackground(display, data->fswindow, 0);
-    XInstallColormap(display, data->colormap);
-    XClearWindow(display, data->fswindow);
-    XMapRaised(display, data->fswindow);
+    X11_XSelectInput(display, data->fswindow, StructureNotifyMask);
+    X11_XSetWindowBackground(display, data->fswindow, 0);
+    X11_XInstallColormap(display, data->colormap);
+    X11_XClearWindow(display, data->fswindow);
+    X11_XMapRaised(display, data->fswindow);
 
 
     /* Make sure the fswindow is in view by warping mouse to the corner */
     /* Make sure the fswindow is in view by warping mouse to the corner */
-    XUngrabPointer(display, CurrentTime);
-    XWarpPointer(display, None, root, 0, 0, 0, 0, rect.x, rect.y);
+    X11_XUngrabPointer(display, CurrentTime);
+    X11_XWarpPointer(display, None, root, 0, 0, 0, 0, rect.x, rect.y);
 
 
     /* Wait to be mapped, filter Unmap event out if it arrives. */
     /* Wait to be mapped, filter Unmap event out if it arrives. */
-    XIfEvent(display, &ev, &isMapNotify, (XPointer)&data->fswindow);
-    XCheckIfEvent(display, &ev, &isUnmapNotify, (XPointer)&data->fswindow);
+    X11_XIfEvent(display, &ev, &isMapNotify, (XPointer)&data->fswindow);
+    X11_XCheckIfEvent(display, &ev, &isUnmapNotify, (XPointer)&data->fswindow);
 
 
 #if SDL_VIDEO_DRIVER_X11_XVIDMODE
 #if SDL_VIDEO_DRIVER_X11_XVIDMODE
     if ( displaydata->use_vidmode ) {
     if ( displaydata->use_vidmode ) {
-        XF86VidModeLockModeSwitch(display, screen, True);
+        X11_XF86VidModeLockModeSwitch(display, screen, True);
     }
     }
 #endif
 #endif
 
 
     SetWindowBordered(display, displaydata->screen, data->xwindow, SDL_FALSE);
     SetWindowBordered(display, displaydata->screen, data->xwindow, SDL_FALSE);
 
 
     /* Center actual window within our cover-the-screen window. */
     /* Center actual window within our cover-the-screen window. */
-    XReparentWindow(display, data->xwindow, data->fswindow,
+    X11_XReparentWindow(display, data->xwindow, data->fswindow,
                     (rect.w - window->w) / 2, (rect.h - window->h) / 2);
                     (rect.w - window->w) / 2, (rect.h - window->h) / 2);
 
 
     /* Move the mouse to the upper left to make sure it's on-screen */
     /* Move the mouse to the upper left to make sure it's on-screen */
-    XWarpPointer(display, None, root, 0, 0, 0, 0, rect.x, rect.y);
+    X11_XWarpPointer(display, None, root, 0, 0, 0, 0, rect.x, rect.y);
 
 
     /* Center mouse in the fullscreen window. */
     /* Center mouse in the fullscreen window. */
     rect.x += (rect.w / 2);
     rect.x += (rect.w / 2);
     rect.y += (rect.h / 2);
     rect.y += (rect.h / 2);
-    XWarpPointer(display, None, root, 0, 0, 0, 0, rect.x, rect.y);
+    X11_XWarpPointer(display, None, root, 0, 0, 0, 0, rect.x, rect.y);
 
 
     /* Wait to be mapped, filter Unmap event out if it arrives. */
     /* Wait to be mapped, filter Unmap event out if it arrives. */
-    XIfEvent(display, &ev, &isMapNotify, (XPointer)&data->xwindow);
-    XCheckIfEvent(display, &ev, &isUnmapNotify, (XPointer)&data->xwindow);
+    X11_XIfEvent(display, &ev, &isMapNotify, (XPointer)&data->xwindow);
+    X11_XCheckIfEvent(display, &ev, &isUnmapNotify, (XPointer)&data->xwindow);
 
 
     SDL_UpdateWindowGrab(window);
     SDL_UpdateWindowGrab(window);
 }
 }
@@ -1210,27 +1210,27 @@ X11_EndWindowFullscreenLegacy(_THIS, SDL_Window * window, SDL_VideoDisplay * _di
 
 
 #if SDL_VIDEO_DRIVER_X11_VIDMODE
 #if SDL_VIDEO_DRIVER_X11_VIDMODE
     if ( displaydata->use_vidmode ) {
     if ( displaydata->use_vidmode ) {
-        XF86VidModeLockModeSwitch(display, screen, False);
+        X11_XF86VidModeLockModeSwitch(display, screen, False);
     }
     }
 #endif
 #endif
 
 
     SDL_UpdateWindowGrab(window);
     SDL_UpdateWindowGrab(window);
 
 
-    XReparentWindow(display, data->xwindow, root, window->x, window->y);
+    X11_XReparentWindow(display, data->xwindow, root, window->x, window->y);
 
 
     /* flush these events so they don't confuse normal event handling */
     /* flush these events so they don't confuse normal event handling */
-    XSync(display, False);
-    XCheckIfEvent(display, &ev, &isMapNotify, (XPointer)&data->xwindow);
-    XCheckIfEvent(display, &ev, &isUnmapNotify, (XPointer)&data->xwindow);
+    X11_XSync(display, False);
+    X11_XCheckIfEvent(display, &ev, &isMapNotify, (XPointer)&data->xwindow);
+    X11_XCheckIfEvent(display, &ev, &isUnmapNotify, (XPointer)&data->xwindow);
 
 
     SetWindowBordered(display, screen, data->xwindow,
     SetWindowBordered(display, screen, data->xwindow,
                       (window->flags & SDL_WINDOW_BORDERLESS) == 0);
                       (window->flags & SDL_WINDOW_BORDERLESS) == 0);
 
 
-    XWithdrawWindow(display, fswindow, screen);
+    X11_XWithdrawWindow(display, fswindow, screen);
 
 
     /* Wait to be unmapped. */
     /* Wait to be unmapped. */
-    XIfEvent(display, &ev, &isUnmapNotify, (XPointer)&fswindow);
-    XDestroyWindow(display, fswindow);
+    X11_XIfEvent(display, &ev, &isUnmapNotify, (XPointer)&fswindow);
+    X11_XDestroyWindow(display, fswindow);
 }
 }
 
 
 
 
@@ -1328,8 +1328,8 @@ X11_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp)
         colorcells[i].flags = DoRed | DoGreen | DoBlue;
         colorcells[i].flags = DoRed | DoGreen | DoBlue;
     }
     }
 
 
-    XStoreColors(display, colormap, colorcells, ncolors);
-    XFlush(display);
+    X11_XStoreColors(display, colormap, colorcells, ncolors);
+    X11_XFlush(display);
     SDL_free(colorcells);
     SDL_free(colorcells);
 
 
     return 0;
     return 0;
@@ -1354,7 +1354,7 @@ X11_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
         /* Try to grab the mouse */
         /* Try to grab the mouse */
         for (;;) {
         for (;;) {
             int result =
             int result =
-                XGrabPointer(display, data->xwindow, True, 0, GrabModeAsync,
+                X11_XGrabPointer(display, data->xwindow, True, 0, GrabModeAsync,
                              GrabModeAsync, data->xwindow, None, CurrentTime);
                              GrabModeAsync, data->xwindow, None, CurrentTime);
             if (result == GrabSuccess) {
             if (result == GrabSuccess) {
                 break;
                 break;
@@ -1363,7 +1363,7 @@ X11_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
         }
         }
 
 
         /* Raise the window if we grab the mouse */
         /* Raise the window if we grab the mouse */
-        XRaiseWindow(display, data->xwindow);
+        X11_XRaiseWindow(display, data->xwindow);
 
 
         /* Now grab the keyboard */
         /* Now grab the keyboard */
         hint = SDL_GetHint(SDL_HINT_GRAB_KEYBOARD);
         hint = SDL_GetHint(SDL_HINT_GRAB_KEYBOARD);
@@ -1376,14 +1376,14 @@ X11_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
             grab_keyboard = oldstyle_fullscreen;
             grab_keyboard = oldstyle_fullscreen;
         }
         }
         if (grab_keyboard) {
         if (grab_keyboard) {
-            XGrabKeyboard(display, data->xwindow, True, GrabModeAsync,
+            X11_XGrabKeyboard(display, data->xwindow, True, GrabModeAsync,
                           GrabModeAsync, CurrentTime);
                           GrabModeAsync, CurrentTime);
         }
         }
     } else {
     } else {
-        XUngrabPointer(display, CurrentTime);
-        XUngrabKeyboard(display, CurrentTime);
+        X11_XUngrabPointer(display, CurrentTime);
+        X11_XUngrabKeyboard(display, CurrentTime);
     }
     }
-    XSync(display, False);
+    X11_XSync(display, False);
 }
 }
 
 
 void
 void
@@ -1411,12 +1411,12 @@ X11_DestroyWindow(_THIS, SDL_Window * window)
         }
         }
 #ifdef X_HAVE_UTF8_STRING
 #ifdef X_HAVE_UTF8_STRING
         if (data->ic) {
         if (data->ic) {
-            XDestroyIC(data->ic);
+            X11_XDestroyIC(data->ic);
         }
         }
 #endif
 #endif
         if (data->created) {
         if (data->created) {
-            XDestroyWindow(display, data->xwindow);
-            XFlush(display);
+            X11_XDestroyWindow(display, data->xwindow);
+            X11_XFlush(display);
         }
         }
         SDL_free(data);
         SDL_free(data);
     }
     }

+ 6 - 6
src/video/x11/SDL_x11xinput2.c

@@ -36,7 +36,7 @@ static int xinput2_initialized = 0;
 static int xinput2_multitouch_supported = 0;
 static int xinput2_multitouch_supported = 0;
 #endif
 #endif
 
 
-/* Opcode returned XQueryExtension
+/* Opcode returned X11_XQueryExtension
  * It will be used in event processing
  * It will be used in event processing
  * to know that the event came from
  * to know that the event came from
  * this extension */
  * this extension */
@@ -82,16 +82,16 @@ X11_InitXinput2(_THIS)
     * "As XI2 progresses it becomes important that you use this call as the server may treat the client
     * "As XI2 progresses it becomes important that you use this call as the server may treat the client
     * differently depending on the supported version".
     * differently depending on the supported version".
     *
     *
-    * FIXME:event and err are not needed but if not passed XQueryExtension returns SegmentationFault
+    * FIXME:event and err are not needed but if not passed X11_XQueryExtension returns SegmentationFault
     */
     */
     if (!SDL_X11_HAVE_XINPUT2 ||
     if (!SDL_X11_HAVE_XINPUT2 ||
-        !XQueryExtension(data->display, "XInputExtension", &xinput2_opcode, &event, &err)) {
+        !X11_XQueryExtension(data->display, "XInputExtension", &xinput2_opcode, &event, &err)) {
         return;
         return;
     }
     }
 
 
     outmajor = major;
     outmajor = major;
     outminor = minor;
     outminor = minor;
-    if (XIQueryVersion(data->display, &outmajor, &outminor) != Success) {
+    if (X11_XIQueryVersion(data->display, &outmajor, &outminor) != Success) {
         return;
         return;
     }
     }
 
 
@@ -115,7 +115,7 @@ X11_InitXinput2(_THIS)
 
 
     XISetMask(mask, XI_RawMotion);
     XISetMask(mask, XI_RawMotion);
 
 
-    if (XISelectEvents(data->display,DefaultRootWindow(data->display),&eventmask,1) != Success) {
+    if (X11_XISelectEvents(data->display,DefaultRootWindow(data->display),&eventmask,1) != Success) {
         return;
         return;
     }
     }
 #endif
 #endif
@@ -226,7 +226,7 @@ X11_Xinput2SelectTouch(_THIS, SDL_Window *window)
     XISetMask(mask, XI_TouchUpdate);
     XISetMask(mask, XI_TouchUpdate);
     XISetMask(mask, XI_TouchEnd);
     XISetMask(mask, XI_TouchEnd);
 
 
-    XISelectEvents(data->display,window_data->xwindow,&eventmask,1);
+    X11_XISelectEvents(data->display,window_data->xwindow,&eventmask,1);
 #endif
 #endif
 }
 }