From a2bd897064734412e26912b56ed99ed74a0b732e Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Fri, 18 Oct 2013 01:36:41 -0400 Subject: [PATCH] Don't supply duplicate X11 symbols inside SDL. Fixes static linking when something else also uses X11. --- src/video/x11/SDL_x11clipboard.c | 26 +-- src/video/x11/SDL_x11dyn.c | 46 ++--- src/video/x11/SDL_x11dyn.h | 42 ++-- src/video/x11/SDL_x11events.c | 108 +++++----- src/video/x11/SDL_x11framebuffer.c | 34 ++-- src/video/x11/SDL_x11keyboard.c | 14 +- src/video/x11/SDL_x11messagebox.c | 90 ++++----- src/video/x11/SDL_x11modes.c | 116 +++++------ src/video/x11/SDL_x11mouse.c | 38 ++-- src/video/x11/SDL_x11opengl.c | 26 +-- src/video/x11/SDL_x11opengles.c | 8 +- src/video/x11/SDL_x11shape.c | 8 +- src/video/x11/SDL_x11video.c | 44 ++-- src/video/x11/SDL_x11window.c | 314 ++++++++++++++--------------- src/video/x11/SDL_x11xinput2.c | 12 +- 15 files changed, 459 insertions(+), 467 deletions(-) diff --git a/src/video/x11/SDL_x11clipboard.c b/src/video/x11/SDL_x11clipboard.c index 970aeaf15fc0f..e6ca86bc39263 100644 --- a/src/video/x11/SDL_x11clipboard.c +++ b/src/video/x11/SDL_x11clipboard.c @@ -31,7 +31,7 @@ /* If you don't support UTF-8, you might use XA_STRING here */ #ifdef X_HAVE_UTF8_STRING -#define TEXT_FORMAT XInternAtom(display, "UTF8_STRING", False) +#define TEXT_FORMAT X11_XInternAtom(display, "UTF8_STRING", False) #else #define TEXT_FORMAT XA_STRING #endif @@ -55,7 +55,7 @@ X11_SetClipboardText(_THIS, const char *text) Display *display = ((SDL_VideoData *) _this->driverdata)->display; Atom format; 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 */ window = GetWindow(_this); @@ -65,17 +65,17 @@ X11_SetClipboardText(_THIS, const char *text) /* Save the selection on the root window */ format = TEXT_FORMAT; - XChangeProperty(display, DefaultRootWindow(display), + X11_XChangeProperty(display, DefaultRootWindow(display), XA_CUT_BUFFER0, format, 8, PropModeReplace, (const unsigned char *)text, SDL_strlen(text)); 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; } @@ -97,7 +97,7 @@ X11_GetClipboardText(_THIS) char *text; Uint32 waitStart; Uint32 waitElapsed; - Atom XA_CLIPBOARD = XInternAtom(display, "CLIPBOARD", 0); + Atom XA_CLIPBOARD = X11_XInternAtom(display, "CLIPBOARD", 0); if (XA_CLIPBOARD == None) { SDL_SetError("Couldn't access X clipboard"); return SDL_strdup(""); @@ -108,15 +108,15 @@ X11_GetClipboardText(_THIS) /* Get the window that holds the selection */ window = GetWindow(_this); format = TEXT_FORMAT; - owner = XGetSelectionOwner(display, XA_CLIPBOARD); + owner = X11_XGetSelectionOwner(display, XA_CLIPBOARD); if ((owner == None) || (owner == window)) { owner = DefaultRootWindow(display); selection = XA_CUT_BUFFER0; } else { /* Request that the selection owner copy the data to our 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); /* 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) == Success) { if (seln_type == format) { @@ -149,7 +149,7 @@ X11_GetClipboardText(_THIS) text[nbytes] = '\0'; } } - XFree(src); + X11_XFree(src); } if (!text) { diff --git a/src/video/x11/SDL_x11dyn.c b/src/video/x11/SDL_x11dyn.c index f9a2fa68cb48c..24caea49f300c 100644 --- a/src/video/x11/SDL_x11dyn.c +++ b/src/video/x11/SDL_x11dyn.c @@ -103,24 +103,19 @@ X11_GetSym(const char *fnname, int *pHasModule) return fn; } +#endif /* SDL_VIDEO_DRIVER_X11_DYNAMIC */ /* Define 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; \ - 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" #undef SDL_X11_MODULE #undef SDL_X11_SYM -#endif /* SDL_VIDEO_DRIVER_X11_DYNAMIC */ /* Annoying varargs entry point... */ #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 /* 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_SYM - -#ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC static int x11_load_refcount = 0; -#endif void SDL_X11_UnloadSymbols(void) { -#ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC /* Don't actually unload if more than one module is using the libs... */ 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. */ #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" #undef SDL_X11_MODULE #undef SDL_X11_SYM #ifdef X_HAVE_UTF8_STRING - pXCreateIC = NULL; - pXGetICValues = NULL; + X11_XCreateIC = NULL; + X11_XGetICValues = NULL; #endif +#ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC for (i = 0; i < SDL_TABLESIZE(x11libs); i++) { if (x11libs[i].lib != NULL) { SDL_UnloadObject(x11libs[i].lib); x11libs[i].lib = NULL; } } +#endif } } -#endif } /* 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. */ -#ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC /* deal with multiple modules (dga, x11, etc) needing these symbols... */ if (x11_load_refcount++ == 0) { +#ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC int i; int *thismod = NULL; for (i = 0; i < SDL_TABLESIZE(x11libs); i++) { @@ -191,15 +183,15 @@ SDL_X11_LoadSymbols(void) #undef SDL_X11_SYM #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" #undef SDL_X11_MODULE #undef SDL_X11_SYM #ifdef X_HAVE_UTF8_STRING - pXCreateIC = (SDL_DYNX11FN_XCreateIC) + X11_XCreateIC = (SDL_DYNX11FN_XCreateIC) X11_GetSym("XCreateIC", &SDL_X11_HAVE_UTF8); - pXGetICValues = (SDL_DYNX11FN_XGetICValues) + X11_XGetICValues = (SDL_DYNX11FN_XGetICValues) X11_GetSym("XGetICValues", &SDL_X11_HAVE_UTF8); #endif @@ -211,19 +203,21 @@ SDL_X11_LoadSymbols(void) SDL_X11_UnloadSymbols(); rc = 0; } - } -#else + +#else /* no dynamic X11 */ + #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" #undef SDL_X11_MODULE #undef SDL_X11_SYM #ifdef X_HAVE_UTF8_STRING - pXCreateIC = XCreateIC; - pXGetICValues = XGetICValues; + X11_XCreateIC = XCreateIC; + X11_XGetICValues = XGetICValues; #endif #endif + } return rc; } diff --git a/src/video/x11/SDL_x11dyn.h b/src/video/x11/SDL_x11dyn.h index 2cebf3b8b92d9..168c07e225b62 100644 --- a/src/video/x11/SDL_x11dyn.h +++ b/src/video/x11/SDL_x11dyn.h @@ -69,35 +69,34 @@ #include #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 extern "C" { #endif /* 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 - 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 /* 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_SYM - #ifdef __cplusplus } #endif diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c index c260019c67c6e..593b2bee151b8 100644 --- a/src/video/x11/SDL_x11events.c +++ b/src/video/x11/SDL_x11events.c @@ -48,7 +48,7 @@ typedef struct { } SDL_x11Prop; /* 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) { @@ -60,8 +60,8 @@ static void X11_ReadProperty(SDL_x11Prop *p, Display *disp, Window w, Atom prop) int bytes_fetch = 0; 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; } while (bytes_left != 0); @@ -79,9 +79,9 @@ static Atom X11_PickTarget(Display *disp, Atom list[], int list_count) char *name; int 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]; - XFree(name); + X11_XFree(name); } return request; } @@ -125,8 +125,8 @@ static SDL_bool X11_KeyRepeat(Display *display, XEvent *event) struct KeyRepeatCheckData d; d.event = event; d.found = SDL_FALSE; - if (XPending(display)) - XCheckIfEvent(display, &dummyev, X11_KeyRepeatCheckIfEvent, + if (X11_XPending(display)) + X11_XCheckIfEvent(display, &dummyev, X11_KeyRepeatCheckIfEvent, (XPointer) &d); 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) { XEvent relevent; - if (XPending(display)) { + if (X11_XPending(display)) { /* according to the xlib docs, no specific mouse wheel events exist. however, mouse wheel events trigger a button press and a button release 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. - False negative: a wheel which, when rolled, doesn't have a release event generated immediately. */ - if (XCheckIfEvent(display, &relevent, X11_IsWheelCheckIfEvent, + if (X11_XCheckIfEvent(display, &relevent, X11_IsWheelCheckIfEvent, (XPointer) event)) { /* 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. */ XGenericEventCookie *cookie = &event.xcookie; - if (XGetEventData(videodata->display, cookie)) { + if (X11_XGetEventData(videodata->display, cookie)) { X11_HandleXinput2Event(videodata, cookie); - XFreeEventData(videodata->display, cookie); + X11_XFreeEventData(videodata->display, cookie); } } #endif /* SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS */ @@ -234,7 +234,7 @@ X11_DispatchFocusIn(SDL_WindowData *data) SDL_SetKeyboardFocus(data->window); #ifdef X_HAVE_UTF8_STRING if (data->ic) { - XSetICFocus(data->ic); + X11_XSetICFocus(data->ic); } #endif } @@ -248,7 +248,7 @@ X11_DispatchFocusOut(SDL_WindowData *data) SDL_SetKeyboardFocus(NULL); #ifdef X_HAVE_UTF8_STRING if (data->ic) { - XUnsetICFocus(data->ic); + X11_XUnsetICFocus(data->ic); } #endif } @@ -278,11 +278,11 @@ X11_DispatchEvent(_THIS) XClientMessageEvent m; SDL_zero(xevent); /* valgrind fix. --ryan. */ - XNextEvent(display, &xevent); + X11_XNextEvent(display, &xevent); /* filter events catchs XIM events and sends them to the correct handler */ - if (XFilterEvent(&xevent, None) == True) { + if (X11_XFilterEvent(&xevent, None) == True) { #if 0 printf("Filtered event type = %d display = %d window = %d\n", xevent.type, xevent.xany.display, xevent.xany.window); @@ -451,23 +451,23 @@ X11_DispatchEvent(_THIS) #if 1 if (videodata->key_layout[keycode] == SDL_SCANCODE_UNKNOWN && 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 - keysym = XkbKeycodeToKeysym(display, keycode, 0, 0); + keysym = X11_XkbKeycodeToKeysym(display, keycode, 0, 0); #else keysym = XKeycodeToKeysym(display, keycode, 0); #endif 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 X11 KeyCode %d (%d), X11 KeySym 0x%lX (%s).\n", keycode, keycode - min_keycode, keysym, - XKeysymToString(keysym)); + X11_XKeysymToString(keysym)); } #endif /* */ SDL_zero(text); #ifdef X_HAVE_UTF8_STRING if (data->ic) { - Xutf8LookupString(data->ic, &xevent.xkey, text, sizeof(text), + X11_Xutf8LookupString(data->ic, &xevent.xkey, text, sizeof(text), &keysym, &status); } #else @@ -549,7 +549,7 @@ X11_DispatchEvent(_THIS) X11_ReadProperty(&p, display, data->xdnd_source, videodata->XdndTypeList); /* pick one */ data->xdnd_req = X11_PickTarget(display, (Atom*)p.data, p.count); - XFree(p.data); + X11_XFree(p.data); } else { /* 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]); @@ -570,8 +570,8 @@ X11_DispatchEvent(_THIS) m.data.l[3] = 0; 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) { if (data->xdnd_req == None) { @@ -585,13 +585,13 @@ X11_DispatchEvent(_THIS) m.data.l[0] = data->xwindow; m.data.l[1] = 0; 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 { /* convert */ 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 { - 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); #endif xevent.xclient.window = root; - XSendEvent(display, root, False, SubstructureRedirectMask | SubstructureNotifyMask, &xevent); + X11_XSendEvent(display, root, False, SubstructureRedirectMask | SubstructureNotifyMask, &xevent); break; } @@ -664,13 +664,13 @@ X11_DispatchEvent(_THIS) Atom real_type; unsigned long items_read, items_left, i; - char *name = XGetAtomName(display, xevent.xproperty.atom); + char *name = X11_XGetAtomName(display, xevent.xproperty.atom); if (name) { 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 (real_type == XA_INTEGER) { int *values = (int *)propdata; @@ -714,23 +714,23 @@ X11_DispatchEvent(_THIS) printf("{"); for (i = 0; i < items_read; i++) { - char *name = XGetAtomName(display, atoms[i]); + char *name = X11_XGetAtomName(display, atoms[i]); if (name) { printf(" %s", name); - XFree(name); + X11_XFree(name); } } printf(" }\n"); } 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"); if (name) { - XFree(name); + X11_XFree(name); } } } if (status == Success) { - XFree(propdata); + X11_XFree(propdata); } #endif /* DEBUG_XEVENTS */ @@ -774,28 +774,28 @@ X11_DispatchEvent(_THIS) sevent.xselection.property = None; sevent.xselection.requestor = req->requestor; 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, &sevent.xselection.target, &seln_format, &nbytes, &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) { - XChangeProperty(display, req->requestor, req->property, + X11_XChangeProperty(display, req->requestor, req->property, sevent.xselection.target, seln_format, PropModeReplace, seln_data, nbytes); sevent.xselection.property = req->property; } else if (XA_TARGETS == req->target) { Atom SupportedFormats[] = { sevent.xselection.target, XA_TARGETS }; - XChangeProperty(display, req->requestor, req->property, + X11_XChangeProperty(display, req->requestor, req->property, XA_ATOM, 32, PropModeReplace, (unsigned char*)SupportedFormats, sizeof(SupportedFormats)/sizeof(*SupportedFormats)); 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; @@ -845,7 +845,7 @@ X11_DispatchEvent(_THIS) } } - XFree(p.data); + X11_XFree(p.data); /* send reply */ SDL_memset(&m, 0, sizeof(XClientMessageEvent)); @@ -857,9 +857,9 @@ X11_DispatchEvent(_THIS) m.data.l[0] = data->xwindow; m.data.l[1] = 1; 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 { 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 X11_Pending(Display * display) { /* 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); } @@ -919,7 +919,7 @@ X11_Pending(Display * display) FD_ZERO(&fdset); FD_SET(x11_fd, &fdset); 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(); if (!data->screensaver_activity || (int) (now - data->screensaver_activity) >= 30000) { - XResetScreenSaver(data->display); + X11_XResetScreenSaver(data->display); #if SDL_USE_LIBDBUS SDL_dbus_screensaver_tickle(_this); @@ -971,16 +971,16 @@ X11_SuspendScreenSaver(_THIS) int major_version, minor_version; 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 < 1 || (major_version == 1 && minor_version < 1)) { return; } - XScreenSaverSuspend(data->display, _this->suspend_screensaver); - XResetScreenSaver(data->display); + X11_XScreenSaverSuspend(data->display, _this->suspend_screensaver); + X11_XResetScreenSaver(data->display); } #endif diff --git a/src/video/x11/SDL_x11framebuffer.c b/src/video/x11/SDL_x11framebuffer.c index 4dfe0d174d6d2..af39147f46cc9 100644 --- a/src/video/x11/SDL_x11framebuffer.c +++ b/src/video/x11/SDL_x11framebuffer.c @@ -43,8 +43,8 @@ static int shm_errhandler(Display *d, XErrorEvent *e) static SDL_bool have_mitshm(void) { /* 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_FALSE; @@ -66,7 +66,7 @@ X11_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, /* Create the graphics context for drawing */ gcv.graphics_exposures = False; - data->gc = XCreateGC(display, data->xwindow, GCGraphicsExposures, &gcv); + data->gc = X11_XCreateGC(display, data->xwindow, GCGraphicsExposures, &gcv); if (!data->gc) { return SDL_SetError("Couldn't create graphics context"); } @@ -95,10 +95,10 @@ X11_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, shminfo->readOnly = False; if ( shminfo->shmaddr != (char *)-1 ) { 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 ) shmdt(shminfo->shmaddr); } else { @@ -109,13 +109,13 @@ X11_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, shm_error = True; } if (!shm_error) { - data->ximage = XShmCreateImage(display, data->visual, + data->ximage = X11_XShmCreateImage(display, data->visual, vinfo.depth, ZPixmap, shminfo->shmaddr, shminfo, window->w, window->h); if (!data->ximage) { - XShmDetach(display, shminfo); - XSync(display, False); + X11_XShmDetach(display, shminfo); + X11_XSync(display, False); shmdt(shminfo->shmaddr); } else { /* Done! */ @@ -132,7 +132,7 @@ X11_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, return SDL_OutOfMemory(); } - data->ximage = XCreateImage(display, data->visual, + data->ximage = X11_XCreateImage(display, data->visual, vinfo.depth, ZPixmap, 0, (char *)(*pixels), window->w, window->h, 32, 0); if (!data->ximage) { @@ -177,7 +177,7 @@ X11_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rect * rects, if (y + h > window->h) 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); } } @@ -209,12 +209,12 @@ X11_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rect * rects, if (y + h > window->h) 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); } } - XSync(display, False); + X11_XSync(display, False); return 0; } @@ -237,8 +237,8 @@ X11_DestroyWindowFramebuffer(_THIS, SDL_Window * window) #ifndef NO_SHARED_MEMORY if (data->use_mitshm) { - XShmDetach(display, &data->shminfo); - XSync(display, False); + X11_XShmDetach(display, &data->shminfo); + X11_XSync(display, False); shmdt(data->shminfo.shmaddr); data->use_mitshm = SDL_FALSE; } @@ -247,7 +247,7 @@ X11_DestroyWindowFramebuffer(_THIS, SDL_Window * window) data->ximage = NULL; } if (data->gc) { - XFreeGC(display, data->gc); + X11_XFreeGC(display, data->gc); data->gc = NULL; } } diff --git a/src/video/x11/SDL_x11keyboard.c b/src/video/x11/SDL_x11keyboard.c index 6bc7ebbfa63a5..9a2de45a0b844 100644 --- a/src/video/x11/SDL_x11keyboard.c +++ b/src/video/x11/SDL_x11keyboard.c @@ -152,7 +152,7 @@ X11_KeyCodeToSDLScancode(Display *display, KeyCode keycode) int i; #if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM - keysym = XkbKeycodeToKeysym(display, keycode, 0, 0); + keysym = X11_XkbKeycodeToKeysym(display, keycode, 0, 0); #else keysym = XKeycodeToKeysym(display, keycode, 0); #endif @@ -182,7 +182,7 @@ X11_KeyCodeToUcs4(Display *display, KeyCode keycode) KeySym keysym; #if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM - keysym = XkbKeycodeToKeysym(display, keycode, 0, 0); + keysym = X11_XkbKeycodeToKeysym(display, keycode, 0, 0); #else keysym = XKeycodeToKeysym(display, keycode, 0); #endif @@ -211,14 +211,14 @@ X11_InitKeyboard(_THIS) }; SDL_bool fingerprint_detected; - XAutoRepeatOn(data->display); + X11_XAutoRepeatOn(data->display); /* Try to determine which scancodes are being used based on fingerprint */ 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) { fingerprint[i].value = - XKeysymToKeycode(data->display, fingerprint[i].keysym) - + X11_XKeysymToKeycode(data->display, fingerprint[i].keysym) - min_keycode; } for (i = 0; i < SDL_arraysize(scancode_set); ++i) { @@ -258,14 +258,14 @@ X11_InitKeyboard(_THIS) for (i = min_keycode; i <= max_keycode; ++i) { KeySym sym; #if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM - sym = XkbKeycodeToKeysym(data->display, i, 0, 0); + sym = X11_XkbKeycodeToKeysym(data->display, i, 0, 0); #else sym = XKeycodeToKeysym(data->display, i, 0); #endif if (sym != NoSymbol) { SDL_Scancode scancode; 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); data->key_layout[i] = scancode; if (scancode == SDL_SCANCODE_UNKNOWN) { diff --git a/src/video/x11/SDL_x11messagebox.c b/src/video/x11/SDL_x11messagebox.c index f938ded8bbddf..0d0ffb75e50d2 100644 --- a/src/video/x11/SDL_x11messagebox.c +++ b/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) { 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; *pheight = overall_logical.height; } else { XCharStruct text_structure; 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, &text_structure ); *pwidth = text_structure.width; @@ -180,7 +180,7 @@ X11_MessageBoxInit( SDL_MessageBoxDataX11 *data, const SDL_MessageBoxData * mess data->numbuttons = numbuttons; data->pbuttonid = pbuttonid; - data->display = XOpenDisplay( NULL ); + data->display = X11_XOpenDisplay( NULL ); if ( !data->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) { char **missing = NULL; 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); if ( missing != NULL ) { - XFreeStringList(missing); + X11_XFreeStringList(missing); } if ( data->font_set == NULL ) { return SDL_SetError("Couldn't load font %s", g_MessageBoxFont); } } else { - data->font_struct = XLoadQueryFont( data->display, g_MessageBoxFontLatin1 ); + data->font_struct = X11_XLoadQueryFont( data->display, g_MessageBoxFontLatin1 ); if ( data->font_struct == NULL ) { return SDL_SetError("Couldn't load font %s", g_MessageBoxFontLatin1); } @@ -338,23 +338,23 @@ static void X11_MessageBoxShutdown( SDL_MessageBoxDataX11 *data ) { if ( data->font_set != NULL ) { - XFreeFontSet( data->display, data->font_set ); + X11_XFreeFontSet( data->display, data->font_set ); data->font_set = NULL; } if ( data->font_struct != NULL ) { - XFreeFont( data->display, data->font_struct ); + X11_XFreeFont( data->display, data->font_struct ); data->font_struct = NULL; } if ( data->display ) { 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; } - XCloseDisplay( data->display ); + X11_XCloseDisplay( data->display ); data->display = NULL; } } @@ -384,7 +384,7 @@ X11_MessageBoxCreateWindow( SDL_MessageBoxDataX11 *data ) StructureNotifyMask | FocusChangeMask | PointerMotionMask; wnd_attr.event_mask = data->event_mask; - data->window = XCreateWindow( + data->window = X11_XCreateWindow( display, RootWindow(display, data->screen), 0, 0, data->dialog_width, data->dialog_height, @@ -396,31 +396,31 @@ X11_MessageBoxCreateWindow( SDL_MessageBoxDataX11 *data ) if ( windowdata ) { /* 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 */ - 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 ) { XWindowAttributes attrib; Window dummy; - XGetWindowAttributes(display, windowdata->xwindow, &attrib); + X11_XGetWindowAttributes(display, windowdata->xwindow, &attrib); x = attrib.x + ( attrib.width - data->dialog_width ) / 2; 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 { x = ( DisplayWidth( display, data->screen ) - data->dialog_width ) / 2; 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 ) { sizehints->flags = USPosition | USSize | PMaxSize | PMinSize; sizehints->x = x; @@ -431,12 +431,12 @@ X11_MessageBoxCreateWindow( SDL_MessageBoxDataX11 *data ) sizehints->min_width = sizehints->max_width = data->dialog_width; 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; } @@ -448,19 +448,19 @@ X11_MessageBoxDraw( SDL_MessageBoxDataX11 *data, GC ctx ) Window window = data->window; 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++ ) { TextLineData *plinedata = &data->linedata[ i ]; 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, plinedata->text, plinedata->length ); } else { - XDrawString( display, window, ctx, + X11_XDrawString( display, window, ctx, data->xtext, data->ytext + i * data->text_height, 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 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.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.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_TEXT ] ); if (SDL_X11_HAVE_UTF8) { - Xutf8DrawString( display, window, data->font_set, ctx, + X11_Xutf8DrawString( display, window, data->font_set, ctx, buttondatax11->x + offset, buttondatax11->y + offset, buttondata->text, buttondatax11->length ); } else { - XDrawString( display, window, ctx, + X11_XDrawString( display, window, ctx, buttondatax11->x + offset, buttondatax11->y + offset, buttondata->text, buttondatax11->length ); } @@ -519,7 +519,7 @@ X11_MessageBoxLoop( SDL_MessageBoxDataX11 *data ) 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 ) { return SDL_SetError("Couldn't create graphics context"); } @@ -531,11 +531,11 @@ X11_MessageBoxLoop( SDL_MessageBoxDataX11 *data ) XEvent e; 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. */ - if ( ( e.type != Expose ) && XFilterEvent( &e, None ) ) + if ( ( e.type != Expose ) && X11_XFilterEvent( &e, None ) ) continue; switch( e.type ) { @@ -574,12 +574,12 @@ X11_MessageBoxLoop( SDL_MessageBoxDataX11 *data ) case KeyPress: /* 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; case KeyRelease: { 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 ( key != last_key_pressed ) @@ -637,7 +637,7 @@ X11_MessageBoxLoop( SDL_MessageBoxDataX11 *data ) } } - XFreeGC( data->display, ctx ); + X11_XFreeGC( data->display, ctx ); return 0; } @@ -667,7 +667,7 @@ X11_ShowMessageBoxImpl(const SDL_MessageBoxData *messageboxdata, int *buttonid) #endif /* This code could get called from multiple threads maybe? */ - XInitThreads(); + X11_XInitThreads(); /* Initialize the return buttonid value to -1 (for error or dialogbox closed). */ *buttonid = -1; @@ -707,7 +707,7 @@ X11_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) int status = 0; /* 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) { return X11_ShowMessageBoxImpl(messageboxdata, buttonid); /* oh well. */ diff --git a/src/video/x11/SDL_x11modes.c b/src/video/x11/SDL_x11modes.c index 472416ccda18f..a4c242cdc5a36 100644 --- a/src/video/x11/SDL_x11modes.c +++ b/src/video/x11/SDL_x11modes.c @@ -54,20 +54,20 @@ get_visualinfo(Display * display, int screen, XVisualInfo * vinfo) SDL_zero(template); template.visualid = SDL_strtol(visual_id, NULL, 0); - vi = XGetVisualInfo(display, VisualIDMask, &template, &nvis); + vi = X11_XGetVisualInfo(display, VisualIDMask, &template, &nvis); if (vi) { *vinfo = *vi; - XFree(vi); + X11_XFree(vi); return 0; } } depth = DefaultDepth(display, screen); 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 -1; @@ -79,11 +79,11 @@ X11_GetVisualInfoFromVisual(Display * display, Visual * visual, XVisualInfo * vi XVisualInfo *vi; 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) { *vinfo = *vi; - XFree(vi); + X11_XFree(vi); return 0; } return -1; @@ -108,7 +108,7 @@ X11_GetPixelFormatFromVisualInfo(Display * display, XVisualInfo * vinfo) bpp = vinfo->depth; if (bpp == 24) { int i, n; - XPixmapFormatValues *p = XListPixmapFormats(display, &n); + XPixmapFormatValues *p = X11_XListPixmapFormats(display, &n); if (p) { for (i = 0; i < n; ++i) { if (p[i].depth == 24) { @@ -116,7 +116,7 @@ X11_GetPixelFormatFromVisualInfo(Display * display, XVisualInfo * vinfo) break; } } - XFree(p); + X11_XFree(p); } } @@ -178,9 +178,9 @@ CheckXinerama(Display * display, int *major, int *minor) } /* 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 printf("Xinerama not active on the display\n"); #endif @@ -228,7 +228,7 @@ CheckXRandR(Display * display, int *major, int *minor) } /* Query the extension version */ - if (!XRRQueryVersion(display, major, minor)) { + if (!X11_XRRQueryVersion(display, major, minor)) { #ifdef X11MODES_DEBUG printf("XRandR not active on the display\n"); #endif @@ -261,10 +261,10 @@ SetXRandRModeInfo(Display *display, XRRScreenResources *res, XRROutputInfo *outp Rotation rotation = 0; const XRRModeInfo *info = &res->modes[i]; - crtc = XRRGetCrtcInfo(display, res, output_info->crtc); + crtc = X11_XRRGetCrtcInfo(display, res, output_info->crtc); if (crtc) { rotation = crtc->rotation; - XRRFreeCrtcInfo(crtc); + X11_XRRFreeCrtcInfo(crtc); } if (rotation & (XRANDR_ROTATION_LEFT|XRANDR_ROTATION_RIGHT)) { @@ -313,8 +313,8 @@ CheckVidMode(Display * display, int *major, int *minor) /* Query the extension version */ 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 printf("XVidMode not active on the display\n"); #endif @@ -335,7 +335,7 @@ Bool XF86VidModeGetModeInfo(Display * dpy, int scr, XF86VidModeModeLine l; SDL_zerop(info); SDL_zero(l); - retval = XF86VidModeGetModeLine(dpy, scr, &dotclock, &l); + retval = X11_XF86VidModeGetModeLine(dpy, scr, &dotclock, &l); info->dotclock = dotclock; info->hdisplay = l.hdisplay; info->hsyncstart = l.hsyncstart; @@ -397,7 +397,7 @@ X11_InitModes(_THIS) * or newer of the Nvidia binary drivers */ if (CheckXinerama(data->display, &xinerama_major, &xinerama_minor)) { - xinerama = XineramaQueryScreens(data->display, &screencount); + xinerama = X11_XineramaQueryScreens(data->display, &screencount); if (xinerama) { use_xinerama = xinerama_major * 100 + xinerama_minor; } @@ -501,7 +501,7 @@ X11_InitModes(_THIS) displaydata->depth = vinfo.depth; displaydata->scanline_pad = SDL_BYTESPERPIXEL(mode.format) * 8; - pixmapFormats = XListPixmapFormats(data->display, &n); + pixmapFormats = X11_XListPixmapFormats(data->display, &n); if (pixmapFormats) { for (i = 0; i < n; ++i) { if (pixmapFormats[i].depth == displaydata->depth) { @@ -509,7 +509,7 @@ X11_InitModes(_THIS) break; } } - XFree(pixmapFormats); + X11_XFree(pixmapFormats); } #if SDL_VIDEO_DRIVER_X11_XINERAMA @@ -526,13 +526,13 @@ X11_InitModes(_THIS) #if SDL_VIDEO_DRIVER_X11_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) { XRROutputInfo *output_info; XRRCrtcInfo *crtc; int output; - Atom EDID = XInternAtom(data->display, "EDID", False); + Atom EDID = X11_XInternAtom(data->display, "EDID", False); Atom *props; int nprop; unsigned long width_mm; @@ -540,10 +540,10 @@ X11_InitModes(_THIS) int inches = 0; 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 || output_info->connection == RR_Disconnected) { - XRRFreeOutputInfo(output_info); + X11_XRRFreeOutputInfo(output_info); continue; } @@ -551,10 +551,10 @@ X11_InitModes(_THIS) We're checking the crtc position, but that may not be a valid test 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) { - XRRFreeOutputInfo(output_info); - XRRFreeCrtcInfo(crtc); + X11_XRRFreeOutputInfo(output_info); + X11_XRRFreeCrtcInfo(crtc); continue; } @@ -570,7 +570,7 @@ X11_InitModes(_THIS) SDL_strlcpy(display_name, output_info->name, sizeof(display_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) { unsigned char *prop; int actual_format; @@ -578,7 +578,7 @@ X11_InitModes(_THIS) Atom actual_type; if (props[i] == EDID) { - if (XRRGetOutputProperty(data->display, + if (X11_XRRGetOutputProperty(data->display, res->outputs[output], props[i], 0, 100, False, False, AnyPropertyType, @@ -593,13 +593,13 @@ X11_InitModes(_THIS) SDL_strlcpy(display_name, info->dsc_product_name, sizeof(display_name)); free(info); } - XFree(prop); + X11_XFree(prop); } break; } } if (props) { - XFree(props); + X11_XFree(props); } if (*display_name && inches) { @@ -610,8 +610,8 @@ X11_InitModes(_THIS) printf("Display name: %s\n", display_name); #endif - XRRFreeOutputInfo(output_info); - XRRFreeCrtcInfo(crtc); + X11_XRRFreeOutputInfo(output_info); + X11_XRRFreeCrtcInfo(crtc); break; } #ifdef X11MODES_DEBUG @@ -619,7 +619,7 @@ X11_InitModes(_THIS) printf("Couldn't find XRandR CRTC at %d,%d\n", displaydata->x, displaydata->y); } #endif - XRRFreeScreenResources(res); + X11_XRRFreeScreenResources(res); } #endif /* SDL_VIDEO_DRIVER_X11_XRANDR */ @@ -652,7 +652,7 @@ X11_InitModes(_THIS) } #if SDL_VIDEO_DRIVER_X11_XINERAMA - if (xinerama) XFree(xinerama); + if (xinerama) X11_XFree(xinerama); #endif if (_this->num_displays == 0) { @@ -725,13 +725,13 @@ X11_GetDisplayModes(_THIS, SDL_VideoDisplay * sdl_display) if (data->use_xrandr) { XRRScreenResources *res; - res = XRRGetScreenResources (display, RootWindow(display, data->screen)); + res = X11_XRRGetScreenResources (display, RootWindow(display, data->screen)); if (res) { SDL_DisplayModeData *modedata; XRROutputInfo *output_info; 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) { for (i = 0; i < output_info->nmode; ++i) { 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; } @@ -756,7 +756,7 @@ X11_GetDisplayModes(_THIS, SDL_VideoDisplay * sdl_display) #if SDL_VIDEO_DRIVER_X11_XVIDMODE if (data->use_vidmode && - XF86VidModeGetAllModeLines(display, data->vidmode_screen, &nmodes, &modes)) { + X11_XF86VidModeGetAllModeLines(display, data->vidmode_screen, &nmodes, &modes)) { int i; #ifdef X11MODES_DEBUG @@ -780,7 +780,7 @@ X11_GetDisplayModes(_THIS, SDL_VideoDisplay * sdl_display) SDL_free(modedata); } } - XFree(modes); + X11_XFree(modes); return; } #endif /* SDL_VIDEO_DRIVER_X11_XVIDMODE */ @@ -811,41 +811,41 @@ X11_SetDisplayMode(_THIS, SDL_VideoDisplay * sdl_display, SDL_DisplayMode * mode XRRCrtcInfo *crtc; Status status; - res = XRRGetScreenResources (display, RootWindow(display, data->screen)); + res = X11_XRRGetScreenResources (display, RootWindow(display, data->screen)); if (!res) { 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) { - XRRFreeScreenResources(res); + X11_XRRFreeScreenResources(res); 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) { - XRRFreeOutputInfo(output_info); - XRRFreeScreenResources(res); + X11_XRRFreeOutputInfo(output_info); + X11_XRRFreeScreenResources(res); 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, &data->xrandr_output, 1); - XRRFreeCrtcInfo(crtc); - XRRFreeOutputInfo(output_info); - XRRFreeScreenResources(res); + X11_XRRFreeCrtcInfo(crtc); + X11_XRRFreeOutputInfo(output_info); + X11_XRRFreeScreenResources(res); if (status != Success) { - return SDL_SetError("XRRSetCrtcConfig failed"); + return SDL_SetError("X11_XRRSetCrtcConfig failed"); } } #endif /* SDL_VIDEO_DRIVER_X11_XRANDR */ #if SDL_VIDEO_DRIVER_X11_XVIDMODE 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 */ @@ -872,11 +872,11 @@ X11_GetDisplayBounds(_THIS, SDL_VideoDisplay * sdl_display, SDL_Rect * rect) if (data->use_xinerama) { Display *display = ((SDL_VideoData *) _this->driverdata)->display; int screencount; - XineramaScreenInfo *xinerama = XineramaQueryScreens(display, &screencount); + XineramaScreenInfo *xinerama = X11_XineramaQueryScreens(display, &screencount); if (xinerama) { rect->x = xinerama[data->xinerama_screen].x_org; rect->y = xinerama[data->xinerama_screen].y_org; - XFree(xinerama); + X11_XFree(xinerama); } } #endif /* SDL_VIDEO_DRIVER_X11_XINERAMA */ diff --git a/src/video/x11/SDL_x11mouse.c b/src/video/x11/SDL_x11mouse.c index 441ecdfe370e7..4bcd9d6c8585e 100644 --- a/src/video/x11/SDL_x11mouse.c +++ b/src/video/x11/SDL_x11mouse.c @@ -50,12 +50,12 @@ X11_CreateEmptyCursor() SDL_zero(data); color.red = color.green = color.blue = 0; - pixmap = XCreateBitmapFromData(display, DefaultRootWindow(display), + pixmap = X11_XCreateBitmapFromData(display, DefaultRootWindow(display), data, 1, 1); if (pixmap) { - x11_empty_cursor = XCreatePixmapCursor(display, pixmap, pixmap, + x11_empty_cursor = X11_XCreatePixmapCursor(display, pixmap, pixmap, &color, &color, 0, 0); - XFreePixmap(display, pixmap); + X11_XFreePixmap(display, pixmap); } } return x11_empty_cursor; @@ -65,7 +65,7 @@ static void X11_DestroyEmptyCursor(void) { if (x11_empty_cursor != None) { - XFreeCursor(GetDisplay(), x11_empty_cursor); + X11_XFreeCursor(GetDisplay(), x11_empty_cursor); x11_empty_cursor = None; } } @@ -94,7 +94,7 @@ X11_CreateXCursorCursor(SDL_Surface * surface, int hot_x, int hot_y) Cursor cursor = None; XcursorImage *image; - image = XcursorImageCreate(surface->w, surface->h); + image = X11_XcursorImageCreate(surface->w, surface->h); if (!image) { SDL_OutOfMemory(); 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_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; } @@ -186,16 +186,16 @@ X11_CreatePixmapCursor(SDL_Surface * surface, int hot_x, int hot_y) } else bg.red = bg.green = bg.blue = 0; - data_pixmap = XCreateBitmapFromData(display, DefaultRootWindow(display), + data_pixmap = X11_XCreateBitmapFromData(display, DefaultRootWindow(display), (char*)data_bits, surface->w, surface->h); - mask_pixmap = XCreateBitmapFromData(display, DefaultRootWindow(display), + mask_pixmap = X11_XCreateBitmapFromData(display, DefaultRootWindow(display), (char*)mask_bits, 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); - XFreePixmap(display, data_pixmap); - XFreePixmap(display, mask_pixmap); + X11_XFreePixmap(display, data_pixmap); + X11_XFreePixmap(display, mask_pixmap); return cursor; } @@ -256,7 +256,7 @@ X11_CreateSystemCursor(SDL_SystemCursor id) if (cursor) { Cursor x11_cursor; - x11_cursor = XCreateFontCursor(GetDisplay(), shape); + x11_cursor = X11_XCreateFontCursor(GetDisplay(), shape); cursor->driverdata = (void*)x11_cursor; } else { @@ -272,7 +272,7 @@ X11_FreeCursor(SDL_Cursor * cursor) Cursor x11_cursor = (Cursor)cursor->driverdata; if (x11_cursor != None) { - XFreeCursor(GetDisplay(), x11_cursor); + X11_XFreeCursor(GetDisplay(), x11_cursor); } SDL_free(cursor); } @@ -298,12 +298,12 @@ X11_ShowCursor(SDL_Cursor * cursor) for (window = video->windows; window; window = window->next) { data = (SDL_WindowData *)window->driverdata; if (x11_cursor != None) { - XDefineCursor(display, data->xwindow, x11_cursor); + X11_XDefineCursor(display, data->xwindow, x11_cursor); } else { - XUndefineCursor(display, data->xwindow); + X11_XUndefineCursor(display, data->xwindow); } } - XFlush(display); + X11_XFlush(display); } return 0; } @@ -314,8 +314,8 @@ X11_WarpMouse(SDL_Window * window, int x, int y) SDL_WindowData *data = (SDL_WindowData *) window->driverdata; 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 diff --git a/src/video/x11/SDL_x11opengl.c b/src/video/x11/SDL_x11opengl.c index 67a4b06cc6260..74165f407abe2 100644 --- a/src/video/x11/SDL_x11opengl.c +++ b/src/video/x11/SDL_x11opengl.c @@ -320,16 +320,16 @@ X11_GL_InitExtensions(_THIS) xattr.background_pixel = 0; xattr.border_pixel = 0; xattr.colormap = - XCreateColormap(display, RootWindow(display, screen), vinfo->visual, + X11_XCreateColormap(display, RootWindow(display, screen), vinfo->visual, 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, (CWBackPixel | CWBorderPixel | CWColormap), &xattr); context = _this->gl_data->glXCreateContext(display, vinfo, NULL, True); if (context) { _this->gl_data->glXMakeCurrent(display, w, context); } - XFree(vinfo); + X11_XFree(vinfo); glXQueryExtensionsStringFunc = (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->glXDestroyContext(display, context); } - XDestroyWindow(display, w); + X11_XDestroyWindow(display, w); 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. */ - XSync(display, False); + X11_XSync(display, False); 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.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 (_this->gl_config.major_version < 3 && _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) { SDL_SetError("Could not create GL context"); @@ -801,7 +801,7 @@ X11_GL_DeleteContext(_THIS, SDL_GLContext context) return; } _this->gl_data->glXDestroyContext(display, glx_context); - XSync(display, False); + X11_XSync(display, False); } #endif /* SDL_VIDEO_OPENGL_GLX */ diff --git a/src/video/x11/SDL_x11opengles.c b/src/video/x11/SDL_x11opengles.c index 98183258f8cae..f972ceeeb6d5c 100644 --- a/src/video/x11/SDL_x11opengles.c +++ b/src/video/x11/SDL_x11opengles.c @@ -74,13 +74,13 @@ X11_GLES_GetVisual(_THIS, Display * display, int screen) &visual_id) == EGL_FALSE || !visual_id) { /* Use the default visual when all else fails */ vi_in.screen = screen; - egl_visualinfo = XGetVisualInfo(display, + egl_visualinfo = X11_XGetVisualInfo(display, VisualScreenMask, &vi_in, &out_count); } else { vi_in.screen = screen; 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; @@ -93,9 +93,9 @@ X11_GLES_CreateContext(_THIS, SDL_Window * window) SDL_WindowData *data = (SDL_WindowData *) window->driverdata; Display *display = data->videodata->display; - XSync(display, False); + X11_XSync(display, False); context = SDL_EGL_CreateContext(_this, data->egl_surface); - XSync(display, False); + X11_XSync(display, False); return context; } diff --git a/src/video/x11/SDL_x11shape.c b/src/video/x11/SDL_x11shape.c index 67eeade8a0570..af89851e68097 100644 --- a/src/video/x11/SDL_x11shape.c +++ b/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); 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 return 0; diff --git a/src/video/x11/SDL_x11video.c b/src/video/x11/SDL_x11video.c index 5ed47d5e82780..c84d4ec6811df 100644 --- a/src/video/x11/SDL_x11video.c +++ b/src/video/x11/SDL_x11video.c @@ -230,9 +230,9 @@ X11_Available(void) { Display *display = NULL; if (SDL_X11_LoadSymbols()) { - display = XOpenDisplay(NULL); + display = X11_XOpenDisplay(NULL); if (display != NULL) { - XCloseDisplay(display); + X11_XCloseDisplay(display); } SDL_X11_UnloadSymbols(); } @@ -244,7 +244,7 @@ X11_DeleteDevice(SDL_VideoDevice * device) { SDL_VideoData *data = (SDL_VideoData *) device->driverdata; if (data->display) { - XCloseDisplay(data->display); + X11_XCloseDisplay(data->display); } SDL_free(data->windowlist); SDL_free(device->driverdata); @@ -296,7 +296,7 @@ X11_CreateDevice(int devindex) /* Need for threading gl calls. This is also required for the proprietary nVidia driver to be threaded. */ - XInitThreads(); + X11_XInitThreads(); /* Initialize all variables that we clean on shutdown */ device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); @@ -313,14 +313,14 @@ X11_CreateDevice(int devindex) device->driverdata = data; /* 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; } else { local_X11 = 0; } */ - data->display = XOpenDisplay(display); + data->display = X11_XOpenDisplay(display); #if defined(__osf__) && defined(SDL_VIDEO_DRIVER_X11_DYNAMIC) /* On Tru64 if linking without -lX11, it fails and you get following message. * Xlib: connection to ":0.0" refused by server @@ -331,7 +331,7 @@ X11_CreateDevice(int devindex) */ if (data->display == NULL) { SDL_Delay(1000); - data->display = XOpenDisplay(display); + data->display = X11_XOpenDisplay(display); } #endif if (data->display == NULL) { @@ -341,12 +341,12 @@ X11_CreateDevice(int devindex) return NULL; } #ifdef X11_DEBUG - XSynchronize(data->display, True); + X11_XSynchronize(data->display, True); #endif /* Hook up an X11 error handler to recover the desktop resolution. */ safety_net_triggered = SDL_FALSE; - orig_x11_errhandler = XSetErrorHandler(X11_SafetyNetErrHandler); + orig_x11_errhandler = X11_XSetErrorHandler(X11_SafetyNetErrHandler); /* Set the function pointers */ device->VideoInit = X11_VideoInit; @@ -448,31 +448,31 @@ X11_CheckWindowManager(_THIS) #endif /* 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) { wm_window = ((Window*)propdata)[0]; } if (propdata) { - XFree(propdata); + X11_XFree(propdata); } 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]) { wm_window = None; } if (propdata) { - XFree(propdata); + X11_XFree(propdata); } } /* Reset the error handler, we're done checking */ - XSync(display, False); - XSetErrorHandler(handler); + X11_XSync(display, False); + X11_XSetErrorHandler(handler); if (!wm_window) { #ifdef DEBUG_WINDOW_MANAGER @@ -505,12 +505,12 @@ X11_VideoInit(_THIS) #ifdef X_HAVE_UTF8_STRING if (SDL_X11_HAVE_UTF8) { data->im = - XOpenIM(data->display, NULL, data->classname, data->classname); + X11_XOpenIM(data->display, NULL, data->classname, data->classname); } #endif /* 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_DELETE_WINDOW); GET_ATOM(_NET_WM_STATE); @@ -568,7 +568,7 @@ X11_VideoQuit(_THIS) SDL_free(data->classname); #ifdef X_HAVE_UTF8_STRING if (data->im) { - XCloseIM(data->im); + X11_XCloseIM(data->im); } #endif diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c index 18ff443ad3ed6..120b803cae393 100644 --- a/src/video/x11/SDL_x11window.c +++ b/src/video/x11/SDL_x11window.c @@ -61,11 +61,11 @@ static Bool isConfigureNotify(Display *dpy, XEvent *ev, XPointer win) /* 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(); - while (!XCheckIfEvent(display, event_return, predicate, arg)) { + while (!X11_XCheckIfEvent(display, event_return, predicate, arg)) { if ((SDL_GetTicks() - start) >= timeoutMS) { return False; } @@ -88,7 +88,7 @@ X11_IsWindowMapped(_THIS, SDL_Window * window) SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; XWindowAttributes attr; - XGetWindowAttributes(videodata->display, data->xwindow, &attr); + X11_XGetWindowAttributes(videodata->display, data->xwindow, &attr); if (attr.map_state != IsUnmapped) { return SDL_TRUE; } else { @@ -110,7 +110,7 @@ X11_IsActionAllowed(SDL_Window *window, Atom action) Atom *list; 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 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); } 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; Uint32 flags = 0; - if (XGetWindowProperty(display, xwindow, _NET_WM_STATE, + if (X11_XGetWindowProperty(display, xwindow, _NET_WM_STATE, 0l, maxLength, False, XA_ATOM, &actualType, &actualFormat, &numItems, &bytesAfter, &propertyValue) == Success) { @@ -209,7 +209,7 @@ X11_GetNetWMState(_THIS, Window xwindow) } else if (fullscreen == 1) { flags |= SDL_WINDOW_FULLSCREEN; } - XFree(propertyValue); + X11_XFree(propertyValue); } /* 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 if (SDL_X11_HAVE_UTF8 && videodata->im) { data->ic = - pXCreateIC(videodata->im, XNClientWindow, w, XNFocusWindow, w, + X11_XCreateIC(videodata->im, XNClientWindow, w, XNFocusWindow, w, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, XNResourceName, videodata->classname, XNResourceClass, videodata->classname, NULL); @@ -270,7 +270,7 @@ SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created) { XWindowAttributes attrib; - XGetWindowAttributes(data->videodata->display, w, &attrib); + X11_XGetWindowAttributes(data->videodata->display, w, &attrib); window->x = attrib.x; window->y = attrib.y; window->w = attrib.width; @@ -289,7 +289,7 @@ SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created) { Window FocalWindow; int RevertTo=0; - XGetInputFocus(data->videodata->display, &FocalWindow, &RevertTo); + X11_XGetInputFocus(data->videodata->display, &FocalWindow, &RevertTo); if (FocalWindow==w) { 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. */ - Atom WM_HINTS = XInternAtom(display, "_MOTIF_WM_HINTS", True); + Atom WM_HINTS = X11_XInternAtom(display, "_MOTIF_WM_HINTS", True); if (WM_HINTS != None) { /* Hints used by Motif compliant window managers */ struct @@ -332,11 +332,11 @@ SetWindowBordered(Display *display, int screen, Window window, SDL_bool border) (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, sizeof(MWMHints) / 4); } 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; depth = vinfo->depth; - XFree(vinfo); + X11_XFree(vinfo); } else #endif { @@ -410,7 +410,7 @@ X11_CreateWindow(_THIS, SDL_Window * window) int rshift, gshift, bshift; xattr.colormap = - XCreateColormap(display, RootWindow(display, screen), + X11_XCreateColormap(display, RootWindow(display, screen), visual, AllocAll); /* 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; } - XStoreColors(display, xattr.colormap, colorcells, ncolors); + X11_XStoreColors(display, xattr.colormap, colorcells, ncolors); SDL_free(colorcells); } else { xattr.colormap = - XCreateColormap(display, RootWindow(display, screen), + X11_XCreateColormap(display, RootWindow(display, screen), visual, AllocNone); } - w = XCreateWindow(display, RootWindow(display, screen), + w = X11_XCreateWindow(display, RootWindow(display, screen), window->x, window->y, window->w, window->h, 0, depth, InputOutput, visual, (CWOverrideRedirect | CWBackPixmap | CWBorderPixel | @@ -492,7 +492,7 @@ X11_CreateWindow(_THIS, SDL_Window * window) SetWindowBordered(display, screen, w, (window->flags & SDL_WINDOW_BORDERLESS) == 0); - sizehints = XAllocSizeHints(); + sizehints = X11_XAllocSizeHints(); /* Setup the normal size hints */ sizehints->flags = 0; if (!(window->flags & SDL_WINDOW_RESIZABLE)) { @@ -505,25 +505,25 @@ X11_CreateWindow(_THIS, SDL_Window * window) sizehints->flags |= USPosition; /* Setup the input hints so we get keyboard input */ - wmhints = XAllocWMHints(); + wmhints = X11_XAllocWMHints(); wmhints->input = True; wmhints->flags = InputHint; /* Setup the class hints so we can get an icon (AfterStep) */ - classhints = XAllocClassHint(); + classhints = X11_XAllocClassHint(); classhints->res_name = data->classname; classhints->res_class = data->classname; /* 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 */ 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); } @@ -531,14 +531,14 @@ X11_CreateWindow(_THIS, SDL_Window * window) X11_SetNetWMState(_this, w, window->flags); /* 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, (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, (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->_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) { - XDestroyWindow(display, w); + X11_XDestroyWindow(display, w); return -1; } windowdata = (SDL_WindowData *) window->driverdata; @@ -564,7 +564,7 @@ X11_CreateWindow(_THIS, SDL_Window * window) #endif ) { if (!_this->egl_data) { - XDestroyWindow(display, w); + X11_XDestroyWindow(display, w); return -1; } @@ -572,7 +572,7 @@ X11_CreateWindow(_THIS, SDL_Window * window) windowdata->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType) w); if (windowdata->egl_surface == EGL_NO_SURFACE) { - XDestroyWindow(display, w); + X11_XDestroyWindow(display, w); return SDL_SetError("Could not create GLES window surface"); } } @@ -581,25 +581,25 @@ X11_CreateWindow(_THIS, SDL_Window * window) #ifdef X_HAVE_UTF8_STRING if (SDL_X11_HAVE_UTF8 && windowdata->ic) { - pXGetICValues(windowdata->ic, XNFilterEvents, &fevent, NULL); + X11_XGetICValues(windowdata->ic, XNFilterEvents, &fevent, NULL); } #endif X11_Xinput2SelectTouch(_this, window); - XSelectInput(display, w, + X11_XSelectInput(display, w, (FocusChangeMask | EnterWindowMask | LeaveWindowMask | ExposureMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask | KeyPressMask | KeyReleaseMask | PropertyChangeMask | StructureNotifyMask | 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, (unsigned char*)&xdnd_version, 1); - XFlush(display); + X11_XFlush(display); return 0; } @@ -628,14 +628,14 @@ X11_GetWindowTitle(_THIS, Window xwindow) unsigned char *propdata; 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, &items_read, &items_left, &propdata); if (status == Success && propdata) { title = SDL_strdup(SDL_static_cast(char*, propdata)); - XFree(propdata); + X11_XFree(propdata); } 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, &items_read, &items_left, &propdata); if (status == Success && propdata) { @@ -668,21 +668,21 @@ X11_SetWindowTitle(_THIS, SDL_Window * window) SDL_OutOfMemory(); return; } - status = XStringListToTextProperty(&title_locale, 1, &titleprop); + status = X11_XStringListToTextProperty(&title_locale, 1, &titleprop); SDL_free(title_locale); 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 if (SDL_X11_HAVE_UTF8) { status = - Xutf8TextListToTextProperty(display, (char **) &title, 1, + X11_Xutf8TextListToTextProperty(display, (char **) &title, 1, XUTF8StringStyle, &titleprop); if (status == Success) { - XSetTextProperty(display, data->xwindow, &titleprop, + X11_XSetTextProperty(display, data->xwindow, &titleprop, _NET_WM_NAME); - XFree(titleprop.value); + X11_XFree(titleprop.value); } } #endif @@ -693,27 +693,27 @@ X11_SetWindowTitle(_THIS, SDL_Window * window) SDL_OutOfMemory(); return; } - status = XStringListToTextProperty(&icon_locale, 1, &iconprop); + status = X11_XStringListToTextProperty(&icon_locale, 1, &iconprop); SDL_free(icon_locale); if (status) { - XSetTextProperty(display, data->xwindow, &iconprop, + X11_XSetTextProperty(display, data->xwindow, &iconprop, XA_WM_ICON_NAME); - XFree(iconprop.value); + X11_XFree(iconprop.value); } #ifdef X_HAVE_UTF8_STRING if (SDL_X11_HAVE_UTF8) { status = - Xutf8TextListToTextProperty(display, (char **) &icon, 1, + X11_Xutf8TextListToTextProperty(display, (char **) &icon, 1, XUTF8StringStyle, &iconprop); if (status == Success) { - XSetTextProperty(display, data->xwindow, &iconprop, + X11_XSetTextProperty(display, data->xwindow, &iconprop, _NET_WM_ICON_NAME); - XFree(iconprop.value); + X11_XFree(iconprop.value); } } #endif } - XFlush(display); + X11_XFlush(display); } void @@ -745,15 +745,15 @@ X11_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon) *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, propsize); } SDL_free(propdata); } else { - XDeleteProperty(display, data->xwindow, _NET_WM_ICON); + X11_XDeleteProperty(display, data->xwindow, _NET_WM_ICON); } - XFlush(display); + X11_XFlush(display); } void @@ -762,8 +762,8 @@ X11_SetWindowPosition(_THIS, SDL_Window * window) SDL_WindowData *data = (SDL_WindowData *) window->driverdata; 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 @@ -773,26 +773,26 @@ X11_SetWindowMinimumSize(_THIS, SDL_Window * window) Display *display = data->videodata->display; if (window->flags & SDL_WINDOW_RESIZABLE) { - XSizeHints *sizehints = XAllocSizeHints(); + XSizeHints *sizehints = X11_XAllocSizeHints(); long userhints; - XGetWMNormalHints(display, data->xwindow, sizehints, &userhints); + X11_XGetWMNormalHints(display, data->xwindow, sizehints, &userhints); sizehints->min_width = window->min_w; sizehints->min_height = window->min_h; sizehints->flags |= PMinSize; - XSetWMNormalHints(display, data->xwindow, sizehints); + X11_XSetWMNormalHints(display, data->xwindow, sizehints); - XFree(sizehints); + X11_XFree(sizehints); /* 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 @@ -802,26 +802,26 @@ X11_SetWindowMaximumSize(_THIS, SDL_Window * window) Display *display = data->videodata->display; if (window->flags & SDL_WINDOW_RESIZABLE) { - XSizeHints *sizehints = XAllocSizeHints(); + XSizeHints *sizehints = X11_XAllocSizeHints(); long userhints; - XGetWMNormalHints(display, data->xwindow, sizehints, &userhints); + X11_XGetWMNormalHints(display, data->xwindow, sizehints, &userhints); sizehints->max_width = window->max_w; sizehints->max_height = window->max_h; sizehints->flags |= PMaxSize; - XSetWMNormalHints(display, data->xwindow, sizehints); + X11_XSetWMNormalHints(display, data->xwindow, sizehints); - XFree(sizehints); + X11_XFree(sizehints); /* 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 @@ -834,20 +834,20 @@ X11_SetWindowSize(_THIS, SDL_Window * window) X11_ResizeWindowShape(window); } 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. */ - XSizeHints *sizehints = XAllocSizeHints(); + XSizeHints *sizehints = X11_XAllocSizeHints(); 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_height = sizehints->max_height = window->h; sizehints->flags |= PMinSize | PMaxSize; - XSetWMNormalHints(display, data->xwindow, sizehints); + X11_XSetWMNormalHints(display, data->xwindow, sizehints); - XFree(sizehints); + X11_XFree(sizehints); /* From Pierre-Loup: 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 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 { - XResizeWindow(display, data->xwindow, window->w, window->h); + X11_XResizeWindow(display, data->xwindow, window->w, window->h); } - XFlush(display); + X11_XFlush(display); } void @@ -887,25 +887,25 @@ X11_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered) XEvent event; 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) { XWindowAttributes attr; do { - XSync(display, False); - XGetWindowAttributes(display, data->xwindow, &attr); + X11_XSync(display, False); + X11_XGetWindowAttributes(display, data->xwindow, &attr); } while (attr.map_state != IsViewable); 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. */ - 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 @@ -916,12 +916,12 @@ X11_ShowWindow(_THIS, SDL_Window * window) XEvent event; if (!X11_IsWindowMapped(_this, window)) { - XMapRaised(display, data->xwindow); + X11_XMapRaised(display, data->xwindow); /* 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 */ - 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; if (X11_IsWindowMapped(_this, window)) { - XWithdrawWindow(display, data->xwindow, displaydata->screen); + X11_XWithdrawWindow(display, data->xwindow, displaydata->screen); /* 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[2] = 0; - XSendEvent(display, RootWindow(display, displaydata->screen), 0, + X11_XSendEvent(display, RootWindow(display, displaydata->screen), 0, 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; Display *display = data->videodata->display; - XRaiseWindow(display, data->xwindow); + X11_XRaiseWindow(display, data->xwindow); SetWindowActive(_this, window); - XFlush(display); + X11_XFlush(display); } 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[3] = 0l; - XSendEvent(display, RootWindow(display, displaydata->screen), 0, + X11_XSendEvent(display, RootWindow(display, displaydata->screen), 0, SubstructureNotifyMask | SubstructureRedirectMask, &e); } else { X11_SetNetWMState(_this, data->xwindow, window->flags); } - XFlush(display); + X11_XFlush(display); } void @@ -1033,8 +1033,8 @@ X11_MinimizeWindow(_THIS, SDL_Window * window) (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata; Display *display = data->videodata->display; - XIconifyWindow(display, data->xwindow, displaydata->screen); - XFlush(display); + X11_XIconifyWindow(display, data->xwindow, displaydata->screen); + X11_XFlush(display); } void @@ -1061,9 +1061,9 @@ X11_SetWindowFullscreenViaWM(_THIS, SDL_Window * window, SDL_VideoDisplay * _dis if (!(window->flags & SDL_WINDOW_RESIZABLE)) { /* 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) */ - XSizeHints *sizehints = XAllocSizeHints(); + XSizeHints *sizehints = X11_XAllocSizeHints(); long flags = 0; - XGetWMNormalHints(display, data->xwindow, sizehints, &flags); + X11_XGetWMNormalHints(display, data->xwindow, sizehints, &flags); /* set the resize flags on */ if (fullscreen) { /* 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_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); @@ -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[3] = 0l; - XSendEvent(display, RootWindow(display, displaydata->screen), 0, + X11_XSendEvent(display, RootWindow(display, displaydata->screen), 0, SubstructureNotifyMask | SubstructureRedirectMask, &e); } else { Uint32 flags; @@ -1104,13 +1104,13 @@ X11_SetWindowFullscreenViaWM(_THIS, SDL_Window * window, SDL_VideoDisplay * _dis if (data->visual->class == DirectColor) { if ( fullscreen ) { - XInstallColormap(display, data->colormap); + X11_XInstallColormap(display, data->colormap); } else { - XUninstallColormap(display, data->colormap); + X11_XUninstallColormap(display, data->colormap); } } - XFlush(display); + X11_XFlush(display); } /* This handles fullscreen itself, outside the Window Manager. */ @@ -1145,48 +1145,48 @@ X11_BeginWindowFullscreenLegacy(_THIS, SDL_Window * window, SDL_VideoDisplay * _ xattr.colormap = data->colormap; xattrmask |= CWColormap; - data->fswindow = XCreateWindow(display, root, + data->fswindow = X11_XCreateWindow(display, root, rect.x, rect.y, rect.w, rect.h, 0, displaydata->depth, InputOutput, 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 */ - 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. */ - 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 ( displaydata->use_vidmode ) { - XF86VidModeLockModeSwitch(display, screen, True); + X11_XF86VidModeLockModeSwitch(display, screen, True); } #endif SetWindowBordered(display, displaydata->screen, data->xwindow, SDL_FALSE); /* 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); /* 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. */ rect.x += (rect.w / 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. */ - 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); } @@ -1210,27 +1210,27 @@ X11_EndWindowFullscreenLegacy(_THIS, SDL_Window * window, SDL_VideoDisplay * _di #if SDL_VIDEO_DRIVER_X11_VIDMODE if ( displaydata->use_vidmode ) { - XF86VidModeLockModeSwitch(display, screen, False); + X11_XF86VidModeLockModeSwitch(display, screen, False); } #endif 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 */ - 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, (window->flags & SDL_WINDOW_BORDERLESS) == 0); - XWithdrawWindow(display, fswindow, screen); + X11_XWithdrawWindow(display, fswindow, screen); /* 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; } - XStoreColors(display, colormap, colorcells, ncolors); - XFlush(display); + X11_XStoreColors(display, colormap, colorcells, ncolors); + X11_XFlush(display); SDL_free(colorcells); return 0; @@ -1354,7 +1354,7 @@ X11_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed) /* Try to grab the mouse */ for (;;) { int result = - XGrabPointer(display, data->xwindow, True, 0, GrabModeAsync, + X11_XGrabPointer(display, data->xwindow, True, 0, GrabModeAsync, GrabModeAsync, data->xwindow, None, CurrentTime); if (result == GrabSuccess) { break; @@ -1363,7 +1363,7 @@ X11_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed) } /* Raise the window if we grab the mouse */ - XRaiseWindow(display, data->xwindow); + X11_XRaiseWindow(display, data->xwindow); /* Now grab the 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; } if (grab_keyboard) { - XGrabKeyboard(display, data->xwindow, True, GrabModeAsync, + X11_XGrabKeyboard(display, data->xwindow, True, GrabModeAsync, GrabModeAsync, CurrentTime); } } else { - XUngrabPointer(display, CurrentTime); - XUngrabKeyboard(display, CurrentTime); + X11_XUngrabPointer(display, CurrentTime); + X11_XUngrabKeyboard(display, CurrentTime); } - XSync(display, False); + X11_XSync(display, False); } void @@ -1411,12 +1411,12 @@ X11_DestroyWindow(_THIS, SDL_Window * window) } #ifdef X_HAVE_UTF8_STRING if (data->ic) { - XDestroyIC(data->ic); + X11_XDestroyIC(data->ic); } #endif if (data->created) { - XDestroyWindow(display, data->xwindow); - XFlush(display); + X11_XDestroyWindow(display, data->xwindow); + X11_XFlush(display); } SDL_free(data); } diff --git a/src/video/x11/SDL_x11xinput2.c b/src/video/x11/SDL_x11xinput2.c index 10b42288290b9..3f84bbd77eb1b 100644 --- a/src/video/x11/SDL_x11xinput2.c +++ b/src/video/x11/SDL_x11xinput2.c @@ -36,7 +36,7 @@ static int xinput2_initialized = 0; static int xinput2_multitouch_supported = 0; #endif -/* Opcode returned XQueryExtension +/* Opcode returned X11_XQueryExtension * It will be used in event processing * to know that the event came from * 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 * 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 || - !XQueryExtension(data->display, "XInputExtension", &xinput2_opcode, &event, &err)) { + !X11_XQueryExtension(data->display, "XInputExtension", &xinput2_opcode, &event, &err)) { return; } outmajor = major; outminor = minor; - if (XIQueryVersion(data->display, &outmajor, &outminor) != Success) { + if (X11_XIQueryVersion(data->display, &outmajor, &outminor) != Success) { return; } @@ -115,7 +115,7 @@ X11_InitXinput2(_THIS) 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; } #endif @@ -226,7 +226,7 @@ X11_Xinput2SelectTouch(_THIS, SDL_Window *window) XISetMask(mask, XI_TouchUpdate); XISetMask(mask, XI_TouchEnd); - XISelectEvents(data->display,window_data->xwindow,&eventmask,1); + X11_XISelectEvents(data->display,window_data->xwindow,&eventmask,1); #endif }