Commit 0d4d13b2 authored by Ryan C. Gordon's avatar Ryan C. Gordon

Dynamically load X11 libraries like we currently do for alsa, esd, etc.

 This allows you to run an SDL program on a system without Xlib, since it'll
 just report the x11 target unavailable at runtime.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401171
parent 2f61404a
...@@ -609,11 +609,45 @@ CheckX11() ...@@ -609,11 +609,45 @@ CheckX11()
AC_PATH_X AC_PATH_X
AC_PATH_XTRA AC_PATH_XTRA
if test x$have_x = xyes; then if test x$have_x = xyes; then
CFLAGS="$CFLAGS $X_CFLAGS -DENABLE_X11 -DXTHREADS -I$srcdir/include -I$srcdir/src/video" AC_ARG_ENABLE(x11-shared,
[ --enable-x11-shared dynamically load X11 support [default=yes]],
, enable_x11_shared=yes)
dnl !!! FIXME: make this work?
dnl x11_lib_spec=`echo $X11_LIBS | sed 's/.*-L\([[^ ]]*\).*/\1\/libX11.so.*/'`
dnl x11_lib=`ls $x11_lib_spec | sed 's/.*\/\(.*\)/\1/; q'`
dnl echo "-- $x11_lib_spec -> $x11_lib"
dnl x11ext_lib_spec=`echo $X11EXT_LIBS | sed 's/.*-L\([[^ ]]*\).*/\1\/libXext.so.*/'`
dnl x11ext_lib=`ls $x11ext_lib_spec | sed 's/.*\/\(.*\)/\1/; q'`
dnl echo "-- $x11ext_lib_spec -> $x11ext_lib"
x11_lib_spec='/usr/X11R6/lib/libX11.so.*'
x11_lib='libX11.so.6'
echo "-- $x11_lib_spec -> $x11_lib"
x11ext_lib_spec='/usr/X11R6/lib/libXext.so.*'
x11_lib='libXext.so.6'
echo "-- $x11ext_lib_spec -> $x11_lib"
if test x$use_dlopen != xyes && \
test x$enable_x11_shared = xyes; then
AC_MSG_ERROR([You must have dlopen() support and use the --enable-dlopen option])
fi
if test x$use_dlopen = xyes && \
test x$enable_x11_shared = xyes && test x$x11_lib != x; then
CFLAGS="$CFLAGS $X_CFLAGS -DENABLE_X11 -DXTHREADS -DX11_DYNAMIC=\$(x11_lib) -DX11EXT_DYNAMIC=\$(x11ext_lib) -I$srcdir/include -I$srcdir/src/video"
SYSTEM_LIBS="$SYSTEM_LIBS $X_LIBS"
AC_SUBST(x11_lib)
AC_SUBST(x11ext_lib)
else
CFLAGS="$CFLAGS $X_CFLAGS -DENABLE_X11 -DXTHREADS -I$srcdir/include -I$srcdir/src/video"
SYSTEM_LIBS="$SYSTEM_LIBS $X_LIBS -lX11 -lXext"
fi
if test x$ac_cv_func_shmat != xyes; then if test x$ac_cv_func_shmat != xyes; then
CFLAGS="$CFLAGS -DNO_SHARED_MEMORY" CFLAGS="$CFLAGS -DNO_SHARED_MEMORY"
fi fi
SYSTEM_LIBS="$SYSTEM_LIBS $X_LIBS -lX11 -lXext"
VIDEO_SUBDIRS="$VIDEO_SUBDIRS x11" VIDEO_SUBDIRS="$VIDEO_SUBDIRS x11"
VIDEO_DRIVERS="$VIDEO_DRIVERS x11/libvideo_x11.la" VIDEO_DRIVERS="$VIDEO_DRIVERS x11/libvideo_x11.la"
......
...@@ -35,6 +35,13 @@ Equipment Corporation. ...@@ -35,6 +35,13 @@ Equipment Corporation.
#include "panoramiXproto.h" /* in ../include */ #include "panoramiXproto.h" /* in ../include */
#include "Xinerama.h" #include "Xinerama.h"
#include "../../x11/SDL_x11dyn.h"
/* Workaround code in headers... */
#define _XFlush p_XFlush
#define _XFlushGCCache p_XFlushGCCache
#define _XReply p_XReply
#define _XSend p_XSend
static XExtensionInfo _panoramiX_ext_info_data; static XExtensionInfo _panoramiX_ext_info_data;
static XExtensionInfo *panoramiX_ext_info = &_panoramiX_ext_info_data; static XExtensionInfo *panoramiX_ext_info = &_panoramiX_ext_info_data;
...@@ -111,7 +118,7 @@ Status SDL_NAME(XPanoramiXQueryVersion)( ...@@ -111,7 +118,7 @@ Status SDL_NAME(XPanoramiXQueryVersion)(
req->panoramiXReqType = X_PanoramiXQueryVersion; req->panoramiXReqType = X_PanoramiXQueryVersion;
req->clientMajor = PANORAMIX_MAJOR_VERSION; req->clientMajor = PANORAMIX_MAJOR_VERSION;
req->clientMinor = PANORAMIX_MINOR_VERSION; req->clientMinor = PANORAMIX_MINOR_VERSION;
if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) { if (!p_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
UnlockDisplay (dpy); UnlockDisplay (dpy);
SyncHandle (); SyncHandle ();
return 0; return 0;
...@@ -145,7 +152,7 @@ Status SDL_NAME(XPanoramiXGetState) ( ...@@ -145,7 +152,7 @@ Status SDL_NAME(XPanoramiXGetState) (
req->reqType = info->codes->major_opcode; req->reqType = info->codes->major_opcode;
req->panoramiXReqType = X_PanoramiXGetState; req->panoramiXReqType = X_PanoramiXGetState;
req->window = drawable; req->window = drawable;
if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) { if (!p_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
UnlockDisplay (dpy); UnlockDisplay (dpy);
SyncHandle (); SyncHandle ();
return 0; return 0;
...@@ -174,7 +181,7 @@ Status SDL_NAME(XPanoramiXGetScreenCount) ( ...@@ -174,7 +181,7 @@ Status SDL_NAME(XPanoramiXGetScreenCount) (
req->reqType = info->codes->major_opcode; req->reqType = info->codes->major_opcode;
req->panoramiXReqType = X_PanoramiXGetScreenCount; req->panoramiXReqType = X_PanoramiXGetScreenCount;
req->window = drawable; req->window = drawable;
if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) { if (!p_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
UnlockDisplay (dpy); UnlockDisplay (dpy);
SyncHandle (); SyncHandle ();
return 0; return 0;
...@@ -205,7 +212,7 @@ Status SDL_NAME(XPanoramiXGetScreenSize) ( ...@@ -205,7 +212,7 @@ Status SDL_NAME(XPanoramiXGetScreenSize) (
req->panoramiXReqType = X_PanoramiXGetScreenSize; req->panoramiXReqType = X_PanoramiXGetScreenSize;
req->window = drawable; req->window = drawable;
req->screen = screen_num; /* need to define */ req->screen = screen_num; /* need to define */
if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) { if (!p_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
UnlockDisplay (dpy); UnlockDisplay (dpy);
SyncHandle (); SyncHandle ();
return 0; return 0;
...@@ -285,7 +292,7 @@ SDL_NAME(XineramaQueryScreens)( ...@@ -285,7 +292,7 @@ SDL_NAME(XineramaQueryScreens)(
GetReq (XineramaQueryScreens, req); GetReq (XineramaQueryScreens, req);
req->reqType = info->codes->major_opcode; req->reqType = info->codes->major_opcode;
req->panoramiXReqType = X_XineramaQueryScreens; req->panoramiXReqType = X_XineramaQueryScreens;
if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) { if (!p_XReply (dpy, (xReply *) &rep, 0, xFalse)) {
UnlockDisplay (dpy); UnlockDisplay (dpy);
SyncHandle (); SyncHandle ();
return NULL; return NULL;
...@@ -297,7 +304,7 @@ SDL_NAME(XineramaQueryScreens)( ...@@ -297,7 +304,7 @@ SDL_NAME(XineramaQueryScreens)(
int i; int i;
for(i = 0; i < rep.number; i++) { for(i = 0; i < rep.number; i++) {
_XRead(dpy, (char*)(&scratch), sz_XineramaScreenInfo); p_XRead(dpy, (char*)(&scratch), sz_XineramaScreenInfo);
scrnInfo[i].screen_number = i; scrnInfo[i].screen_number = i;
scrnInfo[i].x_org = scratch.x_org; scrnInfo[i].x_org = scratch.x_org;
scrnInfo[i].y_org = scratch.y_org; scrnInfo[i].y_org = scratch.y_org;
...@@ -307,7 +314,7 @@ SDL_NAME(XineramaQueryScreens)( ...@@ -307,7 +314,7 @@ SDL_NAME(XineramaQueryScreens)(
*number = rep.number; *number = rep.number;
} else } else
_XEatData(dpy, rep.length << 2); p_XEatData(dpy, rep.length << 2);
} }
UnlockDisplay (dpy); UnlockDisplay (dpy);
......
...@@ -56,6 +56,14 @@ SOFTWARE. ...@@ -56,6 +56,14 @@ SOFTWARE.
#include <X11/extensions/XShm.h> #include <X11/extensions/XShm.h>
#include "extutil.h" #include "extutil.h"
#include "../../x11/SDL_x11dyn.h"
/* Workaround code in headers... */
#define _XFlush p_XFlush
#define _XFlushGCCache p_XFlushGCCache
#define _XReply p_XReply
#define _XSend p_XSend
static XExtensionInfo _xv_info_data; static XExtensionInfo _xv_info_data;
static XExtensionInfo *xv_info = &_xv_info_data; static XExtensionInfo *xv_info = &_xv_info_data;
static char *xv_extension_name = XvName; static char *xv_extension_name = XvName;
...@@ -121,7 +129,7 @@ SDL_NAME(XvQueryExtension)( ...@@ -121,7 +129,7 @@ SDL_NAME(XvQueryExtension)(
XvGetReq(QueryExtension, req); XvGetReq(QueryExtension, req);
if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { if (!p_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
UnlockDisplay(dpy); UnlockDisplay(dpy);
SyncHandle(); SyncHandle();
return XvBadExtension; return XvBadExtension;
...@@ -171,7 +179,7 @@ SDL_NAME(XvQueryAdaptors)( ...@@ -171,7 +179,7 @@ SDL_NAME(XvQueryAdaptors)(
/* READ THE REPLY */ /* READ THE REPLY */
if (_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) { if (p_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) {
UnlockDisplay(dpy); UnlockDisplay(dpy);
SyncHandle(); SyncHandle();
return(XvBadReply); return(XvBadReply);
...@@ -183,7 +191,7 @@ SDL_NAME(XvQueryAdaptors)( ...@@ -183,7 +191,7 @@ SDL_NAME(XvQueryAdaptors)(
SyncHandle(); SyncHandle();
return(XvBadAlloc); return(XvBadAlloc);
} }
_XRead (dpy, buffer, size); p_XRead (dpy, buffer, size);
u.buffer = buffer; u.buffer = buffer;
...@@ -331,7 +339,7 @@ SDL_NAME(XvQueryEncodings)( ...@@ -331,7 +339,7 @@ SDL_NAME(XvQueryEncodings)(
/* READ THE REPLY */ /* READ THE REPLY */
if (_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) { if (p_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) {
UnlockDisplay(dpy); UnlockDisplay(dpy);
SyncHandle(); SyncHandle();
return(XvBadReply); return(XvBadReply);
...@@ -343,7 +351,7 @@ SDL_NAME(XvQueryEncodings)( ...@@ -343,7 +351,7 @@ SDL_NAME(XvQueryEncodings)(
SyncHandle(); SyncHandle();
return(XvBadAlloc); return(XvBadAlloc);
} }
_XRead (dpy, buffer, size); p_XRead (dpy, buffer, size);
u.buffer = buffer; u.buffer = buffer;
...@@ -619,7 +627,7 @@ SDL_NAME(XvGrabPort)( ...@@ -619,7 +627,7 @@ SDL_NAME(XvGrabPort)(
req->port = port; req->port = port;
req->time = time; req->time = time;
if (_XReply (dpy, (xReply *) &rep, 0, xTrue) == 0) if (p_XReply (dpy, (xReply *) &rep, 0, xTrue) == 0)
rep.result = GrabSuccess; rep.result = GrabSuccess;
result = rep.result; result = rep.result;
...@@ -747,7 +755,7 @@ SDL_NAME(XvGetPortAttribute) ( ...@@ -747,7 +755,7 @@ SDL_NAME(XvGetPortAttribute) (
/* READ THE REPLY */ /* READ THE REPLY */
if (_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) { if (p_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) {
UnlockDisplay(dpy); UnlockDisplay(dpy);
SyncHandle(); SyncHandle();
return(XvBadReply); return(XvBadReply);
...@@ -792,7 +800,7 @@ SDL_NAME(XvQueryBestSize)( ...@@ -792,7 +800,7 @@ SDL_NAME(XvQueryBestSize)(
/* READ THE REPLY */ /* READ THE REPLY */
if (_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) { if (p_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) {
UnlockDisplay(dpy); UnlockDisplay(dpy);
SyncHandle(); SyncHandle();
return(XvBadReply); return(XvBadReply);
...@@ -827,7 +835,7 @@ SDL_NAME(XvQueryPortAttributes)(Display *dpy, XvPortID port, int *num) ...@@ -827,7 +835,7 @@ SDL_NAME(XvQueryPortAttributes)(Display *dpy, XvPortID port, int *num)
/* READ THE REPLY */ /* READ THE REPLY */
if (_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) { if (p_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) {
UnlockDisplay(dpy); UnlockDisplay(dpy);
SyncHandle(); SyncHandle();
return ret; return ret;
...@@ -842,17 +850,17 @@ SDL_NAME(XvQueryPortAttributes)(Display *dpy, XvPortID port, int *num) ...@@ -842,17 +850,17 @@ SDL_NAME(XvQueryPortAttributes)(Display *dpy, XvPortID port, int *num)
int i; int i;
for(i = 0; i < rep.num_attributes; i++) { for(i = 0; i < rep.num_attributes; i++) {
_XRead(dpy, (char*)(&Info), sz_xvAttributeInfo); p_XRead(dpy, (char*)(&Info), sz_xvAttributeInfo);
ret[i].flags = (int)Info.flags; ret[i].flags = (int)Info.flags;
ret[i].min_value = Info.min; ret[i].min_value = Info.min;
ret[i].max_value = Info.max; ret[i].max_value = Info.max;
ret[i].name = marker; ret[i].name = marker;
_XRead(dpy, marker, Info.size); p_XRead(dpy, marker, Info.size);
marker += Info.size; marker += Info.size;
(*num)++; (*num)++;
} }
} else } else
_XEatData(dpy, rep.length << 2); p_XEatData(dpy, rep.length << 2);
} }
UnlockDisplay(dpy); UnlockDisplay(dpy);
...@@ -882,7 +890,7 @@ SDL_NAME(XvImageFormatValues) * SDL_NAME(XvListImageFormats) ( ...@@ -882,7 +890,7 @@ SDL_NAME(XvImageFormatValues) * SDL_NAME(XvListImageFormats) (
/* READ THE REPLY */ /* READ THE REPLY */
if (_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) { if (p_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) {
UnlockDisplay(dpy); UnlockDisplay(dpy);
SyncHandle(); SyncHandle();
return NULL; return NULL;
...@@ -896,7 +904,7 @@ SDL_NAME(XvImageFormatValues) * SDL_NAME(XvListImageFormats) ( ...@@ -896,7 +904,7 @@ SDL_NAME(XvImageFormatValues) * SDL_NAME(XvListImageFormats) (
int i; int i;
for(i = 0; i < rep.num_formats; i++) { for(i = 0; i < rep.num_formats; i++) {
_XRead(dpy, (char*)(&Info), sz_xvImageFormatInfo); p_XRead(dpy, (char*)(&Info), sz_xvImageFormatInfo);
ret[i].id = Info.id; ret[i].id = Info.id;
ret[i].type = Info.type; ret[i].type = Info.type;
ret[i].byte_order = Info.byte_order; ret[i].byte_order = Info.byte_order;
...@@ -922,7 +930,7 @@ SDL_NAME(XvImageFormatValues) * SDL_NAME(XvListImageFormats) ( ...@@ -922,7 +930,7 @@ SDL_NAME(XvImageFormatValues) * SDL_NAME(XvListImageFormats) (
(*num)++; (*num)++;
} }
} else } else
_XEatData(dpy, rep.length << 2); p_XEatData(dpy, rep.length << 2);
} }
UnlockDisplay(dpy); UnlockDisplay(dpy);
...@@ -956,7 +964,7 @@ SDL_NAME(XvImage) * SDL_NAME(XvCreateImage) ( ...@@ -956,7 +964,7 @@ SDL_NAME(XvImage) * SDL_NAME(XvCreateImage) (
/* READ THE REPLY */ /* READ THE REPLY */
if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { if (!p_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
UnlockDisplay(dpy); UnlockDisplay(dpy);
SyncHandle(); SyncHandle();
return NULL; return NULL;
...@@ -972,10 +980,10 @@ SDL_NAME(XvImage) * SDL_NAME(XvCreateImage) ( ...@@ -972,10 +980,10 @@ SDL_NAME(XvImage) * SDL_NAME(XvCreateImage) (
ret->offsets = ret->pitches + rep.num_planes; ret->offsets = ret->pitches + rep.num_planes;
ret->data = data; ret->data = data;
ret->obdata = NULL; ret->obdata = NULL;
_XRead(dpy, (char*)(ret->pitches), rep.num_planes << 2); p_XRead(dpy, (char*)(ret->pitches), rep.num_planes << 2);
_XRead(dpy, (char*)(ret->offsets), rep.num_planes << 2); p_XRead(dpy, (char*)(ret->offsets), rep.num_planes << 2);
} else } else
_XEatData(dpy, rep.length << 2); p_XEatData(dpy, rep.length << 2);
UnlockDisplay(dpy); UnlockDisplay(dpy);
SyncHandle(); SyncHandle();
...@@ -1124,7 +1132,7 @@ xv_wire_to_event(Display *dpy, XEvent *host, xEvent *wire) ...@@ -1124,7 +1132,7 @@ xv_wire_to_event(Display *dpy, XEvent *host, xEvent *wire)
case XvVideoNotify: case XvVideoNotify:
re->xvvideo.type = event->u.u.type & 0x7f; re->xvvideo.type = event->u.u.type & 0x7f;
re->xvvideo.serial = re->xvvideo.serial =
_XSetLastRequestRead(dpy, (xGenericReply *)event); p_XSetLastRequestRead(dpy, (xGenericReply *)event);
re->xvvideo.send_event = ((event->u.u.type & 0x80) != 0); re->xvvideo.send_event = ((event->u.u.type & 0x80) != 0);
re->xvvideo.display = dpy; re->xvvideo.display = dpy;
re->xvvideo.time = event->u.videoNotify.time; re->xvvideo.time = event->u.videoNotify.time;
...@@ -1135,7 +1143,7 @@ xv_wire_to_event(Display *dpy, XEvent *host, xEvent *wire) ...@@ -1135,7 +1143,7 @@ xv_wire_to_event(Display *dpy, XEvent *host, xEvent *wire)
case XvPortNotify: case XvPortNotify:
re->xvport.type = event->u.u.type & 0x7f; re->xvport.type = event->u.u.type & 0x7f;
re->xvport.serial = re->xvport.serial =
_XSetLastRequestRead(dpy, (xGenericReply *)event); p_XSetLastRequestRead(dpy, (xGenericReply *)event);
re->xvport.send_event = ((event->u.u.type & 0x80) != 0); re->xvport.send_event = ((event->u.u.type & 0x80) != 0);
re->xvport.display = dpy; re->xvport.display = dpy;
re->xvport.time = event->u.portNotify.time; re->xvport.time = event->u.portNotify.time;
......
...@@ -51,7 +51,7 @@ SOFTWARE. ...@@ -51,7 +51,7 @@ SOFTWARE.
#define XvGetReq(name, req) \ #define XvGetReq(name, req) \
WORD64ALIGN\ WORD64ALIGN\
if ((dpy->bufptr + SIZEOF(xv##name##Req)) > dpy->bufmax)\ if ((dpy->bufptr + SIZEOF(xv##name##Req)) > dpy->bufmax)\
_XFlush(dpy);\ p_XFlush(dpy);\
req = (xv##name##Req *)(dpy->last_req = dpy->bufptr);\ req = (xv##name##Req *)(dpy->last_req = dpy->bufptr);\
req->reqType = info->codes->major_opcode;\ req->reqType = info->codes->major_opcode;\
req->xvReqType = xv_##name; \ req->xvReqType = xv_##name; \
...@@ -63,7 +63,7 @@ SOFTWARE. ...@@ -63,7 +63,7 @@ SOFTWARE.
#define XvGetReq(name, req) \ #define XvGetReq(name, req) \
WORD64ALIGN\ WORD64ALIGN\
if ((dpy->bufptr + SIZEOF(xv/**/name/**/Req)) > dpy->bufmax)\ if ((dpy->bufptr + SIZEOF(xv/**/name/**/Req)) > dpy->bufmax)\
_XFlush(dpy);\ p_XFlush(dpy);\
req = (xv/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\ req = (xv/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\
req->reqType = info->codes->major_opcode;\ req->reqType = info->codes->major_opcode;\
req->xvReqType = xv_/**/name;\ req->xvReqType = xv_/**/name;\
......
...@@ -56,7 +56,6 @@ Copyright (c) 1995,1996 The XFree86 Project, Inc ...@@ -56,7 +56,6 @@ Copyright (c) 1995,1996 The XFree86 Project, Inc
#undef _SC_PAGESIZE #undef _SC_PAGESIZE
#endif #endif
#define NEED_EVENTS #define NEED_EVENTS
#define NEED_REPLIES #define NEED_REPLIES
#include <X11/Xlibint.h> #include <X11/Xlibint.h>
...@@ -65,6 +64,14 @@ Copyright (c) 1995,1996 The XFree86 Project, Inc ...@@ -65,6 +64,14 @@ Copyright (c) 1995,1996 The XFree86 Project, Inc
#include <X11/extensions/Xext.h> #include <X11/extensions/Xext.h>
#include "extutil.h" #include "extutil.h"
#include "../../x11/SDL_x11dyn.h"
/* Workaround code in headers... */
#define _XFlush p_XFlush
#define _XFlushGCCache p_XFlushGCCache
#define _XReply p_XReply
#define _XSend p_XSend
extern XExtDisplayInfo* SDL_NAME(xdga_find_display)(Display*); extern XExtDisplayInfo* SDL_NAME(xdga_find_display)(Display*);
extern char *SDL_NAME(xdga_extension_name); extern char *SDL_NAME(xdga_extension_name);
...@@ -112,7 +119,7 @@ Bool SDL_NAME(XF86DGAGetVideoLL)( ...@@ -112,7 +119,7 @@ Bool SDL_NAME(XF86DGAGetVideoLL)(
req->reqType = info->codes->major_opcode; req->reqType = info->codes->major_opcode;
req->dgaReqType = X_XF86DGAGetVideoLL; req->dgaReqType = X_XF86DGAGetVideoLL;
req->screen = screen; req->screen = screen;
if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { if (!p_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
UnlockDisplay(dpy); UnlockDisplay(dpy);
SyncHandle(); SyncHandle();
return False; return False;
...@@ -147,7 +154,7 @@ Bool SDL_NAME(XF86DGADirectVideoLL)( ...@@ -147,7 +154,7 @@ Bool SDL_NAME(XF86DGADirectVideoLL)(
req->enable = enable; req->enable = enable;
UnlockDisplay(dpy); UnlockDisplay(dpy);
SyncHandle(); SyncHandle();
XSync(dpy,False); pXSync(dpy,False);
return True; return True;
} }
...@@ -168,7 +175,7 @@ Bool SDL_NAME(XF86DGAGetViewPortSize)( ...@@ -168,7 +175,7 @@ Bool SDL_NAME(XF86DGAGetViewPortSize)(
req->reqType = info->codes->major_opcode; req->reqType = info->codes->major_opcode;
req->dgaReqType = X_XF86DGAGetViewPortSize; req->dgaReqType = X_XF86DGAGetViewPortSize;
req->screen = screen; req->screen = screen;
if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { if (!p_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
UnlockDisplay(dpy); UnlockDisplay(dpy);
SyncHandle(); SyncHandle();
return False; return False;
...@@ -203,7 +210,7 @@ Bool SDL_NAME(XF86DGASetViewPort)( ...@@ -203,7 +210,7 @@ Bool SDL_NAME(XF86DGASetViewPort)(
req->y = y; req->y = y;
UnlockDisplay(dpy); UnlockDisplay(dpy);
SyncHandle(); SyncHandle();
XSync(dpy,False); pXSync(dpy,False);
return True; return True;
} }
...@@ -224,7 +231,7 @@ Bool SDL_NAME(XF86DGAGetVidPage)( ...@@ -224,7 +231,7 @@ Bool SDL_NAME(XF86DGAGetVidPage)(
req->reqType = info->codes->major_opcode; req->reqType = info->codes->major_opcode;
req->dgaReqType = X_XF86DGAGetVidPage; req->dgaReqType = X_XF86DGAGetVidPage;
req->screen = screen; req->screen = screen;
if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { if (!p_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
UnlockDisplay(dpy); UnlockDisplay(dpy);
SyncHandle(); SyncHandle();
return False; return False;
...@@ -255,7 +262,7 @@ Bool SDL_NAME(XF86DGASetVidPage)( ...@@ -255,7 +262,7 @@ Bool SDL_NAME(XF86DGASetVidPage)(
req->vpage = vpage; req->vpage = vpage;
UnlockDisplay(dpy); UnlockDisplay(dpy);
SyncHandle(); SyncHandle();
XSync(dpy,False); pXSync(dpy,False);
return True; return True;
} }
...@@ -277,7 +284,7 @@ Bool SDL_NAME(XF86DGAInstallColormap)( ...@@ -277,7 +284,7 @@ Bool SDL_NAME(XF86DGAInstallColormap)(
req->id = cmap; req->id = cmap;
UnlockDisplay(dpy); UnlockDisplay(dpy);
SyncHandle(); SyncHandle();
XSync(dpy,False); pXSync(dpy,False);
return True; return True;
} }
...@@ -297,7 +304,7 @@ Bool SDL_NAME(XF86DGAQueryDirectVideo)( ...@@ -297,7 +304,7 @@ Bool SDL_NAME(XF86DGAQueryDirectVideo)(
req->reqType = info->codes->major_opcode; req->reqType = info->codes->major_opcode;
req->dgaReqType = X_XF86DGAQueryDirectVideo; req->dgaReqType = X_XF86DGAQueryDirectVideo;
req->screen = screen; req->screen = screen;
if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { if (!p_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
UnlockDisplay(dpy); UnlockDisplay(dpy);
SyncHandle(); SyncHandle();
return False; return False;
...@@ -325,7 +332,7 @@ Bool SDL_NAME(XF86DGAViewPortChanged)( ...@@ -325,7 +332,7 @@ Bool SDL_NAME(XF86DGAViewPortChanged)(
req->dgaReqType = X_XF86DGAViewPortChanged; req->dgaReqType = X_XF86DGAViewPortChanged;
req->screen = screen; req->screen = screen;
req->n = n; req->n = n;
if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { if (!p_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
UnlockDisplay(dpy); UnlockDisplay(dpy);
SyncHandle(); SyncHandle();
return False; return False;
...@@ -598,7 +605,7 @@ SDL_NAME(XF86DGAForkApp)(int screen) ...@@ -598,7 +605,7 @@ SDL_NAME(XF86DGAForkApp)(int screen)
for (i = 0; i < numScrs; i++) { for (i = 0; i < numScrs; i++) {
sp = scrList[i]; sp = scrList[i];
SDL_NAME(XF86DGADirectVideoLL)(sp->display, sp->screen, 0); SDL_NAME(XF86DGADirectVideoLL)(sp->display, sp->screen, 0);
XSync(sp->display, False); pXSync(sp->display, False);
} }
if (WIFEXITED(status)) if (WIFEXITED(status))
_exit(0); _exit(0);
...@@ -658,7 +665,7 @@ XF86cleanup(int sig) ...@@ -658,7 +665,7 @@ XF86cleanup(int sig)
for (i = 0; i < numScrs; i++) { for (i = 0; i < numScrs; i++) {
sp = scrList[i]; sp = scrList[i];
SDL_NAME(XF86DGADirectVideo)(sp->display, sp->screen, 0); SDL_NAME(XF86DGADirectVideo)(sp->display, sp->screen, 0);
XSync(sp->display, False); pXSync(sp->display, False);
} }
_exit(3); _exit(3);
} }
......
...@@ -28,6 +28,14 @@ Copyright (c) 1995,1996 The XFree86 Project, Inc ...@@ -28,6 +28,14 @@ Copyright (c) 1995,1996 The XFree86 Project, Inc
#include <linux/fb.h> #include <linux/fb.h>
#endif #endif
#include "../../x11/SDL_x11dyn.h"
/* Workaround code in headers... */
#define _XFlush p_XFlush
#define _XFlushGCCache p_XFlushGCCache
#define _XReply p_XReply
#define _XSend p_XSend
/* If you change this, change the Bases[] array below as well */ /* If you change this, change the Bases[] array below as well */
#define MAX_HEADS 16 #define MAX_HEADS 16
...@@ -104,7 +112,7 @@ xdga_wire_to_event( ...@@ -104,7 +112,7 @@ xdga_wire_to_event(
case MotionNotify: case MotionNotify:
mevent = (SDL_NAME(XDGAMotionEvent)*)event; mevent = (SDL_NAME(XDGAMotionEvent)*)event;
mevent->type = wire->u.u.type & 0x7F; mevent->type = wire->u.u.type & 0x7F;
mevent->serial = _XSetLastRequestRead(dpy, (xGenericReply *)wire); mevent->serial = p_XSetLastRequestRead(dpy, (xGenericReply *)wire);
mevent->display = dpy; mevent->display = dpy;
mevent->screen = wire->u.event.screen; mevent->screen = wire->u.event.screen;
mevent->time = wire->u.event.time; mevent->time = wire->u.event.time;
...@@ -116,7 +124,7 @@ xdga_wire_to_event( ...@@ -116,7 +124,7 @@ xdga_wire_to_event(
case ButtonRelease: case ButtonRelease:
bevent = (SDL_NAME(XDGAButtonEvent)*)event; bevent = (SDL_NAME(XDGAButtonEvent)*)event;
bevent->type = wire->u.u.type & 0x7F; bevent->type = wire->u.u.type & 0x7F;
bevent->serial = _XSetLastRequestRead(dpy, (xGenericReply *)wire); bevent->serial = p_XSetLastRequestRead(dpy, (xGenericReply *)wire);
bevent->display = dpy; bevent->display = dpy;
bevent->screen = wire->u.event.screen; bevent->screen = wire->u.event.screen;
bevent->time = wire->u.event.time; bevent->time = wire->u.event.time;
...@@ -127,7 +135,7 @@ xdga_wire_to_event( ...@@ -127,7 +135,7 @@ xdga_wire_to_event(
case KeyRelease: case KeyRelease:
kevent = (SDL_NAME(XDGAKeyEvent)*)event; kevent = (SDL_NAME(XDGAKeyEvent)*)event;
kevent->type = wire->u.u.type & 0x7F; kevent->type = wire->u.u.type & 0x7F;
kevent->serial = _XSetLastRequestRead(dpy, (xGenericReply *)wire); kevent->serial = p_XSetLastRequestRead(dpy, (xGenericReply *)wire);
kevent->display = dpy; kevent->display = dpy;
kevent->screen = wire->u.event.screen; kevent->screen = wire->u.event.screen;
kevent->time = wire->u.event.time; kevent->time = wire->u.event.time;
...@@ -172,7 +180,7 @@ Bool SDL_NAME(XDGAQueryVersion)( ...@@ -172,7 +180,7 @@ Bool SDL_NAME(XDGAQueryVersion)(
GetReq(XDGAQueryVersion, req); GetReq(XDGAQueryVersion, req);
req->reqType = info->codes->major_opcode; req->reqType = info->codes->major_opcode;
req->dgaReqType = X_XDGAQueryVersion; req->dgaReqType = X_XDGAQueryVersion;
if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { if (!p_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
UnlockDisplay(dpy); UnlockDisplay(dpy);
SyncHandle(); SyncHandle();
return False; return False;
...@@ -189,8 +197,8 @@ Bool SDL_NAME(XDGAQueryVersion)( ...@@ -189,8 +197,8 @@ Bool SDL_NAME(XDGAQueryVersion)(
i < XF86DGANumberEvents; i < XF86DGANumberEvents;
i++, j++) i++, j++)
{ {
XESetWireToEvent (dpy, j, xdga_wire_to_event); pXESetWireToEvent(dpy, j, xdga_wire_to_event);
XESetEventToWire (dpy, j, xdga_event_to_wire); pXESetEventToWire(dpy, j, xdga_event_to_wire);
} }
SDL_NAME(XDGASetClientVersion)(dpy); SDL_NAME(XDGASetClientVersion)(dpy);
} }
...@@ -233,7 +241,7 @@ Bool SDL_NAME(XDGAOpenFramebuffer)( ...@@ -233,7 +241,7 @@ Bool SDL_NAME(XDGAOpenFramebuffer)(
req->reqType = info->codes->major_opcode; req->reqType = info->codes->major_opcode;
req->dgaReqType = X_XDGAOpenFramebuffer; req->dgaReqType = X_XDGAOpenFramebuffer;
req->screen = screen; req->screen = screen;
if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { if (!p_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
UnlockDisplay(dpy); UnlockDisplay(dpy);
SyncHandle(); SyncHandle();
return False; return False;
...@@ -241,7 +249,7 @@ Bool SDL_NAME(XDGAOpenFramebuffer)( ...@@ -241,7 +249,7 @@ Bool SDL_NAME(XDGAOpenFramebuffer)(
if(rep.length) { if(rep.length) {
deviceName = Xmalloc(rep.length << 2); deviceName = Xmalloc(rep.length << 2);
_XRead(dpy, deviceName, rep.length << 2); p_XRead(dpy, deviceName, rep.length << 2);
} }
ret = SDL_NAME(XDGAMapFramebuffer)(screen, deviceName, ret = SDL_NAME(XDGAMapFramebuffer)(screen, deviceName,
...@@ -298,7 +306,7 @@ SDL_NAME(XDGAMode)* SDL_NAME(XDGAQueryModes)( ...@@ -298,7 +306,7 @@ SDL_NAME(XDGAMode)* SDL_NAME(XDGAQueryModes)(
req->dgaReqType = X_XDGAQueryModes; req->dgaReqType = X_XDGAQueryModes;
req->screen = screen; req->screen = screen;
if (_XReply(dpy, (xReply *)&rep, 0, xFalse)) { if (p_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
if(rep.length) { if(rep.length) {
xXDGAModeInfo info; xXDGAModeInfo info;
int i, size; int i, size;
...@@ -312,7 +320,7 @@ SDL_NAME(XDGAMode)* SDL_NAME(XDGAQueryModes)( ...@@ -312,7 +320,7 @@ SDL_NAME(XDGAMode)* SDL_NAME(XDGAQueryModes)(
if(modes) { if(modes) {
for(i = 0; i < rep.number; i++) { for(i = 0; i < rep.number; i++) {
_XRead(dpy, (char*)(&info), sz_xXDGAModeInfo); p_XRead(dpy, (char*)(&info), sz_xXDGAModeInfo);
modes[i].num = info.num; modes[i].num = info.num;
modes[i].verticalRefresh = modes[i].verticalRefresh =
...@@ -340,13 +348,13 @@ SDL_NAME(XDGAMode)* SDL_NAME(XDGAQueryModes)( ...@@ -340,13 +348,13 @@ SDL_NAME(XDGAMode)* SDL_NAME(XDGAQueryModes)(
modes[i].reserved1 = info.reserved1; modes[i].reserved1 = info.reserved1;
modes[i].reserved2 = info.reserved2; modes[i].reserved2 = info.reserved2;
_XRead(dpy, offset, info.name_size); p_XRead(dpy, offset, info.name_size);
modes[i].name = offset; modes[i].name = offset;
offset += info.name_size; offset += info.name_size;
} }
*num = rep.number; *num = rep.number;
} else } else
_XEatData(dpy, rep.length << 2); p_XEatData(dpy, rep.length << 2);
} }
} }
...@@ -379,7 +387,7 @@ SDL_NAME(XDGASetMode)( ...@@ -379,7 +387,7 @@ SDL_NAME(XDGASetMode)(
req->mode = mode; req->mode = mode;
req->pid = pid = XAllocID(dpy); req->pid = pid = XAllocID(dpy);
if (_XReply(dpy, (xReply *)&rep, 0, xFalse)) { if (p_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
if(rep.length) { if(rep.length) {
xXDGAModeInfo info; xXDGAModeInfo info;
int size; int size;
...@@ -390,7 +398,7 @@ SDL_NAME(XDGASetMode)( ...@@ -390,7 +398,7 @@ SDL_NAME(XDGASetMode)(
dev = (SDL_NAME(XDGADevice)*)Xmalloc(sizeof(SDL_NAME(XDGADevice)) + size); dev = (SDL_NAME(XDGADevice)*)Xmalloc(sizeof(SDL_NAME(XDGADevice)) + size);
if(dev) { if(dev) {
_XRead(dpy, (char*)(&info), sz_xXDGAModeInfo); p_XRead(dpy, (char*)(&info), sz_xXDGAModeInfo);
dev->mode.num = info.num; dev->mode.num = info.num;
dev->mode.verticalRefresh = dev->mode.verticalRefresh =
...@@ -419,7 +427,7 @@ SDL_NAME(XDGASetMode)( ...@@ -419,7 +427,7 @@ SDL_NAME(XDGASetMode)(
dev->mode.reserved2 = info.reserved2; dev->mode.reserved2 = info.reserved2;
dev->mode.name = (char*)(&dev[1]); dev->mode.name = (char*)(&dev[1]);
_XRead(dpy, dev->mode.name, info.name_size); p_XRead(dpy, dev->mode.name, info.name_size);
dev->pixmap = (rep.flags & XDGAPixmap) ? pid : 0; dev->pixmap = (rep.flags & XDGAPixmap) ? pid : 0;
dev->data = SDL_NAME(XDGAGetMappedMemory)(screen); dev->data = SDL_NAME(XDGAGetMappedMemory)(screen);
...@@ -610,7 +618,7 @@ int SDL_NAME(XDGAGetViewportStatus)( ...@@ -610,7 +618,7 @@ int SDL_NAME(XDGAGetViewportStatus)(
req->reqType = info->codes->major_opcode; req->reqType = info->codes->major_opcode;
req->dgaReqType = X_XDGAGetViewportStatus; req->dgaReqType = X_XDGAGetViewportStatus;
req->screen = screen; req->screen = screen;
if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) if (!p_XReply(dpy, (xReply *)&rep, 0, xFalse))
status = rep.status; status = rep.status;
UnlockDisplay(dpy); UnlockDisplay(dpy);
SyncHandle(); SyncHandle();
...@@ -632,7 +640,7 @@ void SDL_NAME(XDGASync)( ...@@ -632,7 +640,7 @@ void SDL_NAME(XDGASync)(
req->reqType = info->codes->major_opcode; req->reqType = info->codes->major_opcode;
req->dgaReqType = X_XDGASync; req->dgaReqType = X_XDGASync;
req->screen = screen; req->screen = screen;
_XReply(dpy, (xReply *)&rep, 0, xFalse); p_XReply(dpy, (xReply *)&rep, 0, xFalse);
UnlockDisplay(dpy); UnlockDisplay(dpy);
SyncHandle(); SyncHandle();
} }
...@@ -659,7 +667,7 @@ void SDL_NAME(XDGAChangePixmapMode)( ...@@ -659,7 +667,7 @@ void SDL_NAME(XDGAChangePixmapMode)(
req->x = *x; req->x = *x;
req->y = *y; req->y = *y;
req->flags = mode; req->flags = mode;
_XReply(dpy, (xReply *)&rep, 0, xFalse); p_XReply(dpy, (xReply *)&rep, 0, xFalse);
*x = rep.x; *x = rep.x;
*y = rep.y; *y = rep.y;
UnlockDisplay(dpy); UnlockDisplay(dpy);
......
This diff is collapsed.
...@@ -173,9 +173,9 @@ extern XExtDisplayInfo *XextFindDisplay( ...@@ -173,9 +173,9 @@ extern XExtDisplayInfo *XextFindDisplay(
#define XextHasExtension(i) ((i) && ((i)->codes)) #define XextHasExtension(i) ((i) && ((i)->codes))
#define XextCheckExtension(dpy,i,name,val) \ #define XextCheckExtension(dpy,i,name,val) \
if (!XextHasExtension(i)) { XMissingExtension (dpy, name); return val; } if (!XextHasExtension(i)) { pXMissingExtension (dpy, name); return val; }
#define XextSimpleCheckExtension(dpy,i,name) \ #define XextSimpleCheckExtension(dpy,i,name) \
if (!XextHasExtension(i)) { XMissingExtension (dpy, name); return; } if (!XextHasExtension(i)) { pXMissingExtension (dpy, name); return; }
/* /*
...@@ -188,9 +188,9 @@ extern XExtDisplayInfo *XextFindDisplay( ...@@ -188,9 +188,9 @@ extern XExtDisplayInfo *XextFindDisplay(
XExtDisplayInfo *proc (Display *dpy) \ XExtDisplayInfo *proc (Display *dpy) \
{ \ { \
XExtDisplayInfo *dpyinfo; \ XExtDisplayInfo *dpyinfo; \
if (!extinfo) { if (!(extinfo = XextCreateExtension())) return NULL; } \ if (!extinfo) { if (!(extinfo = pXextCreateExtension())) return NULL; } \
if (!(dpyinfo = XextFindDisplay (extinfo, dpy))) \ if (!(dpyinfo = pXextFindDisplay (extinfo, dpy))) \
dpyinfo = XextAddDisplay (extinfo,dpy,extname,hooks,nev,data); \ dpyinfo = pXextAddDisplay (extinfo,dpy,extname,hooks,nev,data); \
return dpyinfo; \ return dpyinfo; \
} }
...@@ -200,7 +200,7 @@ XExtDisplayInfo *proc (Display *dpy) \ ...@@ -200,7 +200,7 @@ XExtDisplayInfo *proc (Display *dpy) \
#define XEXT_GENERATE_CLOSE_DISPLAY(proc,extinfo) \ #define XEXT_GENERATE_CLOSE_DISPLAY(proc,extinfo) \
int proc (Display *dpy, XExtCodes *codes) \ int proc (Display *dpy, XExtCodes *codes) \
{ \ { \
return XextRemoveDisplay (extinfo, dpy); \ return pXextRemoveDisplay (extinfo, dpy); \
} }
#define XEXT_CLOSE_DISPLAY_PROTO(proc) \ #define XEXT_CLOSE_DISPLAY_PROTO(proc) \
...@@ -213,7 +213,7 @@ char *proc (Display *dpy, int code, XExtCodes *codes, char *buf, int n) \ ...@@ -213,7 +213,7 @@ char *proc (Display *dpy, int code, XExtCodes *codes, char *buf, int n) \
if (code >= 0 && code < nerr) { \ if (code >= 0 && code < nerr) { \
char tmp[256]; \ char tmp[256]; \
sprintf (tmp, "%s.%d", extname, code); \ sprintf (tmp, "%s.%d", extname, code); \
XGetErrorDatabaseText (dpy, "XProtoError", tmp, errl[code], buf, n); \ pXGetErrorDatabaseText (dpy, "XProtoError", tmp, errl[code], buf, n); \
return buf; \ return buf; \
} \ } \
return (char *)0; \ return (char *)0; \
......
...@@ -47,7 +47,7 @@ static int DGA_DispatchEvent(_THIS) ...@@ -47,7 +47,7 @@ static int DGA_DispatchEvent(_THIS)
int posted; int posted;
SDL_NAME(XDGAEvent) xevent; SDL_NAME(XDGAEvent) xevent;
XNextEvent(DGA_Display, (XEvent *)&xevent); pXNextEvent(DGA_Display, (XEvent *)&xevent);
posted = 0; posted = 0;
xevent.type -= DGA_event_base; xevent.type -= DGA_event_base;
......
...@@ -48,6 +48,9 @@ static char rcsid = ...@@ -48,6 +48,9 @@ static char rcsid =
#include "SDL_dgamouse_c.h" #include "SDL_dgamouse_c.h"
#include "SDL_dgaevents_c.h" #include "SDL_dgaevents_c.h"
/* get function pointers... */
#include "../x11/SDL_x11dyn.h"
/* Initialization/Query functions */ /* Initialization/Query functions */
static int DGA_VideoInit(_THIS, SDL_PixelFormat *vformat); static int DGA_VideoInit(_THIS, SDL_PixelFormat *vformat);
static SDL_Rect **DGA_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags); static SDL_Rect **DGA_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
...@@ -72,91 +75,98 @@ static int DGA_FlipHWSurface(_THIS, SDL_Surface *surface); ...@@ -72,91 +75,98 @@ static int DGA_FlipHWSurface(_THIS, SDL_Surface *surface);
static int DGA_Available(void) static int DGA_Available(void)
{ {
const char *display; const char *display = NULL;
Display *dpy; Display *dpy = NULL;
int available; int available = 0;
/* The driver is available is available if the display is local /* The driver is available is available if the display is local
and the DGA 2.0+ extension is available, and we can map mem. and the DGA 2.0+ extension is available, and we can map mem.
*/ */
available = 0; if ( SDL_X11_LoadSymbols() ) {
display = NULL; if ( (strncmp(pXDisplayName(display), ":", 1) == 0) ||
if ( (strncmp(XDisplayName(display), ":", 1) == 0) || (strncmp(pXDisplayName(display), "unix:", 5) == 0) ) {
(strncmp(XDisplayName(display), "unix:", 5) == 0) ) { dpy = pXOpenDisplay(display);
dpy = XOpenDisplay(display); if ( dpy ) {
if ( dpy ) { int events, errors, major, minor;
int events, errors, major, minor;
if ( SDL_NAME(XDGAQueryExtension)(dpy, &events, &errors) &&
if ( SDL_NAME(XDGAQueryExtension)(dpy, &events, &errors) && SDL_NAME(XDGAQueryVersion)(dpy, &major, &minor) ) {
SDL_NAME(XDGAQueryVersion)(dpy, &major, &minor) ) { int screen;
int screen;
screen = DefaultScreen(dpy);
screen = DefaultScreen(dpy); if ( (major >= 2) &&
if ( (major >= 2) && SDL_NAME(XDGAOpenFramebuffer)(dpy, screen) ) {
SDL_NAME(XDGAOpenFramebuffer)(dpy, screen) ) { available = 1;
available = 1; SDL_NAME(XDGACloseFramebuffer)(dpy, screen);
SDL_NAME(XDGACloseFramebuffer)(dpy, screen); }
} }
pXCloseDisplay(dpy);
} }
XCloseDisplay(dpy);
} }
SDL_X11_UnloadSymbols();
} }
return(available); return(available);
} }
static void DGA_DeleteDevice(SDL_VideoDevice *device) static void DGA_DeleteDevice(SDL_VideoDevice *device)
{ {
free(device->hidden); if (device != NULL) {
free(device); free(device->hidden);
free(device);
SDL_X11_UnloadSymbols();
}
} }
static SDL_VideoDevice *DGA_CreateDevice(int devindex) static SDL_VideoDevice *DGA_CreateDevice(int devindex)
{ {
SDL_VideoDevice *device; SDL_VideoDevice *device = NULL;
/* Initialize all variables that we clean on shutdown */ /* Initialize all variables that we clean on shutdown */
device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice)); if (SDL_X11_LoadSymbols()) {
if ( device ) { device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice));
memset(device, 0, (sizeof *device));
device->hidden = (struct SDL_PrivateVideoData *)
malloc((sizeof *device->hidden));
}
if ( (device == NULL) || (device->hidden == NULL) ) {
SDL_OutOfMemory();
if ( device ) { if ( device ) {
free(device); memset(device, 0, (sizeof *device));
device->hidden = (struct SDL_PrivateVideoData *)
malloc((sizeof *device->hidden));
} }
return(0); if ( (device == NULL) || (device->hidden == NULL) ) {
SDL_OutOfMemory();
if ( device ) {
free(device);
}
SDL_X11_UnloadSymbols();
return(0);
}
memset(device->hidden, 0, (sizeof *device->hidden));
/* Set the function pointers */
device->VideoInit = DGA_VideoInit;
device->ListModes = DGA_ListModes;
device->SetVideoMode = DGA_SetVideoMode;
device->SetColors = DGA_SetColors;
device->UpdateRects = NULL;
device->VideoQuit = DGA_VideoQuit;
device->AllocHWSurface = DGA_AllocHWSurface;
device->CheckHWBlit = DGA_CheckHWBlit;
device->FillHWRect = DGA_FillHWRect;
device->SetHWColorKey = NULL;
device->SetHWAlpha = NULL;
device->LockHWSurface = DGA_LockHWSurface;
device->UnlockHWSurface = DGA_UnlockHWSurface;
device->FlipHWSurface = DGA_FlipHWSurface;
device->FreeHWSurface = DGA_FreeHWSurface;
device->SetGammaRamp = DGA_SetGammaRamp;
device->GetGammaRamp = NULL;
device->SetCaption = NULL;
device->SetIcon = NULL;
device->IconifyWindow = NULL;
device->GrabInput = NULL;
device->GetWMInfo = NULL;
device->InitOSKeymap = DGA_InitOSKeymap;
device->PumpEvents = DGA_PumpEvents;
device->free = DGA_DeleteDevice;
} }
memset(device->hidden, 0, (sizeof *device->hidden));
/* Set the function pointers */
device->VideoInit = DGA_VideoInit;
device->ListModes = DGA_ListModes;
device->SetVideoMode = DGA_SetVideoMode;
device->SetColors = DGA_SetColors;
device->UpdateRects = NULL;
device->VideoQuit = DGA_VideoQuit;
device->AllocHWSurface = DGA_AllocHWSurface;
device->CheckHWBlit = DGA_CheckHWBlit;
device->FillHWRect = DGA_FillHWRect;
device->SetHWColorKey = NULL;
device->SetHWAlpha = NULL;
device->LockHWSurface = DGA_LockHWSurface;
device->UnlockHWSurface = DGA_UnlockHWSurface;
device->FlipHWSurface = DGA_FlipHWSurface;
device->FreeHWSurface = DGA_FreeHWSurface;
device->SetGammaRamp = DGA_SetGammaRamp;
device->GetGammaRamp = NULL;
device->SetCaption = NULL;
device->SetIcon = NULL;
device->IconifyWindow = NULL;
device->GrabInput = NULL;
device->GetWMInfo = NULL;
device->InitOSKeymap = DGA_InitOSKeymap;
device->PumpEvents = DGA_PumpEvents;
device->free = DGA_DeleteDevice;
return device; return device;
} }
...@@ -329,7 +339,7 @@ static int DGA_VideoInit(_THIS, SDL_PixelFormat *vformat) ...@@ -329,7 +339,7 @@ static int DGA_VideoInit(_THIS, SDL_PixelFormat *vformat)
/* Open the X11 display */ /* Open the X11 display */
display = NULL; /* Get it from DISPLAY environment variable */ display = NULL; /* Get it from DISPLAY environment variable */
DGA_Display = XOpenDisplay(display); DGA_Display = pXOpenDisplay(display);
if ( DGA_Display == NULL ) { if ( DGA_Display == NULL ) {
SDL_SetError("Couldn't open X11 display"); SDL_SetError("Couldn't open X11 display");
return(-1); return(-1);
...@@ -339,12 +349,12 @@ static int DGA_VideoInit(_THIS, SDL_PixelFormat *vformat) ...@@ -339,12 +349,12 @@ static int DGA_VideoInit(_THIS, SDL_PixelFormat *vformat)
if ( ! SDL_NAME(XDGAQueryExtension)(DGA_Display, &event_base, &error_base) || if ( ! SDL_NAME(XDGAQueryExtension)(DGA_Display, &event_base, &error_base) ||
! SDL_NAME(XDGAQueryVersion)(DGA_Display, &major_version, &minor_version) ) { ! SDL_NAME(XDGAQueryVersion)(DGA_Display, &major_version, &minor_version) ) {
SDL_SetError("DGA extension not available"); SDL_SetError("DGA extension not available");
XCloseDisplay(DGA_Display); pXCloseDisplay(DGA_Display);
return(-1); return(-1);
} }
if ( major_version < 2 ) { if ( major_version < 2 ) {
SDL_SetError("DGA driver requires DGA 2.0 or newer"); SDL_SetError("DGA driver requires DGA 2.0 or newer");
XCloseDisplay(DGA_Display); pXCloseDisplay(DGA_Display);
return(-1); return(-1);
} }
DGA_event_base = event_base; DGA_event_base = event_base;
...@@ -356,10 +366,10 @@ static int DGA_VideoInit(_THIS, SDL_PixelFormat *vformat) ...@@ -356,10 +366,10 @@ static int DGA_VideoInit(_THIS, SDL_PixelFormat *vformat)
int i, num_formats; int i, num_formats;
vformat->BitsPerPixel = DefaultDepth(DGA_Display, DGA_Screen); vformat->BitsPerPixel = DefaultDepth(DGA_Display, DGA_Screen);
pix_format = XListPixmapFormats(DGA_Display, &num_formats); pix_format = pXListPixmapFormats(DGA_Display, &num_formats);
if ( pix_format == NULL ) { if ( pix_format == NULL ) {
SDL_SetError("Couldn't determine screen formats"); SDL_SetError("Couldn't determine screen formats");
XCloseDisplay(DGA_Display); pXCloseDisplay(DGA_Display);
return(-1); return(-1);
} }
for ( i=0; i<num_formats; ++i ) { for ( i=0; i<num_formats; ++i ) {
...@@ -368,7 +378,7 @@ static int DGA_VideoInit(_THIS, SDL_PixelFormat *vformat) ...@@ -368,7 +378,7 @@ static int DGA_VideoInit(_THIS, SDL_PixelFormat *vformat)
} }
if ( i != num_formats ) if ( i != num_formats )
vformat->BitsPerPixel = pix_format[i].bits_per_pixel; vformat->BitsPerPixel = pix_format[i].bits_per_pixel;
XFree((char *)pix_format); pXFree((char *)pix_format);
} }
if ( vformat->BitsPerPixel > 8 ) { if ( vformat->BitsPerPixel > 8 ) {
vformat->Rmask = visual->red_mask; vformat->Rmask = visual->red_mask;
...@@ -379,7 +389,7 @@ static int DGA_VideoInit(_THIS, SDL_PixelFormat *vformat) ...@@ -379,7 +389,7 @@ static int DGA_VideoInit(_THIS, SDL_PixelFormat *vformat)
/* Open access to the framebuffer */ /* Open access to the framebuffer */
if ( ! SDL_NAME(XDGAOpenFramebuffer)(DGA_Display, DGA_Screen) ) { if ( ! SDL_NAME(XDGAOpenFramebuffer)(DGA_Display, DGA_Screen) ) {
SDL_SetError("Unable to map the video memory"); SDL_SetError("Unable to map the video memory");
XCloseDisplay(DGA_Display); pXCloseDisplay(DGA_Display);
return(-1); return(-1);
} }
...@@ -399,7 +409,7 @@ static int DGA_VideoInit(_THIS, SDL_PixelFormat *vformat) ...@@ -399,7 +409,7 @@ static int DGA_VideoInit(_THIS, SDL_PixelFormat *vformat)
} }
} }
UpdateHWInfo(this, modes); UpdateHWInfo(this, modes);
XFree(modes); pXFree(modes);
/* Create the hardware surface lock mutex */ /* Create the hardware surface lock mutex */
hw_lock = SDL_CreateMutex(); hw_lock = SDL_CreateMutex();
...@@ -438,7 +448,7 @@ SDL_Surface *DGA_SetVideoMode(_THIS, SDL_Surface *current, ...@@ -438,7 +448,7 @@ SDL_Surface *DGA_SetVideoMode(_THIS, SDL_Surface *current,
/* Free any previous colormap */ /* Free any previous colormap */
if ( DGA_colormap ) { if ( DGA_colormap ) {
XFreeColormap(DGA_Display, DGA_colormap); pXFreeColormap(DGA_Display, DGA_colormap);
DGA_colormap = 0; DGA_colormap = 0;
} }
...@@ -469,7 +479,7 @@ SDL_Surface *DGA_SetVideoMode(_THIS, SDL_Surface *current, ...@@ -469,7 +479,7 @@ SDL_Surface *DGA_SetVideoMode(_THIS, SDL_Surface *current,
/* Set the video mode */ /* Set the video mode */
mode = SDL_NAME(XDGASetMode)(DGA_Display, DGA_Screen, modes[i].num); mode = SDL_NAME(XDGASetMode)(DGA_Display, DGA_Screen, modes[i].num);
XFree(modes); pXFree(modes);
if ( mode == NULL ) { if ( mode == NULL ) {
SDL_SetError("Unable to switch to requested mode"); SDL_SetError("Unable to switch to requested mode");
return(NULL); return(NULL);
...@@ -817,7 +827,7 @@ static int DGA_FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *rect, Uint32 color) ...@@ -817,7 +827,7 @@ static int DGA_FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *rect, Uint32 color)
#endif #endif
SDL_NAME(XDGAFillRectangle)(DGA_Display, DGA_Screen, x, y, w, h, color); SDL_NAME(XDGAFillRectangle)(DGA_Display, DGA_Screen, x, y, w, h, color);
if ( !(this->screen->flags & SDL_DOUBLEBUF) ) { if ( !(this->screen->flags & SDL_DOUBLEBUF) ) {
XFlush(DGA_Display); pXFlush(DGA_Display);
} }
DGA_AddBusySurface(dst); DGA_AddBusySurface(dst);
UNLOCK_DISPLAY(); UNLOCK_DISPLAY();
...@@ -859,7 +869,7 @@ static int HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect, ...@@ -859,7 +869,7 @@ static int HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect,
srcx, srcy, w, h, dstx, dsty); srcx, srcy, w, h, dstx, dsty);
} }
if ( !(this->screen->flags & SDL_DOUBLEBUF) ) { if ( !(this->screen->flags & SDL_DOUBLEBUF) ) {
XFlush(DGA_Display); pXFlush(DGA_Display);
} }
DGA_AddBusySurface(src); DGA_AddBusySurface(src);
DGA_AddBusySurface(dst); DGA_AddBusySurface(dst);
...@@ -939,7 +949,7 @@ static int DGA_FlipHWSurface(_THIS, SDL_Surface *surface) ...@@ -939,7 +949,7 @@ static int DGA_FlipHWSurface(_THIS, SDL_Surface *surface)
DGA_WaitFlip(this); DGA_WaitFlip(this);
SDL_NAME(XDGASetViewport)(DGA_Display, DGA_Screen, SDL_NAME(XDGASetViewport)(DGA_Display, DGA_Screen,
0, flip_yoffset[flip_page], XDGAFlipRetrace); 0, flip_yoffset[flip_page], XDGAFlipRetrace);
XFlush(DGA_Display); pXFlush(DGA_Display);
UNLOCK_DISPLAY(); UNLOCK_DISPLAY();
was_flipped = 1; was_flipped = 1;
flip_page = !flip_page; flip_page = !flip_page;
...@@ -972,8 +982,8 @@ static int DGA_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) ...@@ -972,8 +982,8 @@ static int DGA_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
xcmap[i].flags = (DoRed|DoGreen|DoBlue); xcmap[i].flags = (DoRed|DoGreen|DoBlue);
} }
LOCK_DISPLAY(); LOCK_DISPLAY();
XStoreColors(DGA_Display, DGA_colormap, xcmap, ncolors); pXStoreColors(DGA_Display, DGA_colormap, xcmap, ncolors);
XSync(DGA_Display, False); pXSync(DGA_Display, False);
UNLOCK_DISPLAY(); UNLOCK_DISPLAY();
/* That was easy. :) */ /* That was easy. :) */
...@@ -1006,8 +1016,8 @@ int DGA_SetGammaRamp(_THIS, Uint16 *ramp) ...@@ -1006,8 +1016,8 @@ int DGA_SetGammaRamp(_THIS, Uint16 *ramp)
xcmap[i].flags = (DoRed|DoGreen|DoBlue); xcmap[i].flags = (DoRed|DoGreen|DoBlue);
} }
LOCK_DISPLAY(); LOCK_DISPLAY();
XStoreColors(DGA_Display, DGA_colormap, xcmap, ncolors); pXStoreColors(DGA_Display, DGA_colormap, xcmap, ncolors);
XSync(DGA_Display, False); pXSync(DGA_Display, False);
UNLOCK_DISPLAY(); UNLOCK_DISPLAY();
return(0); return(0);
} }
...@@ -1019,7 +1029,7 @@ void DGA_VideoQuit(_THIS) ...@@ -1019,7 +1029,7 @@ void DGA_VideoQuit(_THIS)
if ( DGA_Display ) { if ( DGA_Display ) {
/* Free colormap, if necessary */ /* Free colormap, if necessary */
if ( DGA_colormap ) { if ( DGA_colormap ) {
XFreeColormap(DGA_Display, DGA_colormap); pXFreeColormap(DGA_Display, DGA_colormap);
DGA_colormap = 0; DGA_colormap = 0;
} }
...@@ -1059,6 +1069,6 @@ void DGA_VideoQuit(_THIS) ...@@ -1059,6 +1069,6 @@ void DGA_VideoQuit(_THIS)
DGA_FreeHWSurfaces(this); DGA_FreeHWSurfaces(this);
/* Close up the display */ /* Close up the display */
XCloseDisplay(DGA_Display); pXCloseDisplay(DGA_Display);
} }
} }
...@@ -4,6 +4,9 @@ ...@@ -4,6 +4,9 @@
noinst_LTLIBRARIES = libvideo_x11.la noinst_LTLIBRARIES = libvideo_x11.la
libvideo_x11_la_SOURCES = $(X11_SRCS) libvideo_x11_la_SOURCES = $(X11_SRCS)
x11_lib = \"@x11_lib@\"
x11ext_lib = \"@x11ext_lib@\"
# The SDL X11 video driver sources # The SDL X11 video driver sources
X11_SRCS = \ X11_SRCS = \
SDL_x11dga.c \ SDL_x11dga.c \
...@@ -25,4 +28,8 @@ X11_SRCS = \ ...@@ -25,4 +28,8 @@ X11_SRCS = \
SDL_x11wm.c \ SDL_x11wm.c \
SDL_x11wm_c.h \ SDL_x11wm_c.h \
SDL_x11yuv.c \ SDL_x11yuv.c \
SDL_x11yuv_c.h SDL_x11yuv_c.h \
SDL_x11dyn.c \
SDL_x11dyn.h \
SDL_x11sym.h
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2004 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
/*#define DEBUG_DYNAMIC_X11 1*/
#include "SDL_x11dyn.h"
#ifdef DEBUG_DYNAMIC_X11
#include <stdio.h>
#endif
#ifdef X11_DYNAMIC
#include <dlfcn.h>
#include "SDL_name.h"
#include "SDL_loadso.h"
static const char *x11_library = X11_DYNAMIC;
static void *x11_handle = NULL;
static const char *x11ext_library = X11EXT_DYNAMIC;
static void *x11ext_handle = NULL;
static void *X11_GetSym(const char *fnname, int *rc)
{
void *fn = NULL;
if (*rc) { /* haven't already failed on a previous lookup? */
fn = SDL_LoadFunction(x11_handle, fnname);
#if DEBUG_DYNAMIC_X11
if (fn != NULL)
printf("X11: Found '%s' in libX11 (%p)\n", fnname, fn);
#endif
if (fn == NULL) { /* not found? Check libX11ext ... */
fn = SDL_LoadFunction(x11ext_handle, fnname);
#if DEBUG_DYNAMIC_X11
if (fn != NULL)
printf("X11: Found '%s' in libXext (%p)\n", fnname, fn);
else
printf("X11: Symbol '%s' NOT FOUND!\n", fnname);
#endif
}
*rc = (fn != NULL);
}
return fn;
}
#endif /* defined X11_DYNAMIC */
/* Define all the function pointers... */
#define SDL_X11_SYM(ret,fn,params) ret (*p##fn) params = NULL;
#include "SDL_x11sym.h"
#undef SDL_X11_SYM
static int x11_load_refcount = 0;
void SDL_X11_UnloadSymbols(void)
{
/* Don't actually unload if more than one module is using the libs... */
if (x11_load_refcount > 0) {
if (--x11_load_refcount == 0) {
/* set all the function pointers to NULL. */
#define SDL_X11_SYM(ret,fn,params) p##fn = NULL;
#include "SDL_x11sym.h"
#undef SDL_X11_SYM
#ifdef X11_DYNAMIC
if (x11_handle != NULL) {
SDL_UnloadObject(x11_handle);
x11_handle = NULL;
}
if (x11ext_handle != NULL) {
SDL_UnloadObject(x11ext_handle);
x11ext_handle = NULL;
}
#endif
}
}
}
/* returns non-zero if all needed symbols were loaded. */
int SDL_X11_LoadSymbols(void)
{
int rc = 1;
/* deal with multiple modules (dga, x11, etc) needing these symbols... */
if (x11_load_refcount++ == 0) {
#ifdef X11_DYNAMIC
x11_handle = SDL_LoadObject(x11_library);
x11ext_handle = SDL_LoadObject(x11ext_library);
if ((x11_handle != NULL) && (x11ext_handle != NULL)) {
#define SDL_X11_SYM(r,fn,arg) p##fn = X11_GetSym(#fn, &rc);
#include "SDL_x11sym.h"
#undef SDL_X11_SYM
}
if (!rc)
SDL_X11_UnloadSymbols(); /* in case one of these loaded... */
#else
#define SDL_X11_SYM(r,fn,arg) p##fn = fn;
#include "SDL_x11sym.h"
#undef SDL_X11_SYM
#endif
}
return rc;
}
/* end of SDL_x11dyn.c ... */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2004 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#ifndef _SDL_x11dyn_h
#define _SDL_x11dyn_h
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include <X11/Xproto.h>
#include <X11/Xlibint.h>
#include <X11/extensions/extutil.h>
#ifndef NO_SHARED_MEMORY
#include <sys/ipc.h>
#include <sys/shm.h>
#include <X11/extensions/XShm.h>
#endif
/*
* Never reference Xlib directly...we might load it dynamically at runtime.
* Even if we don't, for readability, we still use the function pointers
* (although the symbol resolution will be done by the loader in that case).
*
* We define SDL_X11_SYM and include SDL_x11sym.h to accomplish various
* goals, without having to duplicate those function signatures.
*/
#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*);
#define SDL_X11_SYM(ret,fn,params) extern ret (*p##fn) params;
#include "SDL_x11sym.h"
#undef SDL_X11_SYM
/* Macro in the xlib headers, not an actual symbol... */
#define pXDestroyImage XDestroyImage
int SDL_X11_LoadSymbols(void);
void SDL_X11_UnloadSymbols(void);
#ifdef __cplusplus
}
#endif
#endif /* !defined _SDL_x11dyn_h */
...@@ -74,13 +74,13 @@ static int X11_KeyRepeat(Display *display, XEvent *event) ...@@ -74,13 +74,13 @@ static int X11_KeyRepeat(Display *display, XEvent *event)
int repeated; int repeated;
repeated = 0; repeated = 0;
if ( XPending(display) ) { if ( pXPending(display) ) {
XPeekEvent(display, &peekevent); pXPeekEvent(display, &peekevent);
if ( (peekevent.type == KeyPress) && if ( (peekevent.type == KeyPress) &&
(peekevent.xkey.keycode == event->xkey.keycode) && (peekevent.xkey.keycode == event->xkey.keycode) &&
((peekevent.xkey.time-event->xkey.time) < 2) ) { ((peekevent.xkey.time-event->xkey.time) < 2) ) {
repeated = 1; repeated = 1;
XNextEvent(display, &peekevent); pXNextEvent(display, &peekevent);
} }
} }
return(repeated); return(repeated);
...@@ -115,7 +115,7 @@ static __inline__ int X11_WarpedMotion(_THIS, XEvent *xevent) ...@@ -115,7 +115,7 @@ static __inline__ int X11_WarpedMotion(_THIS, XEvent *xevent)
(xevent->xmotion.y < MOUSE_FUDGE_FACTOR) || (xevent->xmotion.y < MOUSE_FUDGE_FACTOR) ||
(xevent->xmotion.y > (h-MOUSE_FUDGE_FACTOR)) ) { (xevent->xmotion.y > (h-MOUSE_FUDGE_FACTOR)) ) {
/* Get the events that have accumulated */ /* Get the events that have accumulated */
while ( XCheckTypedEvent(SDL_Display, MotionNotify, xevent) ) { while ( pXCheckTypedEvent(SDL_Display, MotionNotify, xevent) ) {
deltax = xevent->xmotion.x - mouse_last.x; deltax = xevent->xmotion.x - mouse_last.x;
deltay = xevent->xmotion.y - mouse_last.y; deltay = xevent->xmotion.y - mouse_last.y;
#ifdef DEBUG_MOTION #ifdef DEBUG_MOTION
...@@ -127,10 +127,10 @@ static __inline__ int X11_WarpedMotion(_THIS, XEvent *xevent) ...@@ -127,10 +127,10 @@ static __inline__ int X11_WarpedMotion(_THIS, XEvent *xevent)
} }
mouse_last.x = w/2; mouse_last.x = w/2;
mouse_last.y = h/2; mouse_last.y = h/2;
XWarpPointer(SDL_Display, None, SDL_Window, 0, 0, 0, 0, pXWarpPointer(SDL_Display, None, SDL_Window, 0, 0, 0, 0,
mouse_last.x, mouse_last.y); mouse_last.x, mouse_last.y);
for ( i=0; i<10; ++i ) { for ( i=0; i<10; ++i ) {
XMaskEvent(SDL_Display, PointerMotionMask, xevent); pXMaskEvent(SDL_Display, PointerMotionMask, xevent);
if ( (xevent->xmotion.x > if ( (xevent->xmotion.x >
(mouse_last.x-MOUSE_FUDGE_FACTOR)) && (mouse_last.x-MOUSE_FUDGE_FACTOR)) &&
(xevent->xmotion.x < (xevent->xmotion.x <
...@@ -160,7 +160,7 @@ static int X11_DispatchEvent(_THIS) ...@@ -160,7 +160,7 @@ static int X11_DispatchEvent(_THIS)
XEvent xevent; XEvent xevent;
memset(&xevent, '\0', sizeof (XEvent)); /* valgrind fix. --ryan. */ memset(&xevent, '\0', sizeof (XEvent)); /* valgrind fix. --ryan. */
XNextEvent(SDL_Display, &xevent); pXNextEvent(SDL_Display, &xevent);
posted = 0; posted = 0;
switch (xevent.type) { switch (xevent.type) {
...@@ -437,8 +437,8 @@ printf("Unhandled event %d\n", xevent.type); ...@@ -437,8 +437,8 @@ printf("Unhandled event %d\n", xevent.type);
int X11_Pending(Display *display) int X11_Pending(Display *display)
{ {
/* Flush the display connection and look to see if events are queued */ /* Flush the display connection and look to see if events are queued */
XFlush(display); pXFlush(display);
if ( XEventsQueued(display, QueuedAlready) ) { if ( pXEventsQueued(display, QueuedAlready) ) {
return(1); return(1);
} }
...@@ -452,7 +452,7 @@ int X11_Pending(Display *display) ...@@ -452,7 +452,7 @@ int X11_Pending(Display *display)
FD_ZERO(&fdset); FD_ZERO(&fdset);
FD_SET(x11_fd, &fdset); FD_SET(x11_fd, &fdset);
if ( select(x11_fd+1, &fdset, NULL, NULL, &zero_time) == 1 ) { if ( select(x11_fd+1, &fdset, NULL, NULL, &zero_time) == 1 ) {
return(XPending(display)); return(pXPending(display));
} }
} }
...@@ -619,7 +619,7 @@ SDL_keysym *X11_TranslateKey(Display *display, XKeyEvent *xkey, KeyCode kc, ...@@ -619,7 +619,7 @@ SDL_keysym *X11_TranslateKey(Display *display, XKeyEvent *xkey, KeyCode kc,
/* Get the raw keyboard scancode */ /* Get the raw keyboard scancode */
keysym->scancode = kc; keysym->scancode = kc;
xsym = XKeycodeToKeysym(display, kc, 0); xsym = pXKeycodeToKeysym(display, kc, 0);
#ifdef DEBUG_KEYS #ifdef DEBUG_KEYS
fprintf(stderr, "Translating key 0x%.4x (%d)\n", xsym, kc); fprintf(stderr, "Translating key 0x%.4x (%d)\n", xsym, kc);
#endif #endif
...@@ -711,7 +711,7 @@ SDL_keysym *X11_TranslateKey(Display *display, XKeyEvent *xkey, KeyCode kc, ...@@ -711,7 +711,7 @@ SDL_keysym *X11_TranslateKey(Display *display, XKeyEvent *xkey, KeyCode kc,
} }
#endif #endif
/* Look up the translated value for the key event */ /* Look up the translated value for the key event */
if ( XLookupString(xkey, (char *)keybuf, sizeof(keybuf), if ( pXLookupString(xkey, (char *)keybuf, sizeof(keybuf),
NULL, &state) ) { NULL, &state) ) {
/* /*
* FIXME,: XLookupString() may yield more than one * FIXME,: XLookupString() may yield more than one
...@@ -739,12 +739,12 @@ static void get_modifier_masks(Display *display) ...@@ -739,12 +739,12 @@ static void get_modifier_masks(Display *display)
if(got_masks) if(got_masks)
return; return;
xmods = XGetModifierMapping(display); xmods = pXGetModifierMapping(display);
n = xmods->max_keypermod; n = xmods->max_keypermod;
for(i = 3; i < 8; i++) { for(i = 3; i < 8; i++) {
for(j = 0; j < n; j++) { for(j = 0; j < n; j++) {
KeyCode kc = xmods->modifiermap[i * n + j]; KeyCode kc = xmods->modifiermap[i * n + j];
KeySym ks = XKeycodeToKeysym(display, kc, 0); KeySym ks = pXKeycodeToKeysym(display, kc, 0);
unsigned mask = 1 << i; unsigned mask = 1 << i;
switch(ks) { switch(ks) {
case XK_Num_Lock: case XK_Num_Lock:
...@@ -762,7 +762,7 @@ static void get_modifier_masks(Display *display) ...@@ -762,7 +762,7 @@ static void get_modifier_masks(Display *display)
} }
} }
} }
XFreeModifiermap(xmods); pXFreeModifiermap(xmods);
got_masks = 1; got_masks = 1;
} }
...@@ -804,7 +804,7 @@ Uint16 X11_KeyToUnicode(SDLKey keysym, SDLMod modifiers) ...@@ -804,7 +804,7 @@ Uint16 X11_KeyToUnicode(SDLKey keysym, SDLMod modifiers)
} }
} }
xkey.keycode = XKeysymToKeycode(xkey.display, xsym); xkey.keycode = pXKeysymToKeycode(xkey.display, xsym);
get_modifier_masks(SDL_Display); get_modifier_masks(SDL_Display);
if(modifiers & KMOD_SHIFT) if(modifiers & KMOD_SHIFT)
...@@ -827,7 +827,7 @@ Uint16 X11_KeyToUnicode(SDLKey keysym, SDLMod modifiers) ...@@ -827,7 +827,7 @@ Uint16 X11_KeyToUnicode(SDLKey keysym, SDLMod modifiers)
xkey.state |= num_mask; xkey.state |= num_mask;
unicode = 0; unicode = 0;
if ( XLookupString(&xkey, keybuf, sizeof(keybuf), NULL, NULL) ) if ( pXLookupString(&xkey, keybuf, sizeof(keybuf), NULL, NULL) )
unicode = (unsigned char)keybuf[0]; unicode = (unsigned char)keybuf[0];
return(unicode); return(unicode);
} }
...@@ -851,14 +851,14 @@ void X11_SetKeyboardState(Display *display, const char *key_vec) ...@@ -851,14 +851,14 @@ void X11_SetKeyboardState(Display *display, const char *key_vec)
/* The first time the window is mapped, we initialize key state */ /* The first time the window is mapped, we initialize key state */
if ( ! key_vec ) { if ( ! key_vec ) {
XQueryKeymap(display, keys_return); pXQueryKeymap(display, keys_return);
key_vec = keys_return; key_vec = keys_return;
} }
/* Get the keyboard modifier state */ /* Get the keyboard modifier state */
modstate = 0; modstate = 0;
get_modifier_masks(display); get_modifier_masks(display);
if ( XQueryPointer(display, DefaultRootWindow(display), if ( pXQueryPointer(display, DefaultRootWindow(display),
&junk_window, &junk_window, &x, &y, &x, &y, &mask) ) { &junk_window, &junk_window, &x, &y, &x, &y, &mask) ) {
if ( mask & LockMask ) { if ( mask & LockMask ) {
modstate |= KMOD_CAPS; modstate |= KMOD_CAPS;
......
...@@ -68,7 +68,7 @@ static int X11_SetGammaNoLock(_THIS, float red, float green, float blue) ...@@ -68,7 +68,7 @@ static int X11_SetGammaNoLock(_THIS, float red, float green, float blue)
} }
if ( SDL_GetAppState() & SDL_APPACTIVE ) { if ( SDL_GetAppState() & SDL_APPACTIVE ) {
succeeded = SDL_NAME(XF86VidModeSetGamma)(SDL_Display, SDL_Screen, &gamma); succeeded = SDL_NAME(XF86VidModeSetGamma)(SDL_Display, SDL_Screen, &gamma);
XSync(SDL_Display, False); pXSync(SDL_Display, False);
} else { } else {
gamma_saved[0] = gamma.red; gamma_saved[0] = gamma.red;
gamma_saved[1] = gamma.green; gamma_saved[1] = gamma.green;
......
...@@ -69,10 +69,10 @@ XVisualInfo *X11_GL_GetVisual(_THIS) ...@@ -69,10 +69,10 @@ XVisualInfo *X11_GL_GetVisual(_THIS)
XVisualInfo vi_in; XVisualInfo vi_in;
int out_count; int out_count;
XGetWindowAttributes(SDL_Display, SDL_Window, &a); pXGetWindowAttributes(SDL_Display, SDL_Window, &a);
vi_in.screen = SDL_Screen; vi_in.screen = SDL_Screen;
vi_in.visualid = XVisualIDFromVisual(a.visual); vi_in.visualid = pXVisualIDFromVisual(a.visual);
glx_visualinfo = XGetVisualInfo(SDL_Display, glx_visualinfo = pXGetVisualInfo(SDL_Display,
VisualScreenMask|VisualIDMask, &vi_in, &out_count); VisualScreenMask|VisualIDMask, &vi_in, &out_count);
return glx_visualinfo; return glx_visualinfo;
} }
...@@ -188,7 +188,7 @@ int X11_GL_CreateWindow(_THIS, int w, int h) ...@@ -188,7 +188,7 @@ int X11_GL_CreateWindow(_THIS, int w, int h)
attributes.colormap = SDL_XColorMap; attributes.colormap = SDL_XColorMap;
mask = CWBackPixel | CWBorderPixel | CWColormap; mask = CWBackPixel | CWBorderPixel | CWColormap;
SDL_Window = XCreateWindow(SDL_Display, WMwindow, SDL_Window = pXCreateWindow(SDL_Display, WMwindow,
0, 0, w, h, 0, glx_visualinfo->depth, 0, 0, w, h, 0, glx_visualinfo->depth,
InputOutput, glx_visualinfo->visual, InputOutput, glx_visualinfo->visual,
mask, &attributes); mask, &attributes);
...@@ -209,10 +209,10 @@ int X11_GL_CreateContext(_THIS) ...@@ -209,10 +209,10 @@ int X11_GL_CreateContext(_THIS)
int retval; int retval;
#ifdef HAVE_OPENGL #ifdef HAVE_OPENGL
/* We do this to create a clean separation between X and GLX errors. */ /* We do this to create a clean separation between X and GLX errors. */
XSync( SDL_Display, False ); pXSync( SDL_Display, False );
glx_context = this->gl_data->glXCreateContext(GFX_Display, glx_context = this->gl_data->glXCreateContext(GFX_Display,
glx_visualinfo, NULL, True); glx_visualinfo, NULL, True);
XSync( GFX_Display, False ); pXSync( GFX_Display, False );
if (glx_context == NULL) { if (glx_context == NULL) {
SDL_SetError("Could not create GL context"); SDL_SetError("Could not create GL context");
...@@ -296,7 +296,7 @@ int X11_GL_MakeCurrent(_THIS) ...@@ -296,7 +296,7 @@ int X11_GL_MakeCurrent(_THIS)
SDL_SetError("Unable to make GL context current"); SDL_SetError("Unable to make GL context current");
retval = -1; retval = -1;
} }
XSync( GFX_Display, False ); pXSync( GFX_Display, False );
/* /*
* The context is now current, check for glXReleaseBuffersMESA() * The context is now current, check for glXReleaseBuffersMESA()
......
...@@ -35,9 +35,6 @@ static char rcsid = ...@@ -35,9 +35,6 @@ static char rcsid =
#ifndef NO_SHARED_MEMORY #ifndef NO_SHARED_MEMORY
/* Shared memory information */
extern int XShmQueryExtension(Display *dpy); /* Not in X11 headers */
/* Shared memory error handler routine */ /* Shared memory error handler routine */
static int shm_error; static int shm_error;
static int (*X_handler)(Display *, XErrorEvent *) = NULL; static int (*X_handler)(Display *, XErrorEvent *) = NULL;
...@@ -61,10 +58,10 @@ static void try_mitshm(_THIS, SDL_Surface *screen) ...@@ -61,10 +58,10 @@ static void try_mitshm(_THIS, SDL_Surface *screen)
shminfo.readOnly = False; shminfo.readOnly = False;
if ( shminfo.shmaddr != (char *)-1 ) { if ( shminfo.shmaddr != (char *)-1 ) {
shm_error = False; shm_error = False;
X_handler = XSetErrorHandler(shm_errhandler); X_handler = pXSetErrorHandler(shm_errhandler);
XShmAttach(SDL_Display, &shminfo); pXShmAttach(SDL_Display, &shminfo);
XSync(SDL_Display, True); pXSync(SDL_Display, True);
XSetErrorHandler(X_handler); pXSetErrorHandler(X_handler);
if ( shm_error ) if ( shm_error )
shmdt(shminfo.shmaddr); shmdt(shminfo.shmaddr);
} else { } else {
...@@ -90,13 +87,13 @@ int X11_SetupImage(_THIS, SDL_Surface *screen) ...@@ -90,13 +87,13 @@ int X11_SetupImage(_THIS, SDL_Surface *screen)
#ifndef NO_SHARED_MEMORY #ifndef NO_SHARED_MEMORY
try_mitshm(this, screen); try_mitshm(this, screen);
if(use_mitshm) { if(use_mitshm) {
SDL_Ximage = XShmCreateImage(SDL_Display, SDL_Visual, SDL_Ximage = pXShmCreateImage(SDL_Display, SDL_Visual,
this->hidden->depth, ZPixmap, this->hidden->depth, ZPixmap,
shminfo.shmaddr, &shminfo, shminfo.shmaddr, &shminfo,
screen->w, screen->h); screen->w, screen->h);
if(!SDL_Ximage) { if(!SDL_Ximage) {
XShmDetach(SDL_Display, &shminfo); pXShmDetach(SDL_Display, &shminfo);
XSync(SDL_Display, False); pXSync(SDL_Display, False);
shmdt(shminfo.shmaddr); shmdt(shminfo.shmaddr);
screen->pixels = NULL; screen->pixels = NULL;
goto error; goto error;
...@@ -113,7 +110,7 @@ int X11_SetupImage(_THIS, SDL_Surface *screen) ...@@ -113,7 +110,7 @@ int X11_SetupImage(_THIS, SDL_Surface *screen)
return -1; return -1;
} }
bpp = screen->format->BytesPerPixel; bpp = screen->format->BytesPerPixel;
SDL_Ximage = XCreateImage(SDL_Display, SDL_Visual, SDL_Ximage = pXCreateImage(SDL_Display, SDL_Visual,
this->hidden->depth, ZPixmap, 0, this->hidden->depth, ZPixmap, 0,
(char *)screen->pixels, (char *)screen->pixels,
screen->w, screen->h, screen->w, screen->h,
...@@ -136,11 +133,11 @@ error: ...@@ -136,11 +133,11 @@ error:
void X11_DestroyImage(_THIS, SDL_Surface *screen) void X11_DestroyImage(_THIS, SDL_Surface *screen)
{ {
if ( SDL_Ximage ) { if ( SDL_Ximage ) {
XDestroyImage(SDL_Ximage); pXDestroyImage(SDL_Ximage);
#ifndef NO_SHARED_MEMORY #ifndef NO_SHARED_MEMORY
if ( use_mitshm ) { if ( use_mitshm ) {
XShmDetach(SDL_Display, &shminfo); pXShmDetach(SDL_Display, &shminfo);
XSync(SDL_Display, False); pXSync(SDL_Display, False);
shmdt(shminfo.shmaddr); shmdt(shminfo.shmaddr);
} }
#endif /* ! NO_SHARED_MEMORY */ #endif /* ! NO_SHARED_MEMORY */
...@@ -221,7 +218,7 @@ void X11_FreeHWSurface(_THIS, SDL_Surface *surface) ...@@ -221,7 +218,7 @@ void X11_FreeHWSurface(_THIS, SDL_Surface *surface)
int X11_LockHWSurface(_THIS, SDL_Surface *surface) int X11_LockHWSurface(_THIS, SDL_Surface *surface)
{ {
if ( (surface == SDL_VideoSurface) && blit_queued ) { if ( (surface == SDL_VideoSurface) && blit_queued ) {
XSync(GFX_Display, False); pXSync(GFX_Display, False);
blit_queued = 0; blit_queued = 0;
} }
return(0); return(0);
...@@ -244,15 +241,15 @@ static void X11_NormalUpdate(_THIS, int numrects, SDL_Rect *rects) ...@@ -244,15 +241,15 @@ static void X11_NormalUpdate(_THIS, int numrects, SDL_Rect *rects)
if ( rects[i].w == 0 || rects[i].h == 0 ) { /* Clipped? */ if ( rects[i].w == 0 || rects[i].h == 0 ) { /* Clipped? */
continue; continue;
} }
XPutImage(GFX_Display, SDL_Window, SDL_GC, SDL_Ximage, pXPutImage(GFX_Display, SDL_Window, SDL_GC, SDL_Ximage,
rects[i].x, rects[i].y, rects[i].x, rects[i].y,
rects[i].x, rects[i].y, rects[i].w, rects[i].h); rects[i].x, rects[i].y, rects[i].w, rects[i].h);
} }
if ( SDL_VideoSurface->flags & SDL_ASYNCBLIT ) { if ( SDL_VideoSurface->flags & SDL_ASYNCBLIT ) {
XFlush(GFX_Display); pXFlush(GFX_Display);
blit_queued = 1; blit_queued = 1;
} else { } else {
XSync(GFX_Display, False); pXSync(GFX_Display, False);
} }
} }
...@@ -265,16 +262,16 @@ static void X11_MITSHMUpdate(_THIS, int numrects, SDL_Rect *rects) ...@@ -265,16 +262,16 @@ static void X11_MITSHMUpdate(_THIS, int numrects, SDL_Rect *rects)
if ( rects[i].w == 0 || rects[i].h == 0 ) { /* Clipped? */ if ( rects[i].w == 0 || rects[i].h == 0 ) { /* Clipped? */
continue; continue;
} }
XShmPutImage(GFX_Display, SDL_Window, SDL_GC, SDL_Ximage, pXShmPutImage(GFX_Display, SDL_Window, SDL_GC, SDL_Ximage,
rects[i].x, rects[i].y, rects[i].x, rects[i].y,
rects[i].x, rects[i].y, rects[i].w, rects[i].h, rects[i].x, rects[i].y, rects[i].w, rects[i].h,
False); False);
} }
if ( SDL_VideoSurface->flags & SDL_ASYNCBLIT ) { if ( SDL_VideoSurface->flags & SDL_ASYNCBLIT ) {
XFlush(GFX_Display); pXFlush(GFX_Display);
blit_queued = 1; blit_queued = 1;
} else { } else {
XSync(GFX_Display, False); pXSync(GFX_Display, False);
} }
#endif /* ! NO_SHARED_MEMORY */ #endif /* ! NO_SHARED_MEMORY */
} }
...@@ -308,14 +305,14 @@ void X11_RefreshDisplay(_THIS) ...@@ -308,14 +305,14 @@ void X11_RefreshDisplay(_THIS)
} }
#ifndef NO_SHARED_MEMORY #ifndef NO_SHARED_MEMORY
if ( this->UpdateRects == X11_MITSHMUpdate ) { if ( this->UpdateRects == X11_MITSHMUpdate ) {
XShmPutImage(SDL_Display, SDL_Window, SDL_GC, SDL_Ximage, pXShmPutImage(SDL_Display, SDL_Window, SDL_GC, SDL_Ximage,
0, 0, 0, 0, this->screen->w, this->screen->h, 0, 0, 0, 0, this->screen->w, this->screen->h,
False); False);
} else } else
#endif /* ! NO_SHARED_MEMORY */ #endif /* ! NO_SHARED_MEMORY */
{ {
XPutImage(SDL_Display, SDL_Window, SDL_GC, SDL_Ximage, pXPutImage(SDL_Display, SDL_Window, SDL_GC, SDL_Ximage,
0, 0, 0, 0, this->screen->w, this->screen->h); 0, 0, 0, 0, this->screen->w, this->screen->h);
} }
XSync(SDL_Display, False); pXSync(SDL_Display, False);
} }
...@@ -141,7 +141,7 @@ static void set_best_resolution(_THIS, int width, int height) ...@@ -141,7 +141,7 @@ static void set_best_resolution(_THIS, int width, int height)
(modes[i]->vdisplay != mode.vdisplay) ) { (modes[i]->vdisplay != mode.vdisplay) ) {
SDL_NAME(XF86VidModeSwitchToMode)(SDL_Display, SDL_Screen, modes[i]); SDL_NAME(XF86VidModeSwitchToMode)(SDL_Display, SDL_Screen, modes[i]);
} }
XFree(modes); pXFree(modes);
} }
} }
#endif /* XFREE86_VM */ #endif /* XFREE86_VM */
...@@ -180,7 +180,7 @@ static void set_best_resolution(_THIS, int width, int height) ...@@ -180,7 +180,7 @@ static void set_best_resolution(_THIS, int width, int height)
SDL_modelist[i]->w, SDL_modelist[i]->w,
SDL_modelist[i]->h, SDL_modelist[i]->h,
0); 0);
XSync(SDL_Display, False); pXSync(SDL_Display, False);
} }
} }
} }
...@@ -230,7 +230,7 @@ void X11_WaitMapped(_THIS, Window win) ...@@ -230,7 +230,7 @@ void X11_WaitMapped(_THIS, Window win)
{ {
XEvent event; XEvent event;
do { do {
XMaskEvent(SDL_Display, StructureNotifyMask, &event); pXMaskEvent(SDL_Display, StructureNotifyMask, &event);
} while ( (event.type != MapNotify) || (event.xmap.event != win) ); } while ( (event.type != MapNotify) || (event.xmap.event != win) );
} }
...@@ -239,19 +239,19 @@ void X11_WaitUnmapped(_THIS, Window win) ...@@ -239,19 +239,19 @@ void X11_WaitUnmapped(_THIS, Window win)
{ {
XEvent event; XEvent event;
do { do {
XMaskEvent(SDL_Display, StructureNotifyMask, &event); pXMaskEvent(SDL_Display, StructureNotifyMask, &event);
} while ( (event.type != UnmapNotify) || (event.xunmap.event != win) ); } while ( (event.type != UnmapNotify) || (event.xunmap.event != win) );
} }
static void move_cursor_to(_THIS, int x, int y) static void move_cursor_to(_THIS, int x, int y)
{ {
XWarpPointer(SDL_Display, None, SDL_Root, 0, 0, 0, 0, x, y); pXWarpPointer(SDL_Display, None, SDL_Root, 0, 0, 0, 0, x, y);
} }
static int add_visual(_THIS, int depth, int class) static int add_visual(_THIS, int depth, int class)
{ {
XVisualInfo vi; XVisualInfo vi;
if(XMatchVisualInfo(SDL_Display, SDL_Screen, depth, class, &vi)) { if(pXMatchVisualInfo(SDL_Display, SDL_Screen, depth, class, &vi)) {
int n = this->hidden->nvisuals; int n = this->hidden->nvisuals;
this->hidden->visuals[n].depth = vi.depth; this->hidden->visuals[n].depth = vi.depth;
this->hidden->visuals[n].visual = vi.visual; this->hidden->visuals[n].visual = vi.visual;
...@@ -267,13 +267,13 @@ static int add_visual_byid(_THIS, const char *visual_id) ...@@ -267,13 +267,13 @@ static int add_visual_byid(_THIS, const char *visual_id)
if ( visual_id ) { if ( visual_id ) {
memset(&template, 0, (sizeof template)); memset(&template, 0, (sizeof template));
template.visualid = strtol(visual_id, NULL, 0); template.visualid = strtol(visual_id, NULL, 0);
vi = XGetVisualInfo(SDL_Display, VisualIDMask, &template, &nvis); vi = pXGetVisualInfo(SDL_Display, VisualIDMask, &template, &nvis);
if ( vi ) { if ( vi ) {
int n = this->hidden->nvisuals; int n = this->hidden->nvisuals;
this->hidden->visuals[n].depth = vi->depth; this->hidden->visuals[n].depth = vi->depth;
this->hidden->visuals[n].visual = vi->visual; this->hidden->visuals[n].visual = vi->visual;
this->hidden->nvisuals++; this->hidden->nvisuals++;
XFree(vi); pXFree(vi);
} }
} }
return(this->hidden->nvisuals); return(this->hidden->nvisuals);
...@@ -400,7 +400,7 @@ int X11_GetVideoModes(_THIS) ...@@ -400,7 +400,7 @@ int X11_GetVideoModes(_THIS)
} }
SDL_modelist[n] = NULL; SDL_modelist[n] = NULL;
} }
XFree(modes); pXFree(modes);
use_vidmode = vm_major * 100 + vm_minor; use_vidmode = vm_major * 100 + vm_minor;
save_mode(this); save_mode(this);
...@@ -474,7 +474,7 @@ int X11_GetVideoModes(_THIS) ...@@ -474,7 +474,7 @@ int X11_GetVideoModes(_THIS)
use_xme = 0; use_xme = 0;
} }
if ( modelist ) { if ( modelist ) {
XFree(modelist); pXFree(modelist);
} }
#endif /* HAVE_XIGXME */ #endif /* HAVE_XIGXME */
...@@ -509,7 +509,7 @@ int X11_GetVideoModes(_THIS) ...@@ -509,7 +509,7 @@ int X11_GetVideoModes(_THIS)
} }
/* look up the pixel quantum for each depth */ /* look up the pixel quantum for each depth */
pf = XListPixmapFormats(SDL_Display, &np); pf = pXListPixmapFormats(SDL_Display, &np);
for(i = 0; i < this->hidden->nvisuals; i++) { for(i = 0; i < this->hidden->nvisuals; i++) {
int d = this->hidden->visuals[i].depth; int d = this->hidden->visuals[i].depth;
for(j = 0; j < np; j++) for(j = 0; j < np; j++)
...@@ -518,7 +518,7 @@ int X11_GetVideoModes(_THIS) ...@@ -518,7 +518,7 @@ int X11_GetVideoModes(_THIS)
this->hidden->visuals[i].bpp = j < np ? pf[j].bits_per_pixel : d; this->hidden->visuals[i].bpp = j < np ? pf[j].bits_per_pixel : d;
} }
XFree(pf); pXFree(pf);
} }
if ( SDL_modelist == NULL ) { if ( SDL_modelist == NULL ) {
...@@ -592,7 +592,7 @@ int X11_GetVideoModes(_THIS) ...@@ -592,7 +592,7 @@ int X11_GetVideoModes(_THIS)
xinerama_y = xinerama[i].y_org; xinerama_y = xinerama[i].y_org;
} }
} }
XFree(xinerama); pXFree(xinerama);
} }
#endif /* HAVE_XINERAMA */ #endif /* HAVE_XINERAMA */
...@@ -658,15 +658,15 @@ int X11_ResizeFullScreen(_THIS) ...@@ -658,15 +658,15 @@ int X11_ResizeFullScreen(_THIS)
if ( current_h > real_h ) { if ( current_h > real_h ) {
real_h = MAX(real_h, screen_h); real_h = MAX(real_h, screen_h);
} }
XMoveResizeWindow(SDL_Display, FSwindow, x, y, real_w, real_h); pXMoveResizeWindow(SDL_Display, FSwindow, x, y, real_w, real_h);
move_cursor_to(this, real_w/2, real_h/2); move_cursor_to(this, real_w/2, real_h/2);
/* Center and reparent the drawing window */ /* Center and reparent the drawing window */
x = (real_w - current_w)/2; x = (real_w - current_w)/2;
y = (real_h - current_h)/2; y = (real_h - current_h)/2;
XReparentWindow(SDL_Display, SDL_Window, FSwindow, x, y); pXReparentWindow(SDL_Display, SDL_Window, FSwindow, x, y);
/* FIXME: move the mouse to the old relative location */ /* FIXME: move the mouse to the old relative location */
XSync(SDL_Display, True); /* Flush spurious mode change events */ pXSync(SDL_Display, True); /* Flush spurious mode change events */
} }
return(1); return(1);
} }
...@@ -676,7 +676,7 @@ void X11_QueueEnterFullScreen(_THIS) ...@@ -676,7 +676,7 @@ void X11_QueueEnterFullScreen(_THIS)
switch_waiting = 0x01 | SDL_FULLSCREEN; switch_waiting = 0x01 | SDL_FULLSCREEN;
switch_time = SDL_GetTicks() + 1500; switch_time = SDL_GetTicks() + 1500;
#if 0 /* This causes a BadMatch error if the window is iconified (not needed) */ #if 0 /* This causes a BadMatch error if the window is iconified (not needed) */
XSetInputFocus(SDL_Display, WMwindow, RevertToNone, CurrentTime); pXSetInputFocus(SDL_Display, WMwindow, RevertToNone, CurrentTime);
#endif #endif
} }
...@@ -709,14 +709,14 @@ int X11_EnterFullScreen(_THIS) ...@@ -709,14 +709,14 @@ int X11_EnterFullScreen(_THIS)
if ( current_h > real_h ) { if ( current_h > real_h ) {
real_h = MAX(real_h, screen_h); real_h = MAX(real_h, screen_h);
} }
XMoveResizeWindow(SDL_Display, FSwindow, pXMoveResizeWindow(SDL_Display, FSwindow,
xinerama_x, xinerama_y, real_w, real_h); xinerama_x, xinerama_y, real_w, real_h);
XMapRaised(SDL_Display, FSwindow); pXMapRaised(SDL_Display, FSwindow);
X11_WaitMapped(this, FSwindow); X11_WaitMapped(this, FSwindow);
#if 0 /* This seems to break WindowMaker in focus-follows-mouse mode */ #if 0 /* This seems to break WindowMaker in focus-follows-mouse mode */
/* Make sure we got to the top of the window stack */ /* Make sure we got to the top of the window stack */
if ( XQueryTree(SDL_Display, SDL_Root, &tmpwin, &tmpwin, if ( pXQueryTree(SDL_Display, SDL_Root, &tmpwin, &tmpwin,
&windows, &nwindows) && windows ) { &windows, &nwindows) && windows ) {
/* If not, try to put us there - if fail... oh well */ /* If not, try to put us there - if fail... oh well */
if ( windows[nwindows-1] != FSwindow ) { if ( windows[nwindows-1] != FSwindow ) {
...@@ -729,13 +729,13 @@ int X11_EnterFullScreen(_THIS) ...@@ -729,13 +729,13 @@ int X11_EnterFullScreen(_THIS)
} }
} }
windows[nwindows-1] = FSwindow; windows[nwindows-1] = FSwindow;
XRestackWindows(SDL_Display, windows, nwindows); pXRestackWindows(SDL_Display, windows, nwindows);
XSync(SDL_Display, False); pXSync(SDL_Display, False);
} }
XFree(windows); pXFree(windows);
} }
#else #else
XRaiseWindow(SDL_Display, FSwindow); pXRaiseWindow(SDL_Display, FSwindow);
#endif #endif
#ifdef XFREE86_VM #ifdef XFREE86_VM
...@@ -753,7 +753,7 @@ int X11_EnterFullScreen(_THIS) ...@@ -753,7 +753,7 @@ int X11_EnterFullScreen(_THIS)
} }
/* Set the colormap */ /* Set the colormap */
if ( SDL_XColorMap ) { if ( SDL_XColorMap ) {
XInstallColormap(SDL_Display, SDL_XColorMap); pXInstallColormap(SDL_Display, SDL_XColorMap);
} }
if ( okay ) if ( okay )
X11_GrabInputNoLock(this, this->input_grab | SDL_GRAB_FULLSCREEN); X11_GrabInputNoLock(this, this->input_grab | SDL_GRAB_FULLSCREEN);
...@@ -774,7 +774,7 @@ int X11_EnterFullScreen(_THIS) ...@@ -774,7 +774,7 @@ int X11_EnterFullScreen(_THIS)
int X11_LeaveFullScreen(_THIS) int X11_LeaveFullScreen(_THIS)
{ {
if ( currently_fullscreen ) { if ( currently_fullscreen ) {
XReparentWindow(SDL_Display, SDL_Window, WMwindow, 0, 0); pXReparentWindow(SDL_Display, SDL_Window, WMwindow, 0, 0);
#ifdef XFREE86_VM #ifdef XFREE86_VM
if ( use_vidmode ) { if ( use_vidmode ) {
restore_mode(this); restore_mode(this);
...@@ -796,14 +796,14 @@ int X11_LeaveFullScreen(_THIS) ...@@ -796,14 +796,14 @@ int X11_LeaveFullScreen(_THIS)
saved_res.width, saved_res.width,
saved_res.height, saved_res.height,
0); 0);
XSync(SDL_Display, False); pXSync(SDL_Display, False);
} }
} }
#endif #endif
XUnmapWindow(SDL_Display, FSwindow); pXUnmapWindow(SDL_Display, FSwindow);
X11_WaitUnmapped(this, FSwindow); X11_WaitUnmapped(this, FSwindow);
XSync(SDL_Display, True); /* Flush spurious mode change events */ pXSync(SDL_Display, True); /* Flush spurious mode change events */
currently_fullscreen = 0; currently_fullscreen = 0;
} }
/* If we get popped out of fullscreen mode for some reason, input_grab /* If we get popped out of fullscreen mode for some reason, input_grab
......
...@@ -50,8 +50,8 @@ void X11_FreeWMCursor(_THIS, WMcursor *cursor) ...@@ -50,8 +50,8 @@ void X11_FreeWMCursor(_THIS, WMcursor *cursor)
{ {
if ( SDL_Display != NULL ) { if ( SDL_Display != NULL ) {
SDL_Lock_EventThread(); SDL_Lock_EventThread();
XFreeCursor(SDL_Display, cursor->x_cursor); pXFreeCursor(SDL_Display, cursor->x_cursor);
XSync(SDL_Display, False); pXSync(SDL_Display, False);
SDL_Unlock_EventThread(); SDL_Unlock_EventThread();
} }
free(cursor); free(cursor);
...@@ -105,48 +105,48 @@ WMcursor *X11_CreateWMCursor(_THIS, ...@@ -105,48 +105,48 @@ WMcursor *X11_CreateWMCursor(_THIS,
SDL_Lock_EventThread(); SDL_Lock_EventThread();
/* Create the data image */ /* Create the data image */
data_image = XCreateImage(SDL_Display, data_image = pXCreateImage(SDL_Display,
DefaultVisual(SDL_Display, SDL_Screen), DefaultVisual(SDL_Display, SDL_Screen),
1, XYBitmap, 0, x_data, w, h, 8, w/8); 1, XYBitmap, 0, x_data, w, h, 8, w/8);
data_image->byte_order = MSBFirst; data_image->byte_order = MSBFirst;
data_image->bitmap_bit_order = MSBFirst; data_image->bitmap_bit_order = MSBFirst;
data_pixmap = XCreatePixmap(SDL_Display, SDL_Root, w, h, 1); data_pixmap = pXCreatePixmap(SDL_Display, SDL_Root, w, h, 1);
/* Create the data mask */ /* Create the data mask */
mask_image = XCreateImage(SDL_Display, mask_image = pXCreateImage(SDL_Display,
DefaultVisual(SDL_Display, SDL_Screen), DefaultVisual(SDL_Display, SDL_Screen),
1, XYBitmap, 0, x_mask, w, h, 8, w/8); 1, XYBitmap, 0, x_mask, w, h, 8, w/8);
mask_image->byte_order = MSBFirst; mask_image->byte_order = MSBFirst;
mask_image->bitmap_bit_order = MSBFirst; mask_image->bitmap_bit_order = MSBFirst;
mask_pixmap = XCreatePixmap(SDL_Display, SDL_Root, w, h, 1); mask_pixmap = pXCreatePixmap(SDL_Display, SDL_Root, w, h, 1);
/* Create the graphics context */ /* Create the graphics context */
GCvalues.function = GXcopy; GCvalues.function = GXcopy;
GCvalues.foreground = ~0; GCvalues.foreground = ~0;
GCvalues.background = 0; GCvalues.background = 0;
GCvalues.plane_mask = AllPlanes; GCvalues.plane_mask = AllPlanes;
GCcursor = XCreateGC(SDL_Display, data_pixmap, GCcursor = pXCreateGC(SDL_Display, data_pixmap,
(GCFunction|GCForeground|GCBackground|GCPlaneMask), (GCFunction|GCForeground|GCBackground|GCPlaneMask),
&GCvalues); &GCvalues);
/* Blit the images to the pixmaps */ /* Blit the images to the pixmaps */
XPutImage(SDL_Display, data_pixmap, GCcursor, data_image, pXPutImage(SDL_Display, data_pixmap, GCcursor, data_image,
0, 0, 0, 0, w, h); 0, 0, 0, 0, w, h);
XPutImage(SDL_Display, mask_pixmap, GCcursor, mask_image, pXPutImage(SDL_Display, mask_pixmap, GCcursor, mask_image,
0, 0, 0, 0, w, h); 0, 0, 0, 0, w, h);
XFreeGC(SDL_Display, GCcursor); pXFreeGC(SDL_Display, GCcursor);
/* These free the x_data and x_mask memory pointers */ /* These free the x_data and x_mask memory pointers */
XDestroyImage(data_image); pXDestroyImage(data_image);
XDestroyImage(mask_image); pXDestroyImage(mask_image);
/* Create the cursor */ /* Create the cursor */
cursor->x_cursor = XCreatePixmapCursor(SDL_Display, data_pixmap, cursor->x_cursor = pXCreatePixmapCursor(SDL_Display, data_pixmap,
mask_pixmap, &black, &white, hot_x, hot_y); mask_pixmap, &black, &white, hot_x, hot_y);
XFreePixmap(SDL_Display, data_pixmap); pXFreePixmap(SDL_Display, data_pixmap);
XFreePixmap(SDL_Display, mask_pixmap); pXFreePixmap(SDL_Display, mask_pixmap);
/* Release the event thread */ /* Release the event thread */
XSync(SDL_Display, False); pXSync(SDL_Display, False);
SDL_Unlock_EventThread(); SDL_Unlock_EventThread();
return(cursor); return(cursor);
...@@ -164,13 +164,13 @@ int X11_ShowWMCursor(_THIS, WMcursor *cursor) ...@@ -164,13 +164,13 @@ int X11_ShowWMCursor(_THIS, WMcursor *cursor)
SDL_Lock_EventThread(); SDL_Lock_EventThread();
if ( cursor == NULL ) { if ( cursor == NULL ) {
if ( SDL_BlankCursor != NULL ) { if ( SDL_BlankCursor != NULL ) {
XDefineCursor(SDL_Display, SDL_Window, pXDefineCursor(SDL_Display, SDL_Window,
SDL_BlankCursor->x_cursor); SDL_BlankCursor->x_cursor);
} }
} else { } else {
XDefineCursor(SDL_Display, SDL_Window, cursor->x_cursor); pXDefineCursor(SDL_Display, SDL_Window, cursor->x_cursor);
} }
XSync(SDL_Display, False); pXSync(SDL_Display, False);
SDL_Unlock_EventThread(); SDL_Unlock_EventThread();
} }
return(1); return(1);
...@@ -187,8 +187,8 @@ void X11_WarpWMCursor(_THIS, Uint16 x, Uint16 y) ...@@ -187,8 +187,8 @@ void X11_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
SDL_PrivateMouseMotion(0, 0, x, y); SDL_PrivateMouseMotion(0, 0, x, y);
} else { } else {
SDL_Lock_EventThread(); SDL_Lock_EventThread();
XWarpPointer(SDL_Display, None, SDL_Window, 0, 0, 0, 0, x, y); pXWarpPointer(SDL_Display, None, SDL_Window, 0, 0, 0, 0, x, y);
XSync(SDL_Display, False); pXSync(SDL_Display, False);
SDL_Unlock_EventThread(); SDL_Unlock_EventThread();
} }
} }
...@@ -224,7 +224,7 @@ static void SetMouseAccel(_THIS, const char *accel_param) ...@@ -224,7 +224,7 @@ static void SetMouseAccel(_THIS, const char *accel_param)
} }
} }
if ( mouse_param_buf ) { if ( mouse_param_buf ) {
XChangePointerControl(SDL_Display, True, True, pXChangePointerControl(SDL_Display, True, True,
accel_value[0], accel_value[1], accel_value[2]); accel_value[0], accel_value[1], accel_value[2]);
free(mouse_param_buf); free(mouse_param_buf);
} }
...@@ -257,7 +257,7 @@ void X11_CheckMouseModeNoLock(_THIS) ...@@ -257,7 +257,7 @@ void X11_CheckMouseModeNoLock(_THIS)
SDL_GetMouseState(&mouse_last.x, &mouse_last.y); SDL_GetMouseState(&mouse_last.x, &mouse_last.y);
/* Use as raw mouse mickeys as possible */ /* Use as raw mouse mickeys as possible */
XGetPointerControl(SDL_Display, pXGetPointerControl(SDL_Display,
&mouse_accel.numerator, &mouse_accel.numerator,
&mouse_accel.denominator, &mouse_accel.denominator,
&mouse_accel.threshold); &mouse_accel.threshold);
...@@ -273,7 +273,7 @@ void X11_CheckMouseModeNoLock(_THIS) ...@@ -273,7 +273,7 @@ void X11_CheckMouseModeNoLock(_THIS)
if ( using_dga & DGA_MOUSE ) { if ( using_dga & DGA_MOUSE ) {
X11_DisableDGAMouse(this); X11_DisableDGAMouse(this);
} else { } else {
XChangePointerControl(SDL_Display, True, True, pXChangePointerControl(SDL_Display, True, True,
mouse_accel.numerator, mouse_accel.numerator,
mouse_accel.denominator, mouse_accel.denominator,
mouse_accel.threshold); mouse_accel.threshold);
......
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2004 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
SDL_X11_SYM(XClassHint*,XAllocClassHint,(void))
SDL_X11_SYM(Status,XAllocColor,(Display*,Colormap,XColor*))
SDL_X11_SYM(XSizeHints*,XAllocSizeHints,(void))
SDL_X11_SYM(XWMHints*,XAllocWMHints,(void))
SDL_X11_SYM(int,XChangePointerControl,(Display*,Bool,Bool,int,int,int))
SDL_X11_SYM(int,XChangeProperty,(Display*,Window,Atom,Atom,int,int,_Xconst unsigned char*,int))
SDL_X11_SYM(int,XChangeWindowAttributes,(Display*,Window,unsigned long,XSetWindowAttributes*))
SDL_X11_SYM(Bool,XCheckTypedEvent,(Display*,int,XEvent*))
SDL_X11_SYM(int,XClearWindow,(Display*,Window))
SDL_X11_SYM(int,XCloseDisplay,(Display*))
SDL_X11_SYM(Colormap,XCreateColormap,(Display*,Window,Visual*,int))
SDL_X11_SYM(Cursor,XCreatePixmapCursor,(Display*,Pixmap,Pixmap,XColor*,XColor*,unsigned int,unsigned int))
SDL_X11_SYM(GC,XCreateGC,(Display*,Drawable,unsigned long,XGCValues*))
SDL_X11_SYM(XImage*,XCreateImage,(Display*,Visual*,unsigned int,int,int,char*,unsigned int,unsigned int,int,int))
SDL_X11_SYM(Pixmap,XCreatePixmap,(Display*,Drawable,unsigned int,unsigned int,unsigned int))
SDL_X11_SYM(Pixmap,XCreatePixmapFromBitmapData,(Display*,Drawable,char*,unsigned int,unsigned int,unsigned long,unsigned long,unsigned int))
SDL_X11_SYM(Window,XCreateSimpleWindow,(Display*,Window,int,int,unsigned int,unsigned int,unsigned int,unsigned long,unsigned long))
SDL_X11_SYM(Window,XCreateWindow,(Display*,Window,int,int,unsigned int,unsigned int,unsigned int,int,unsigned int,Visual*,unsigned long,XSetWindowAttributes*))
SDL_X11_SYM(int,XDefineCursor,(Display*,Window,Cursor))
SDL_X11_SYM(int,XDeleteProperty,(Display*,Window,Atom))
SDL_X11_SYM(int,XDestroyWindow,(Display*,Window))
SDL_X11_SYM(char*,XDisplayName,(_Xconst char*))
SDL_X11_SYM(int,XEventsQueued,(Display*,int))
SDL_X11_SYM(int,XFlush,(Display*))
SDL_X11_SYM(int,XFree,(void*))
SDL_X11_SYM(int,XFreeColormap,(Display*,Colormap))
SDL_X11_SYM(int,XFreeColors,(Display*,Colormap,unsigned long*,int,unsigned long))
SDL_X11_SYM(int,XFreeCursor,(Display*,Cursor))
SDL_X11_SYM(int,XFreeGC,(Display*,GC))
SDL_X11_SYM(int,XFreeModifiermap,(XModifierKeymap*))
SDL_X11_SYM(int,XFreePixmap,(Display*,Pixmap))
SDL_X11_SYM(int,XGetErrorDatabaseText,(Display*,_Xconst char*,_Xconst char*,_Xconst char*,char*,int))
SDL_X11_SYM(XModifierKeymap*,XGetModifierMapping,(Display*))
SDL_X11_SYM(int,XGetPointerControl,(Display*,int*,int*,int*))
SDL_X11_SYM(XVisualInfo*,XGetVisualInfo,(Display*,long,XVisualInfo*,int*))
SDL_X11_SYM(XWMHints*,XGetWMHints,(Display*,Window))
SDL_X11_SYM(Status,XGetWMIconName,(Display*,Window,XTextProperty*))
SDL_X11_SYM(Status,XGetWMName,(Display*,Window,XTextProperty*))
SDL_X11_SYM(Status,XGetWindowAttributes,(Display*,Window,XWindowAttributes*))
SDL_X11_SYM(int,XGrabKeyboard,(Display*,Window,Bool,int,int,Time))
SDL_X11_SYM(int,XGrabPointer,(Display*,Window,Bool,unsigned int,int,int,Window,Cursor,Time))
SDL_X11_SYM(Status,XIconifyWindow,(Display*,Window,int))
SDL_X11_SYM(int,XInstallColormap,(Display*,Colormap))
SDL_X11_SYM(KeyCode,XKeysymToKeycode,(Display*,KeySym))
SDL_X11_SYM(Atom,XInternAtom,(Display*,_Xconst char*,Bool))
SDL_X11_SYM(XPixmapFormatValues*,XListPixmapFormats,(Display*,int*))
SDL_X11_SYM(int,XLookupString,(XKeyEvent*,char*,int,KeySym*,XComposeStatus*))
SDL_X11_SYM(int,XMapRaised,(Display*,Window))
SDL_X11_SYM(int,XMapWindow,(Display*,Window))
SDL_X11_SYM(int,XMaskEvent,(Display*,long,XEvent*))
SDL_X11_SYM(Status,XMatchVisualInfo,(Display*,int,int,int,XVisualInfo*))
SDL_X11_SYM(int,XMissingExtension,(Display*,_Xconst char*))
SDL_X11_SYM(int,XMoveResizeWindow,(Display*,Window,int,int,unsigned int,unsigned int))
SDL_X11_SYM(int,XMoveWindow,(Display*,Window,int,int))
SDL_X11_SYM(int,XNextEvent,(Display*,XEvent*))
SDL_X11_SYM(Display*,XOpenDisplay,(_Xconst char*))
SDL_X11_SYM(int,XPeekEvent,(Display*,XEvent*))
SDL_X11_SYM(int,XPending,(Display*))
SDL_X11_SYM(int,XPutImage,(Display*,Drawable,GC,XImage*,int,int,int,int,unsigned int,unsigned int))
SDL_X11_SYM(int,XQueryColors,(Display*,Colormap,XColor*,int))
SDL_X11_SYM(int,XQueryKeymap,(Display*,char [32]))
SDL_X11_SYM(Bool,XQueryPointer,(Display*,Window,Window*,Window*,int*,int*,int*,int*,unsigned int*))
SDL_X11_SYM(int,XRaiseWindow,(Display*,Window))
SDL_X11_SYM(int,XReparentWindow,(Display*,Window,Window,int,int))
SDL_X11_SYM(int,XResizeWindow,(Display*,Window,unsigned int,unsigned int))
SDL_X11_SYM(int,XSelectInput,(Display*,Window,long))
SDL_X11_SYM(Status,XSendEvent,(Display*,Window,Bool,long,XEvent*))
SDL_X11_SYM(int,XSetClassHint,(Display*,Window,XClassHint*))
SDL_X11_SYM(XErrorHandler,XSetErrorHandler,(XErrorHandler))
SDL_X11_SYM(XIOErrorHandler,XSetIOErrorHandler,(XIOErrorHandler))
SDL_X11_SYM(int,XSetTransientForHint,(Display*,Window,Window))
SDL_X11_SYM(int,XSetWMHints,(Display*,Window,XWMHints*))
SDL_X11_SYM(void,XSetWMIconName,(Display*,Window,XTextProperty*))
SDL_X11_SYM(void,XSetWMName,(Display*,Window,XTextProperty*))
SDL_X11_SYM(void,XSetWMNormalHints,(Display*,Window,XSizeHints*))
SDL_X11_SYM(Status,XSetWMProtocols,(Display*,Window,Atom*,int))
SDL_X11_SYM(int,XSetWindowBackground,(Display*,Window,unsigned long))
SDL_X11_SYM(int,XSetWindowBackgroundPixmap,(Display*,Window,Pixmap))
SDL_X11_SYM(int,XSetWindowColormap,(Display*,Window,Colormap))
SDL_X11_SYM(int,XStoreColors,(Display*,Colormap,XColor*,int))
SDL_X11_SYM(Status,XStringListToTextProperty,(char**,int,XTextProperty*))
SDL_X11_SYM(int,XSync,(Display*,Bool))
SDL_X11_SYM(int,XUngrabKeyboard,(Display*,Time))
SDL_X11_SYM(int,XUngrabPointer,(Display*,Time))
SDL_X11_SYM(int,XUnmapWindow,(Display*,Window))
SDL_X11_SYM(int,XWarpPointer,(Display*,Window,Window,int,int,unsigned int,unsigned int,int,int))
SDL_X11_SYM(VisualID,XVisualIDFromVisual,(Visual*))
SDL_X11_SYM(XExtDisplayInfo*,XextAddDisplay,(XExtensionInfo*,Display*,char*,XExtensionHooks*,int,XPointer))
SDL_X11_SYM(XExtensionInfo*,XextCreateExtension,(void))
SDL_X11_SYM(void,XextDestroyExtension,(XExtensionInfo*))
SDL_X11_SYM(XExtDisplayInfo*,XextFindDisplay,(XExtensionInfo*,Display*))
SDL_X11_SYM(int,XextRemoveDisplay,(XExtensionInfo*,Display*))
SDL_X11_SYM(int,Xutf8TextListToTextProperty,(Display*,char**,int,XICCEncodingStyle,XTextProperty*))
SDL_X11_SYM(void,_XEatData,(Display*,unsigned long))
SDL_X11_SYM(void,_XFlush,(Display*))
SDL_X11_SYM(void,_XFlushGCCache,(Display*,GC))
SDL_X11_SYM(int,_XRead,(Display*,char*,long))
SDL_X11_SYM(void,_XReadPad,(Display*,char*,long))
SDL_X11_SYM(void,_XSend,(Display*,_Xconst char*,long))
SDL_X11_SYM(Status,_XReply,(Display*,xReply*,int,Bool))
SDL_X11_SYM(unsigned long,_XSetLastRequestRead,(Display*,xGenericReply*))
#if NeedWidePrototypes
SDL_X11_SYM(KeySym,XKeycodeToKeysym,(Display*,unsigned int,int))
#else
SDL_X11_SYM(KeySym,XKeycodeToKeysym,(Display*,KeyCode,int))
#endif
#ifndef NO_SHARED_MEMORY
SDL_X11_SYM(Status,XShmAttach,(Display*,XShmSegmentInfo*))
SDL_X11_SYM(Status,XShmDetach,(Display*,XShmSegmentInfo*))
SDL_X11_SYM(Status,XShmPutImage,(Display*,Drawable,GC,XImage*,int,int,int,int,unsigned int,unsigned int,Bool))
SDL_X11_SYM(XImage*,XShmCreateImage,(Display*,Visual*,unsigned int,int,char*,XShmSegmentInfo*,unsigned int,unsigned int))
SDL_X11_SYM(Bool,XShmQueryExtension,(Display*))
#endif
SDL_X11_SYM(SDL_X11_XSynchronizeRetType,XSynchronize,(Display*,Bool))
SDL_X11_SYM(SDL_X11_XESetWireToEventRetType,XESetWireToEvent,(Display*,int,SDL_X11_XESetWireToEventRetType))
SDL_X11_SYM(SDL_X11_XESetEventToWireRetType,XESetEventToWire,(Display*,int,SDL_X11_XESetEventToWireRetType))
/* end of SDL_x11sym.h ... */
This diff is collapsed.
...@@ -31,11 +31,7 @@ static char rcsid = ...@@ -31,11 +31,7 @@ static char rcsid =
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>
#include <X11/Xatom.h> #include <X11/Xatom.h>
#ifndef NO_SHARED_MEMORY
#include <sys/ipc.h>
#include <sys/shm.h>
#include <X11/extensions/XShm.h>
#endif
#ifdef XFREE86_DGAMOUSE #ifdef XFREE86_DGAMOUSE
#include <XFree86/extensions/xf86dga.h> #include <XFree86/extensions/xf86dga.h>
#endif #endif
...@@ -50,6 +46,7 @@ static char rcsid = ...@@ -50,6 +46,7 @@ static char rcsid =
#include "SDL_mouse.h" #include "SDL_mouse.h"
#include "SDL_sysvideo.h" #include "SDL_sysvideo.h"
#include "SDL_x11dyn.h"
/* Hidden "this" pointer for the video functions */ /* Hidden "this" pointer for the video functions */
#define _THIS SDL_VideoDevice *this #define _THIS SDL_VideoDevice *this
......
...@@ -123,7 +123,7 @@ void X11_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask) ...@@ -123,7 +123,7 @@ void X11_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask)
SDL_iconcolors[i]--; SDL_iconcolors[i]--;
} }
} }
XFreeColors(GFX_Display, dcmap, freelist, nfree, 0); pXFreeColors(GFX_Display, dcmap, freelist, nfree, 0);
} }
if(!SDL_iconcolors) if(!SDL_iconcolors)
SDL_iconcolors = malloc(256 * sizeof *SDL_iconcolors); SDL_iconcolors = malloc(256 * sizeof *SDL_iconcolors);
...@@ -138,7 +138,7 @@ void X11_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask) ...@@ -138,7 +138,7 @@ void X11_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask)
c.green = want[i].g << 8; c.green = want[i].g << 8;
c.blue = want[i].b << 8; c.blue = want[i].b << 8;
c.flags = DoRed | DoGreen | DoBlue; c.flags = DoRed | DoGreen | DoBlue;
if(XAllocColor(GFX_Display, dcmap, &c)) { if(pXAllocColor(GFX_Display, dcmap, &c)) {
/* got the colour */ /* got the colour */
SDL_iconcolors[c.pixel]++; SDL_iconcolors[c.pixel]++;
got[c.pixel] = want[i]; got[c.pixel] = want[i];
...@@ -152,13 +152,13 @@ void X11_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask) ...@@ -152,13 +152,13 @@ void X11_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask)
XColor cols[256]; XColor cols[256];
for(i = 0; i < 256; i++) for(i = 0; i < 256; i++)
cols[i].pixel = i; cols[i].pixel = i;
XQueryColors(GFX_Display, dcmap, cols, 256); pXQueryColors(GFX_Display, dcmap, cols, 256);
for(i = 0; i < 256; i++) { for(i = 0; i < 256; i++) {
got[i].r = cols[i].red >> 8; got[i].r = cols[i].red >> 8;
got[i].g = cols[i].green >> 8; got[i].g = cols[i].green >> 8;
got[i].b = cols[i].blue >> 8; got[i].b = cols[i].blue >> 8;
if(!SDL_iconcolors[i]) { if(!SDL_iconcolors[i]) {
if(XAllocColor(GFX_Display, dcmap, if(pXAllocColor(GFX_Display, dcmap,
cols + i)) { cols + i)) {
SDL_iconcolors[i] = 1; SDL_iconcolors[i] = 1;
} else { } else {
...@@ -191,13 +191,13 @@ void X11_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask) ...@@ -191,13 +191,13 @@ void X11_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask)
memset(LSBmask, 0, masksize); memset(LSBmask, 0, masksize);
for(i = 0; i < masksize; i++) for(i = 0; i < masksize; i++)
LSBmask[i] = reverse_byte(mask[i]); LSBmask[i] = reverse_byte(mask[i]);
mask_pixmap = XCreatePixmapFromBitmapData(SDL_Display, WMwindow, mask_pixmap = pXCreatePixmapFromBitmapData(SDL_Display, WMwindow,
(char *)LSBmask, (char *)LSBmask,
sicon->w, sicon->h, sicon->w, sicon->h,
1L, 0L, 1); 1L, 0L, 1);
/* Transfer the image to an X11 pixmap */ /* Transfer the image to an X11 pixmap */
icon_image = XCreateImage(SDL_Display, icon_image = pXCreateImage(SDL_Display,
DefaultVisual(SDL_Display, SDL_Screen), DefaultVisual(SDL_Display, SDL_Screen),
DefaultDepth(SDL_Display, SDL_Screen), DefaultDepth(SDL_Display, SDL_Screen),
ZPixmap, 0, sicon->pixels, ZPixmap, 0, sicon->pixels,
...@@ -205,13 +205,13 @@ void X11_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask) ...@@ -205,13 +205,13 @@ void X11_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask)
32, 0); 32, 0);
icon_image->byte_order = (SDL_BYTEORDER == SDL_BIG_ENDIAN) icon_image->byte_order = (SDL_BYTEORDER == SDL_BIG_ENDIAN)
? MSBFirst : LSBFirst; ? MSBFirst : LSBFirst;
icon_pixmap = XCreatePixmap(SDL_Display, SDL_Root, sicon->w, sicon->h, icon_pixmap = pXCreatePixmap(SDL_Display, SDL_Root, sicon->w, sicon->h,
DefaultDepth(SDL_Display, SDL_Screen)); DefaultDepth(SDL_Display, SDL_Screen));
gc = XCreateGC(SDL_Display, icon_pixmap, 0, &GCvalues); gc = pXCreateGC(SDL_Display, icon_pixmap, 0, &GCvalues);
XPutImage(SDL_Display, icon_pixmap, gc, icon_image, pXPutImage(SDL_Display, icon_pixmap, gc, icon_image,
0, 0, 0, 0, sicon->w, sicon->h); 0, 0, 0, 0, sicon->w, sicon->h);
XFreeGC(SDL_Display, gc); pXFreeGC(SDL_Display, gc);
XDestroyImage(icon_image); pXDestroyImage(icon_image);
free(LSBmask); free(LSBmask);
sicon->pixels = NULL; sicon->pixels = NULL;
...@@ -220,17 +220,17 @@ void X11_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask) ...@@ -220,17 +220,17 @@ void X11_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask)
it screws up others. The default is only to use a pixmap. */ it screws up others. The default is only to use a pixmap. */
p = getenv("SDL_VIDEO_X11_ICONWIN"); p = getenv("SDL_VIDEO_X11_ICONWIN");
if(p && *p) { if(p && *p) {
icon_window = XCreateSimpleWindow(SDL_Display, SDL_Root, icon_window = pXCreateSimpleWindow(SDL_Display, SDL_Root,
0, 0, sicon->w, sicon->h, 0, 0, 0, sicon->w, sicon->h, 0,
CopyFromParent, CopyFromParent,
CopyFromParent); CopyFromParent);
XSetWindowBackgroundPixmap(SDL_Display, icon_window, pXSetWindowBackgroundPixmap(SDL_Display, icon_window,
icon_pixmap); icon_pixmap);
XClearWindow(SDL_Display, icon_window); pXClearWindow(SDL_Display, icon_window);
} }
/* Set the window icon to the icon pixmap (and icon window) */ /* Set the window icon to the icon pixmap (and icon window) */
wmhints = XAllocWMHints(); wmhints = pXAllocWMHints();
wmhints->flags = (IconPixmapHint | IconMaskHint); wmhints->flags = (IconPixmapHint | IconMaskHint);
wmhints->icon_pixmap = icon_pixmap; wmhints->icon_pixmap = icon_pixmap;
wmhints->icon_mask = mask_pixmap; wmhints->icon_mask = mask_pixmap;
...@@ -238,9 +238,9 @@ void X11_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask) ...@@ -238,9 +238,9 @@ void X11_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask)
wmhints->flags |= IconWindowHint; wmhints->flags |= IconWindowHint;
wmhints->icon_window = icon_window; wmhints->icon_window = icon_window;
} }
XSetWMHints(SDL_Display, WMwindow, wmhints); pXSetWMHints(SDL_Display, WMwindow, wmhints);
XFree(wmhints); pXFree(wmhints);
XSync(SDL_Display, False); pXSync(SDL_Display, False);
done: done:
SDL_Unlock_EventThread(); SDL_Unlock_EventThread();
...@@ -257,30 +257,30 @@ void X11_SetCaption(_THIS, const char *title, const char *icon) ...@@ -257,30 +257,30 @@ void X11_SetCaption(_THIS, const char *title, const char *icon)
if ( title != NULL ) { if ( title != NULL ) {
int error = XLocaleNotSupported; int error = XLocaleNotSupported;
#ifdef X_HAVE_UTF8_STRING #ifdef X_HAVE_UTF8_STRING
error = Xutf8TextListToTextProperty(SDL_Display, error = pXutf8TextListToTextProperty(SDL_Display,
(char **)&title, 1, XUTF8StringStyle, (char **)&title, 1, XUTF8StringStyle,
&titleprop); &titleprop);
#endif #endif
if ( error != Success ) { if ( error != Success ) {
XStringListToTextProperty((char **)&title, 1, pXStringListToTextProperty((char **)&title, 1,
&titleprop); &titleprop);
} }
XSetWMName(SDL_Display, WMwindow, &titleprop); pXSetWMName(SDL_Display, WMwindow, &titleprop);
XFree(titleprop.value); pXFree(titleprop.value);
} }
if ( icon != NULL ) { if ( icon != NULL ) {
int error = XLocaleNotSupported; int error = XLocaleNotSupported;
#ifdef X_HAVE_UTF8_STRING #ifdef X_HAVE_UTF8_STRING
error = Xutf8TextListToTextProperty(SDL_Display, error = pXutf8TextListToTextProperty(SDL_Display,
(char **)&icon, 1, XUTF8StringStyle, &iconprop); (char **)&icon, 1, XUTF8StringStyle, &iconprop);
#endif #endif
if ( error != Success ) { if ( error != Success ) {
XStringListToTextProperty((char **)&icon, 1, &iconprop); pXStringListToTextProperty((char **)&icon, 1, &iconprop);
} }
XSetWMIconName(SDL_Display, WMwindow, &iconprop); pXSetWMIconName(SDL_Display, WMwindow, &iconprop);
XFree(iconprop.value); pXFree(iconprop.value);
} }
XSync(SDL_Display, False); pXSync(SDL_Display, False);
SDL_Unlock_EventThread(); SDL_Unlock_EventThread();
} }
...@@ -291,8 +291,8 @@ int X11_IconifyWindow(_THIS) ...@@ -291,8 +291,8 @@ int X11_IconifyWindow(_THIS)
int result; int result;
SDL_Lock_EventThread(); SDL_Lock_EventThread();
result = XIconifyWindow(SDL_Display, WMwindow, SDL_Screen); result = pXIconifyWindow(SDL_Display, WMwindow, SDL_Screen);
XSync(SDL_Display, False); pXSync(SDL_Display, False);
SDL_Unlock_EventThread(); SDL_Unlock_EventThread();
return(result); return(result);
} }
...@@ -308,12 +308,12 @@ SDL_GrabMode X11_GrabInputNoLock(_THIS, SDL_GrabMode mode) ...@@ -308,12 +308,12 @@ SDL_GrabMode X11_GrabInputNoLock(_THIS, SDL_GrabMode mode)
return(mode); /* Will be set later on mode switch */ return(mode); /* Will be set later on mode switch */
} }
if ( mode == SDL_GRAB_OFF ) { if ( mode == SDL_GRAB_OFF ) {
XUngrabPointer(SDL_Display, CurrentTime); pXUngrabPointer(SDL_Display, CurrentTime);
XUngrabKeyboard(SDL_Display, CurrentTime); pXUngrabKeyboard(SDL_Display, CurrentTime);
} else { } else {
if ( this->screen->flags & SDL_FULLSCREEN ) { if ( this->screen->flags & SDL_FULLSCREEN ) {
/* Unbind the mouse from the fullscreen window */ /* Unbind the mouse from the fullscreen window */
XUngrabPointer(SDL_Display, CurrentTime); pXUngrabPointer(SDL_Display, CurrentTime);
} }
/* Try to grab the mouse */ /* Try to grab the mouse */
#if 0 /* We'll wait here until we actually grab, otherwise behavior undefined */ #if 0 /* We'll wait here until we actually grab, otherwise behavior undefined */
...@@ -321,7 +321,7 @@ SDL_GrabMode X11_GrabInputNoLock(_THIS, SDL_GrabMode mode) ...@@ -321,7 +321,7 @@ SDL_GrabMode X11_GrabInputNoLock(_THIS, SDL_GrabMode mode)
#else #else
while ( 1 ) { while ( 1 ) {
#endif #endif
result = XGrabPointer(SDL_Display, SDL_Window, True, 0, result = pXGrabPointer(SDL_Display, SDL_Window, True, 0,
GrabModeAsync, GrabModeAsync, GrabModeAsync, GrabModeAsync,
SDL_Window, None, CurrentTime); SDL_Window, None, CurrentTime);
if ( result == GrabSuccess ) { if ( result == GrabSuccess ) {
...@@ -333,17 +333,17 @@ SDL_GrabMode X11_GrabInputNoLock(_THIS, SDL_GrabMode mode) ...@@ -333,17 +333,17 @@ SDL_GrabMode X11_GrabInputNoLock(_THIS, SDL_GrabMode mode)
/* Uh, oh, what do we do here? */ ; /* Uh, oh, what do we do here? */ ;
} }
/* Now grab the keyboard */ /* Now grab the keyboard */
XGrabKeyboard(SDL_Display, WMwindow, True, pXGrabKeyboard(SDL_Display, WMwindow, True,
GrabModeAsync, GrabModeAsync, CurrentTime); GrabModeAsync, GrabModeAsync, CurrentTime);
/* Raise the window if we grab the mouse */ /* Raise the window if we grab the mouse */
if ( !(this->screen->flags & SDL_FULLSCREEN) ) if ( !(this->screen->flags & SDL_FULLSCREEN) )
XRaiseWindow(SDL_Display, WMwindow); pXRaiseWindow(SDL_Display, WMwindow);
/* Make sure we register input focus */ /* Make sure we register input focus */
SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS); SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS);
} }
XSync(SDL_Display, False); pXSync(SDL_Display, False);
return(mode); return(mode);
} }
...@@ -368,7 +368,7 @@ static void unlock_display(void) ...@@ -368,7 +368,7 @@ static void unlock_display(void)
{ {
/* Make sure any X11 transactions are completed */ /* Make sure any X11 transactions are completed */
SDL_VideoDevice *this = current_video; SDL_VideoDevice *this = current_video;
XSync(SDL_Display, False); pXSync(SDL_Display, False);
SDL_Unlock_EventThread(); SDL_Unlock_EventThread();
} }
int X11_GetWMInfo(_THIS, SDL_SysWMinfo *info) int X11_GetWMInfo(_THIS, SDL_SysWMinfo *info)
......
...@@ -159,7 +159,7 @@ SDL_Overlay *X11_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, S ...@@ -159,7 +159,7 @@ SDL_Overlay *X11_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, S
} }
} }
if ( formats ) { if ( formats ) {
XFree(formats); pXFree(formats);
} }
} }
} }
...@@ -208,21 +208,21 @@ SDL_Overlay *X11_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, S ...@@ -208,21 +208,21 @@ SDL_Overlay *X11_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, S
unsigned int i; unsigned int i;
SDL_NAME(XvSelectPortNotify)(GFX_Display, xv_port, True); SDL_NAME(XvSelectPortNotify)(GFX_Display, xv_port, True);
X_handler = XSetErrorHandler(xv_errhandler); X_handler = pXSetErrorHandler(xv_errhandler);
for ( i=0; i < sizeof(attr)/(sizeof attr[0]); ++i ) { for ( i=0; i < sizeof(attr)/(sizeof attr[0]); ++i ) {
Atom a; Atom a;
xv_error = False; xv_error = False;
a = XInternAtom(GFX_Display, attr[i], True); a = pXInternAtom(GFX_Display, attr[i], True);
if ( a != None ) { if ( a != None ) {
SDL_NAME(XvSetPortAttribute)(GFX_Display, xv_port, a, 1); SDL_NAME(XvSetPortAttribute)(GFX_Display, xv_port, a, 1);
XSync(GFX_Display, True); pXSync(GFX_Display, True);
if ( ! xv_error ) { if ( ! xv_error ) {
break; break;
} }
} }
} }
XSetErrorHandler(X_handler); pXSetErrorHandler(X_handler);
SDL_NAME(XvSelectPortNotify)(GFX_Display, xv_port, False); SDL_NAME(XvSelectPortNotify)(GFX_Display, xv_port, False);
} }
...@@ -262,7 +262,7 @@ SDL_Overlay *X11_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, S ...@@ -262,7 +262,7 @@ SDL_Overlay *X11_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, S
#ifdef PITCH_WORKAROUND #ifdef PITCH_WORKAROUND
if ( hwdata->image != NULL && hwdata->image->pitches[0] != (width*bpp) ) { if ( hwdata->image != NULL && hwdata->image->pitches[0] != (width*bpp) ) {
/* Ajust overlay width according to pitch */ /* Ajust overlay width according to pitch */
XFree(hwdata->image); pXFree(hwdata->image);
width = hwdata->image->pitches[0] / bpp; width = hwdata->image->pitches[0] / bpp;
hwdata->image = SDL_NAME(XvShmCreateImage)(GFX_Display, xv_port, format, hwdata->image = SDL_NAME(XvShmCreateImage)(GFX_Display, xv_port, format,
0, width, height, yuvshm); 0, width, height, yuvshm);
...@@ -277,10 +277,10 @@ SDL_Overlay *X11_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, S ...@@ -277,10 +277,10 @@ SDL_Overlay *X11_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, S
yuvshm->readOnly = False; yuvshm->readOnly = False;
if ( yuvshm->shmaddr != (char *)-1 ) { if ( yuvshm->shmaddr != (char *)-1 ) {
shm_error = False; shm_error = False;
X_handler = XSetErrorHandler(shm_errhandler); X_handler = pXSetErrorHandler(shm_errhandler);
XShmAttach(GFX_Display, yuvshm); pXShmAttach(GFX_Display, yuvshm);
XSync(GFX_Display, True); pXSync(GFX_Display, True);
XSetErrorHandler(X_handler); pXSetErrorHandler(X_handler);
if ( shm_error ) if ( shm_error )
shmdt(yuvshm->shmaddr); shmdt(yuvshm->shmaddr);
} else { } else {
...@@ -291,7 +291,7 @@ SDL_Overlay *X11_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, S ...@@ -291,7 +291,7 @@ SDL_Overlay *X11_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, S
shm_error = True; shm_error = True;
} }
if ( shm_error ) { if ( shm_error ) {
XFree(hwdata->image); pXFree(hwdata->image);
hwdata->yuv_use_mitshm = 0; hwdata->yuv_use_mitshm = 0;
} else { } else {
hwdata->image->data = yuvshm->shmaddr; hwdata->image->data = yuvshm->shmaddr;
...@@ -306,7 +306,7 @@ SDL_Overlay *X11_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, S ...@@ -306,7 +306,7 @@ SDL_Overlay *X11_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, S
#ifdef PITCH_WORKAROUND #ifdef PITCH_WORKAROUND
if ( hwdata->image != NULL && hwdata->image->pitches[0] != (width*bpp) ) { if ( hwdata->image != NULL && hwdata->image->pitches[0] != (width*bpp) ) {
/* Ajust overlay width according to pitch */ /* Ajust overlay width according to pitch */
XFree(hwdata->image); pXFree(hwdata->image);
width = hwdata->image->pitches[0] / bpp; width = hwdata->image->pitches[0] / bpp;
hwdata->image = SDL_NAME(XvCreateImage)(GFX_Display, xv_port, format, hwdata->image = SDL_NAME(XvCreateImage)(GFX_Display, xv_port, format,
0, width, height); 0, width, height);
...@@ -380,7 +380,7 @@ int X11_DisplayYUVOverlay(_THIS, SDL_Overlay *overlay, SDL_Rect *dstrect) ...@@ -380,7 +380,7 @@ int X11_DisplayYUVOverlay(_THIS, SDL_Overlay *overlay, SDL_Rect *dstrect)
hwdata->image, 0, 0, overlay->w, overlay->h, hwdata->image, 0, 0, overlay->w, overlay->h,
dstrect->x, dstrect->y, dstrect->w, dstrect->h); dstrect->x, dstrect->y, dstrect->w, dstrect->h);
} }
XSync(GFX_Display, False); pXSync(GFX_Display, False);
return(0); return(0);
} }
...@@ -393,12 +393,12 @@ void X11_FreeYUVOverlay(_THIS, SDL_Overlay *overlay) ...@@ -393,12 +393,12 @@ void X11_FreeYUVOverlay(_THIS, SDL_Overlay *overlay)
SDL_NAME(XvUngrabPort)(GFX_Display, hwdata->port, CurrentTime); SDL_NAME(XvUngrabPort)(GFX_Display, hwdata->port, CurrentTime);
#ifndef NO_SHARED_MEMORY #ifndef NO_SHARED_MEMORY
if ( hwdata->yuv_use_mitshm ) { if ( hwdata->yuv_use_mitshm ) {
XShmDetach(GFX_Display, &hwdata->yuvshm); pXShmDetach(GFX_Display, &hwdata->yuvshm);
shmdt(hwdata->yuvshm.shmaddr); shmdt(hwdata->yuvshm.shmaddr);
} }
#endif #endif
if ( hwdata->image ) { if ( hwdata->image ) {
XFree(hwdata->image); pXFree(hwdata->image);
} }
free(hwdata); free(hwdata);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment