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()
AC_PATH_X
AC_PATH_XTRA
if test x$have_x = xyes; then
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
CFLAGS="$CFLAGS -DNO_SHARED_MEMORY"
fi
SYSTEM_LIBS="$SYSTEM_LIBS $X_LIBS -lX11 -lXext"
VIDEO_SUBDIRS="$VIDEO_SUBDIRS x11"
VIDEO_DRIVERS="$VIDEO_DRIVERS x11/libvideo_x11.la"
......
......@@ -35,6 +35,13 @@ Equipment Corporation.
#include "panoramiXproto.h" /* in ../include */
#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 = &_panoramiX_ext_info_data;
......@@ -111,7 +118,7 @@ Status SDL_NAME(XPanoramiXQueryVersion)(
req->panoramiXReqType = X_PanoramiXQueryVersion;
req->clientMajor = PANORAMIX_MAJOR_VERSION;
req->clientMinor = PANORAMIX_MINOR_VERSION;
if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
if (!p_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
UnlockDisplay (dpy);
SyncHandle ();
return 0;
......@@ -145,7 +152,7 @@ Status SDL_NAME(XPanoramiXGetState) (
req->reqType = info->codes->major_opcode;
req->panoramiXReqType = X_PanoramiXGetState;
req->window = drawable;
if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
if (!p_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
UnlockDisplay (dpy);
SyncHandle ();
return 0;
......@@ -174,7 +181,7 @@ Status SDL_NAME(XPanoramiXGetScreenCount) (
req->reqType = info->codes->major_opcode;
req->panoramiXReqType = X_PanoramiXGetScreenCount;
req->window = drawable;
if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
if (!p_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
UnlockDisplay (dpy);
SyncHandle ();
return 0;
......@@ -205,7 +212,7 @@ Status SDL_NAME(XPanoramiXGetScreenSize) (
req->panoramiXReqType = X_PanoramiXGetScreenSize;
req->window = drawable;
req->screen = screen_num; /* need to define */
if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
if (!p_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
UnlockDisplay (dpy);
SyncHandle ();
return 0;
......@@ -285,7 +292,7 @@ SDL_NAME(XineramaQueryScreens)(
GetReq (XineramaQueryScreens, req);
req->reqType = info->codes->major_opcode;
req->panoramiXReqType = X_XineramaQueryScreens;
if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) {
if (!p_XReply (dpy, (xReply *) &rep, 0, xFalse)) {
UnlockDisplay (dpy);
SyncHandle ();
return NULL;
......@@ -297,7 +304,7 @@ SDL_NAME(XineramaQueryScreens)(
int 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].x_org = scratch.x_org;
scrnInfo[i].y_org = scratch.y_org;
......@@ -307,7 +314,7 @@ SDL_NAME(XineramaQueryScreens)(
*number = rep.number;
} else
_XEatData(dpy, rep.length << 2);
p_XEatData(dpy, rep.length << 2);
}
UnlockDisplay (dpy);
......
......@@ -56,6 +56,14 @@ SOFTWARE.
#include <X11/extensions/XShm.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 = &_xv_info_data;
static char *xv_extension_name = XvName;
......@@ -121,7 +129,7 @@ SDL_NAME(XvQueryExtension)(
XvGetReq(QueryExtension, req);
if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
if (!p_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
UnlockDisplay(dpy);
SyncHandle();
return XvBadExtension;
......@@ -171,7 +179,7 @@ SDL_NAME(XvQueryAdaptors)(
/* READ THE REPLY */
if (_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) {
if (p_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) {
UnlockDisplay(dpy);
SyncHandle();
return(XvBadReply);
......@@ -183,7 +191,7 @@ SDL_NAME(XvQueryAdaptors)(
SyncHandle();
return(XvBadAlloc);
}
_XRead (dpy, buffer, size);
p_XRead (dpy, buffer, size);
u.buffer = buffer;
......@@ -331,7 +339,7 @@ SDL_NAME(XvQueryEncodings)(
/* READ THE REPLY */
if (_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) {
if (p_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) {
UnlockDisplay(dpy);
SyncHandle();
return(XvBadReply);
......@@ -343,7 +351,7 @@ SDL_NAME(XvQueryEncodings)(
SyncHandle();
return(XvBadAlloc);
}
_XRead (dpy, buffer, size);
p_XRead (dpy, buffer, size);
u.buffer = buffer;
......@@ -619,7 +627,7 @@ SDL_NAME(XvGrabPort)(
req->port = port;
req->time = time;
if (_XReply (dpy, (xReply *) &rep, 0, xTrue) == 0)
if (p_XReply (dpy, (xReply *) &rep, 0, xTrue) == 0)
rep.result = GrabSuccess;
result = rep.result;
......@@ -747,7 +755,7 @@ SDL_NAME(XvGetPortAttribute) (
/* READ THE REPLY */
if (_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) {
if (p_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) {
UnlockDisplay(dpy);
SyncHandle();
return(XvBadReply);
......@@ -792,7 +800,7 @@ SDL_NAME(XvQueryBestSize)(
/* READ THE REPLY */
if (_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) {
if (p_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) {
UnlockDisplay(dpy);
SyncHandle();
return(XvBadReply);
......@@ -827,7 +835,7 @@ SDL_NAME(XvQueryPortAttributes)(Display *dpy, XvPortID port, int *num)
/* READ THE REPLY */
if (_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) {
if (p_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) {
UnlockDisplay(dpy);
SyncHandle();
return ret;
......@@ -842,17 +850,17 @@ SDL_NAME(XvQueryPortAttributes)(Display *dpy, XvPortID port, int *num)
int 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].min_value = Info.min;
ret[i].max_value = Info.max;
ret[i].name = marker;
_XRead(dpy, marker, Info.size);
p_XRead(dpy, marker, Info.size);
marker += Info.size;
(*num)++;
}
} else
_XEatData(dpy, rep.length << 2);
p_XEatData(dpy, rep.length << 2);
}
UnlockDisplay(dpy);
......@@ -882,7 +890,7 @@ SDL_NAME(XvImageFormatValues) * SDL_NAME(XvListImageFormats) (
/* READ THE REPLY */
if (_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) {
if (p_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) {
UnlockDisplay(dpy);
SyncHandle();
return NULL;
......@@ -896,7 +904,7 @@ SDL_NAME(XvImageFormatValues) * SDL_NAME(XvListImageFormats) (
int 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].type = Info.type;
ret[i].byte_order = Info.byte_order;
......@@ -922,7 +930,7 @@ SDL_NAME(XvImageFormatValues) * SDL_NAME(XvListImageFormats) (
(*num)++;
}
} else
_XEatData(dpy, rep.length << 2);
p_XEatData(dpy, rep.length << 2);
}
UnlockDisplay(dpy);
......@@ -956,7 +964,7 @@ SDL_NAME(XvImage) * SDL_NAME(XvCreateImage) (
/* READ THE REPLY */
if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
if (!p_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
UnlockDisplay(dpy);
SyncHandle();
return NULL;
......@@ -972,10 +980,10 @@ SDL_NAME(XvImage) * SDL_NAME(XvCreateImage) (
ret->offsets = ret->pitches + rep.num_planes;
ret->data = data;
ret->obdata = NULL;
_XRead(dpy, (char*)(ret->pitches), rep.num_planes << 2);
_XRead(dpy, (char*)(ret->offsets), rep.num_planes << 2);
p_XRead(dpy, (char*)(ret->pitches), rep.num_planes << 2);
p_XRead(dpy, (char*)(ret->offsets), rep.num_planes << 2);
} else
_XEatData(dpy, rep.length << 2);
p_XEatData(dpy, rep.length << 2);
UnlockDisplay(dpy);
SyncHandle();
......@@ -1124,7 +1132,7 @@ xv_wire_to_event(Display *dpy, XEvent *host, xEvent *wire)
case XvVideoNotify:
re->xvvideo.type = event->u.u.type & 0x7f;
re->xvvideo.serial =
_XSetLastRequestRead(dpy, (xGenericReply *)event);
p_XSetLastRequestRead(dpy, (xGenericReply *)event);
re->xvvideo.send_event = ((event->u.u.type & 0x80) != 0);
re->xvvideo.display = dpy;
re->xvvideo.time = event->u.videoNotify.time;
......@@ -1135,7 +1143,7 @@ xv_wire_to_event(Display *dpy, XEvent *host, xEvent *wire)
case XvPortNotify:
re->xvport.type = event->u.u.type & 0x7f;
re->xvport.serial =
_XSetLastRequestRead(dpy, (xGenericReply *)event);
p_XSetLastRequestRead(dpy, (xGenericReply *)event);
re->xvport.send_event = ((event->u.u.type & 0x80) != 0);
re->xvport.display = dpy;
re->xvport.time = event->u.portNotify.time;
......
......@@ -51,7 +51,7 @@ SOFTWARE.
#define XvGetReq(name, req) \
WORD64ALIGN\
if ((dpy->bufptr + SIZEOF(xv##name##Req)) > dpy->bufmax)\
_XFlush(dpy);\
p_XFlush(dpy);\
req = (xv##name##Req *)(dpy->last_req = dpy->bufptr);\
req->reqType = info->codes->major_opcode;\
req->xvReqType = xv_##name; \
......@@ -63,7 +63,7 @@ SOFTWARE.
#define XvGetReq(name, req) \
WORD64ALIGN\
if ((dpy->bufptr + SIZEOF(xv/**/name/**/Req)) > dpy->bufmax)\
_XFlush(dpy);\
p_XFlush(dpy);\
req = (xv/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\
req->reqType = info->codes->major_opcode;\
req->xvReqType = xv_/**/name;\
......
......@@ -56,7 +56,6 @@ Copyright (c) 1995,1996 The XFree86 Project, Inc
#undef _SC_PAGESIZE
#endif
#define NEED_EVENTS
#define NEED_REPLIES
#include <X11/Xlibint.h>
......@@ -65,6 +64,14 @@ Copyright (c) 1995,1996 The XFree86 Project, Inc
#include <X11/extensions/Xext.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 char *SDL_NAME(xdga_extension_name);
......@@ -112,7 +119,7 @@ Bool SDL_NAME(XF86DGAGetVideoLL)(
req->reqType = info->codes->major_opcode;
req->dgaReqType = X_XF86DGAGetVideoLL;
req->screen = screen;
if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
if (!p_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
UnlockDisplay(dpy);
SyncHandle();
return False;
......@@ -147,7 +154,7 @@ Bool SDL_NAME(XF86DGADirectVideoLL)(
req->enable = enable;
UnlockDisplay(dpy);
SyncHandle();
XSync(dpy,False);
pXSync(dpy,False);
return True;
}
......@@ -168,7 +175,7 @@ Bool SDL_NAME(XF86DGAGetViewPortSize)(
req->reqType = info->codes->major_opcode;
req->dgaReqType = X_XF86DGAGetViewPortSize;
req->screen = screen;
if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
if (!p_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
UnlockDisplay(dpy);
SyncHandle();
return False;
......@@ -203,7 +210,7 @@ Bool SDL_NAME(XF86DGASetViewPort)(
req->y = y;
UnlockDisplay(dpy);
SyncHandle();
XSync(dpy,False);
pXSync(dpy,False);
return True;
}
......@@ -224,7 +231,7 @@ Bool SDL_NAME(XF86DGAGetVidPage)(
req->reqType = info->codes->major_opcode;
req->dgaReqType = X_XF86DGAGetVidPage;
req->screen = screen;
if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
if (!p_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
UnlockDisplay(dpy);
SyncHandle();
return False;
......@@ -255,7 +262,7 @@ Bool SDL_NAME(XF86DGASetVidPage)(
req->vpage = vpage;
UnlockDisplay(dpy);
SyncHandle();
XSync(dpy,False);
pXSync(dpy,False);
return True;
}
......@@ -277,7 +284,7 @@ Bool SDL_NAME(XF86DGAInstallColormap)(
req->id = cmap;
UnlockDisplay(dpy);
SyncHandle();
XSync(dpy,False);
pXSync(dpy,False);
return True;
}
......@@ -297,7 +304,7 @@ Bool SDL_NAME(XF86DGAQueryDirectVideo)(
req->reqType = info->codes->major_opcode;
req->dgaReqType = X_XF86DGAQueryDirectVideo;
req->screen = screen;
if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
if (!p_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
UnlockDisplay(dpy);
SyncHandle();
return False;
......@@ -325,7 +332,7 @@ Bool SDL_NAME(XF86DGAViewPortChanged)(
req->dgaReqType = X_XF86DGAViewPortChanged;
req->screen = screen;
req->n = n;
if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
if (!p_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
UnlockDisplay(dpy);
SyncHandle();
return False;
......@@ -598,7 +605,7 @@ SDL_NAME(XF86DGAForkApp)(int screen)
for (i = 0; i < numScrs; i++) {
sp = scrList[i];
SDL_NAME(XF86DGADirectVideoLL)(sp->display, sp->screen, 0);
XSync(sp->display, False);
pXSync(sp->display, False);
}
if (WIFEXITED(status))
_exit(0);
......@@ -658,7 +665,7 @@ XF86cleanup(int sig)
for (i = 0; i < numScrs; i++) {
sp = scrList[i];
SDL_NAME(XF86DGADirectVideo)(sp->display, sp->screen, 0);
XSync(sp->display, False);
pXSync(sp->display, False);
}
_exit(3);
}
......
......@@ -28,6 +28,14 @@ Copyright (c) 1995,1996 The XFree86 Project, Inc
#include <linux/fb.h>
#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 */
#define MAX_HEADS 16
......@@ -104,7 +112,7 @@ xdga_wire_to_event(
case MotionNotify:
mevent = (SDL_NAME(XDGAMotionEvent)*)event;
mevent->type = wire->u.u.type & 0x7F;
mevent->serial = _XSetLastRequestRead(dpy, (xGenericReply *)wire);
mevent->serial = p_XSetLastRequestRead(dpy, (xGenericReply *)wire);
mevent->display = dpy;
mevent->screen = wire->u.event.screen;
mevent->time = wire->u.event.time;
......@@ -116,7 +124,7 @@ xdga_wire_to_event(
case ButtonRelease:
bevent = (SDL_NAME(XDGAButtonEvent)*)event;
bevent->type = wire->u.u.type & 0x7F;
bevent->serial = _XSetLastRequestRead(dpy, (xGenericReply *)wire);
bevent->serial = p_XSetLastRequestRead(dpy, (xGenericReply *)wire);
bevent->display = dpy;
bevent->screen = wire->u.event.screen;
bevent->time = wire->u.event.time;
......@@ -127,7 +135,7 @@ xdga_wire_to_event(
case KeyRelease:
kevent = (SDL_NAME(XDGAKeyEvent)*)event;
kevent->type = wire->u.u.type & 0x7F;
kevent->serial = _XSetLastRequestRead(dpy, (xGenericReply *)wire);
kevent->serial = p_XSetLastRequestRead(dpy, (xGenericReply *)wire);
kevent->display = dpy;
kevent->screen = wire->u.event.screen;
kevent->time = wire->u.event.time;
......@@ -172,7 +180,7 @@ Bool SDL_NAME(XDGAQueryVersion)(
GetReq(XDGAQueryVersion, req);
req->reqType = info->codes->major_opcode;
req->dgaReqType = X_XDGAQueryVersion;
if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
if (!p_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
UnlockDisplay(dpy);
SyncHandle();
return False;
......@@ -189,8 +197,8 @@ Bool SDL_NAME(XDGAQueryVersion)(
i < XF86DGANumberEvents;
i++, j++)
{
XESetWireToEvent (dpy, j, xdga_wire_to_event);
XESetEventToWire (dpy, j, xdga_event_to_wire);
pXESetWireToEvent(dpy, j, xdga_wire_to_event);
pXESetEventToWire(dpy, j, xdga_event_to_wire);
}
SDL_NAME(XDGASetClientVersion)(dpy);
}
......@@ -233,7 +241,7 @@ Bool SDL_NAME(XDGAOpenFramebuffer)(
req->reqType = info->codes->major_opcode;
req->dgaReqType = X_XDGAOpenFramebuffer;
req->screen = screen;
if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
if (!p_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
UnlockDisplay(dpy);
SyncHandle();
return False;
......@@ -241,7 +249,7 @@ Bool SDL_NAME(XDGAOpenFramebuffer)(
if(rep.length) {
deviceName = Xmalloc(rep.length << 2);
_XRead(dpy, deviceName, rep.length << 2);
p_XRead(dpy, deviceName, rep.length << 2);
}
ret = SDL_NAME(XDGAMapFramebuffer)(screen, deviceName,
......@@ -298,7 +306,7 @@ SDL_NAME(XDGAMode)* SDL_NAME(XDGAQueryModes)(
req->dgaReqType = X_XDGAQueryModes;
req->screen = screen;
if (_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
if (p_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
if(rep.length) {
xXDGAModeInfo info;
int i, size;
......@@ -312,7 +320,7 @@ SDL_NAME(XDGAMode)* SDL_NAME(XDGAQueryModes)(
if(modes) {
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].verticalRefresh =
......@@ -340,13 +348,13 @@ SDL_NAME(XDGAMode)* SDL_NAME(XDGAQueryModes)(
modes[i].reserved1 = info.reserved1;
modes[i].reserved2 = info.reserved2;
_XRead(dpy, offset, info.name_size);
p_XRead(dpy, offset, info.name_size);
modes[i].name = offset;
offset += info.name_size;
}
*num = rep.number;
} else
_XEatData(dpy, rep.length << 2);
p_XEatData(dpy, rep.length << 2);
}
}
......@@ -379,7 +387,7 @@ SDL_NAME(XDGASetMode)(
req->mode = mode;
req->pid = pid = XAllocID(dpy);
if (_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
if (p_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
if(rep.length) {
xXDGAModeInfo info;
int size;
......@@ -390,7 +398,7 @@ SDL_NAME(XDGASetMode)(
dev = (SDL_NAME(XDGADevice)*)Xmalloc(sizeof(SDL_NAME(XDGADevice)) + size);
if(dev) {
_XRead(dpy, (char*)(&info), sz_xXDGAModeInfo);
p_XRead(dpy, (char*)(&info), sz_xXDGAModeInfo);
dev->mode.num = info.num;
dev->mode.verticalRefresh =
......@@ -419,7 +427,7 @@ SDL_NAME(XDGASetMode)(
dev->mode.reserved2 = info.reserved2;
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->data = SDL_NAME(XDGAGetMappedMemory)(screen);
......@@ -610,7 +618,7 @@ int SDL_NAME(XDGAGetViewportStatus)(
req->reqType = info->codes->major_opcode;
req->dgaReqType = X_XDGAGetViewportStatus;
req->screen = screen;
if (!_XReply(dpy, (xReply *)&rep, 0, xFalse))
if (!p_XReply(dpy, (xReply *)&rep, 0, xFalse))
status = rep.status;
UnlockDisplay(dpy);
SyncHandle();
......@@ -632,7 +640,7 @@ void SDL_NAME(XDGASync)(
req->reqType = info->codes->major_opcode;
req->dgaReqType = X_XDGASync;
req->screen = screen;
_XReply(dpy, (xReply *)&rep, 0, xFalse);
p_XReply(dpy, (xReply *)&rep, 0, xFalse);
UnlockDisplay(dpy);
SyncHandle();
}
......@@ -659,7 +667,7 @@ void SDL_NAME(XDGAChangePixmapMode)(
req->x = *x;
req->y = *y;
req->flags = mode;
_XReply(dpy, (xReply *)&rep, 0, xFalse);
p_XReply(dpy, (xReply *)&rep, 0, xFalse);
*x = rep.x;
*y = rep.y;
UnlockDisplay(dpy);
......
This diff is collapsed.
......@@ -173,9 +173,9 @@ extern XExtDisplayInfo *XextFindDisplay(
#define XextHasExtension(i) ((i) && ((i)->codes))
#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) \
if (!XextHasExtension(i)) { XMissingExtension (dpy, name); return; }
if (!XextHasExtension(i)) { pXMissingExtension (dpy, name); return; }
/*
......@@ -188,9 +188,9 @@ extern XExtDisplayInfo *XextFindDisplay(
XExtDisplayInfo *proc (Display *dpy) \
{ \
XExtDisplayInfo *dpyinfo; \
if (!extinfo) { if (!(extinfo = XextCreateExtension())) return NULL; } \
if (!(dpyinfo = XextFindDisplay (extinfo, dpy))) \
dpyinfo = XextAddDisplay (extinfo,dpy,extname,hooks,nev,data); \
if (!extinfo) { if (!(extinfo = pXextCreateExtension())) return NULL; } \
if (!(dpyinfo = pXextFindDisplay (extinfo, dpy))) \
dpyinfo = pXextAddDisplay (extinfo,dpy,extname,hooks,nev,data); \
return dpyinfo; \
}
......@@ -200,7 +200,7 @@ XExtDisplayInfo *proc (Display *dpy) \
#define XEXT_GENERATE_CLOSE_DISPLAY(proc,extinfo) \
int proc (Display *dpy, XExtCodes *codes) \
{ \
return XextRemoveDisplay (extinfo, dpy); \
return pXextRemoveDisplay (extinfo, dpy); \
}
#define XEXT_CLOSE_DISPLAY_PROTO(proc) \
......@@ -213,7 +213,7 @@ char *proc (Display *dpy, int code, XExtCodes *codes, char *buf, int n) \
if (code >= 0 && code < nerr) { \
char tmp[256]; \
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 (char *)0; \
......
......@@ -47,7 +47,7 @@ static int DGA_DispatchEvent(_THIS)
int posted;
SDL_NAME(XDGAEvent) xevent;
XNextEvent(DGA_Display, (XEvent *)&xevent);
pXNextEvent(DGA_Display, (XEvent *)&xevent);
posted = 0;
xevent.type -= DGA_event_base;
......
......@@ -48,6 +48,9 @@ static char rcsid =
#include "SDL_dgamouse_c.h"
#include "SDL_dgaevents_c.h"
/* get function pointers... */
#include "../x11/SDL_x11dyn.h"
/* Initialization/Query functions */
static int DGA_VideoInit(_THIS, SDL_PixelFormat *vformat);
static SDL_Rect **DGA_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
......@@ -72,18 +75,17 @@ static int DGA_FlipHWSurface(_THIS, SDL_Surface *surface);
static int DGA_Available(void)
{
const char *display;
Display *dpy;
int available;
const char *display = NULL;
Display *dpy = NULL;
int available = 0;
/* The driver is available is available if the display is local
and the DGA 2.0+ extension is available, and we can map mem.
*/
available = 0;
display = NULL;
if ( (strncmp(XDisplayName(display), ":", 1) == 0) ||
(strncmp(XDisplayName(display), "unix:", 5) == 0) ) {
dpy = XOpenDisplay(display);
if ( SDL_X11_LoadSymbols() ) {
if ( (strncmp(pXDisplayName(display), ":", 1) == 0) ||
(strncmp(pXDisplayName(display), "unix:", 5) == 0) ) {
dpy = pXOpenDisplay(display);
if ( dpy ) {
int events, errors, major, minor;
......@@ -98,23 +100,29 @@ static int DGA_Available(void)
SDL_NAME(XDGACloseFramebuffer)(dpy, screen);
}
}
XCloseDisplay(dpy);
pXCloseDisplay(dpy);
}
}
SDL_X11_UnloadSymbols();
}
return(available);
}
static void DGA_DeleteDevice(SDL_VideoDevice *device)
{
if (device != NULL) {
free(device->hidden);
free(device);
SDL_X11_UnloadSymbols();
}
}
static SDL_VideoDevice *DGA_CreateDevice(int devindex)
{
SDL_VideoDevice *device;
SDL_VideoDevice *device = NULL;
/* Initialize all variables that we clean on shutdown */
if (SDL_X11_LoadSymbols()) {
device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice));
if ( device ) {
memset(device, 0, (sizeof *device));
......@@ -126,6 +134,7 @@ static SDL_VideoDevice *DGA_CreateDevice(int devindex)
if ( device ) {
free(device);
}
SDL_X11_UnloadSymbols();
return(0);
}
memset(device->hidden, 0, (sizeof *device->hidden));
......@@ -157,6 +166,7 @@ static SDL_VideoDevice *DGA_CreateDevice(int devindex)
device->PumpEvents = DGA_PumpEvents;
device->free = DGA_DeleteDevice;
}
return device;
}
......@@ -329,7 +339,7 @@ static int DGA_VideoInit(_THIS, SDL_PixelFormat *vformat)
/* Open the X11 display */
display = NULL; /* Get it from DISPLAY environment variable */
DGA_Display = XOpenDisplay(display);
DGA_Display = pXOpenDisplay(display);
if ( DGA_Display == NULL ) {
SDL_SetError("Couldn't open X11 display");
return(-1);
......@@ -339,12 +349,12 @@ static int DGA_VideoInit(_THIS, SDL_PixelFormat *vformat)
if ( ! SDL_NAME(XDGAQueryExtension)(DGA_Display, &event_base, &error_base) ||
! SDL_NAME(XDGAQueryVersion)(DGA_Display, &major_version, &minor_version) ) {
SDL_SetError("DGA extension not available");
XCloseDisplay(DGA_Display);
pXCloseDisplay(DGA_Display);
return(-1);
}
if ( major_version < 2 ) {
SDL_SetError("DGA driver requires DGA 2.0 or newer");
XCloseDisplay(DGA_Display);
pXCloseDisplay(DGA_Display);
return(-1);
}
DGA_event_base = event_base;
......@@ -356,10 +366,10 @@ static int DGA_VideoInit(_THIS, SDL_PixelFormat *vformat)
int i, num_formats;
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 ) {
SDL_SetError("Couldn't determine screen formats");
XCloseDisplay(DGA_Display);
pXCloseDisplay(DGA_Display);
return(-1);
}
for ( i=0; i<num_formats; ++i ) {
......@@ -368,7 +378,7 @@ static int DGA_VideoInit(_THIS, SDL_PixelFormat *vformat)
}
if ( i != num_formats )
vformat->BitsPerPixel = pix_format[i].bits_per_pixel;
XFree((char *)pix_format);
pXFree((char *)pix_format);
}
if ( vformat->BitsPerPixel > 8 ) {
vformat->Rmask = visual->red_mask;
......@@ -379,7 +389,7 @@ static int DGA_VideoInit(_THIS, SDL_PixelFormat *vformat)
/* Open access to the framebuffer */
if ( ! SDL_NAME(XDGAOpenFramebuffer)(DGA_Display, DGA_Screen) ) {
SDL_SetError("Unable to map the video memory");
XCloseDisplay(DGA_Display);
pXCloseDisplay(DGA_Display);
return(-1);
}
......@@ -399,7 +409,7 @@ static int DGA_VideoInit(_THIS, SDL_PixelFormat *vformat)
}
}
UpdateHWInfo(this, modes);
XFree(modes);
pXFree(modes);
/* Create the hardware surface lock mutex */
hw_lock = SDL_CreateMutex();
......@@ -438,7 +448,7 @@ SDL_Surface *DGA_SetVideoMode(_THIS, SDL_Surface *current,
/* Free any previous colormap */
if ( DGA_colormap ) {
XFreeColormap(DGA_Display, DGA_colormap);
pXFreeColormap(DGA_Display, DGA_colormap);
DGA_colormap = 0;
}
......@@ -469,7 +479,7 @@ SDL_Surface *DGA_SetVideoMode(_THIS, SDL_Surface *current,
/* Set the video mode */
mode = SDL_NAME(XDGASetMode)(DGA_Display, DGA_Screen, modes[i].num);
XFree(modes);
pXFree(modes);
if ( mode == NULL ) {
SDL_SetError("Unable to switch to requested mode");
return(NULL);
......@@ -817,7 +827,7 @@ static int DGA_FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *rect, Uint32 color)
#endif
SDL_NAME(XDGAFillRectangle)(DGA_Display, DGA_Screen, x, y, w, h, color);
if ( !(this->screen->flags & SDL_DOUBLEBUF) ) {
XFlush(DGA_Display);
pXFlush(DGA_Display);
}
DGA_AddBusySurface(dst);
UNLOCK_DISPLAY();
......@@ -859,7 +869,7 @@ static int HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect,
srcx, srcy, w, h, dstx, dsty);
}
if ( !(this->screen->flags & SDL_DOUBLEBUF) ) {
XFlush(DGA_Display);
pXFlush(DGA_Display);
}
DGA_AddBusySurface(src);
DGA_AddBusySurface(dst);
......@@ -939,7 +949,7 @@ static int DGA_FlipHWSurface(_THIS, SDL_Surface *surface)
DGA_WaitFlip(this);
SDL_NAME(XDGASetViewport)(DGA_Display, DGA_Screen,
0, flip_yoffset[flip_page], XDGAFlipRetrace);
XFlush(DGA_Display);
pXFlush(DGA_Display);
UNLOCK_DISPLAY();
was_flipped = 1;
flip_page = !flip_page;
......@@ -972,8 +982,8 @@ static int DGA_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
xcmap[i].flags = (DoRed|DoGreen|DoBlue);
}
LOCK_DISPLAY();
XStoreColors(DGA_Display, DGA_colormap, xcmap, ncolors);
XSync(DGA_Display, False);
pXStoreColors(DGA_Display, DGA_colormap, xcmap, ncolors);
pXSync(DGA_Display, False);
UNLOCK_DISPLAY();
/* That was easy. :) */
......@@ -1006,8 +1016,8 @@ int DGA_SetGammaRamp(_THIS, Uint16 *ramp)
xcmap[i].flags = (DoRed|DoGreen|DoBlue);
}
LOCK_DISPLAY();
XStoreColors(DGA_Display, DGA_colormap, xcmap, ncolors);
XSync(DGA_Display, False);
pXStoreColors(DGA_Display, DGA_colormap, xcmap, ncolors);
pXSync(DGA_Display, False);
UNLOCK_DISPLAY();
return(0);
}
......@@ -1019,7 +1029,7 @@ void DGA_VideoQuit(_THIS)
if ( DGA_Display ) {
/* Free colormap, if necessary */
if ( DGA_colormap ) {
XFreeColormap(DGA_Display, DGA_colormap);
pXFreeColormap(DGA_Display, DGA_colormap);
DGA_colormap = 0;
}
......@@ -1059,6 +1069,6 @@ void DGA_VideoQuit(_THIS)
DGA_FreeHWSurfaces(this);
/* Close up the display */
XCloseDisplay(DGA_Display);
pXCloseDisplay(DGA_Display);
}
}
......@@ -4,6 +4,9 @@
noinst_LTLIBRARIES = libvideo_x11.la
libvideo_x11_la_SOURCES = $(X11_SRCS)
x11_lib = \"@x11_lib@\"
x11ext_lib = \"@x11ext_lib@\"
# The SDL X11 video driver sources
X11_SRCS = \
SDL_x11dga.c \
......@@ -25,4 +28,8 @@ X11_SRCS = \
SDL_x11wm.c \
SDL_x11wm_c.h \
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)
int repeated;
repeated = 0;
if ( XPending(display) ) {
XPeekEvent(display, &peekevent);
if ( pXPending(display) ) {
pXPeekEvent(display, &peekevent);
if ( (peekevent.type == KeyPress) &&
(peekevent.xkey.keycode == event->xkey.keycode) &&
((peekevent.xkey.time-event->xkey.time) < 2) ) {
repeated = 1;
XNextEvent(display, &peekevent);
pXNextEvent(display, &peekevent);
}
}
return(repeated);
......@@ -115,7 +115,7 @@ static __inline__ int X11_WarpedMotion(_THIS, XEvent *xevent)
(xevent->xmotion.y < MOUSE_FUDGE_FACTOR) ||
(xevent->xmotion.y > (h-MOUSE_FUDGE_FACTOR)) ) {
/* 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;
deltay = xevent->xmotion.y - mouse_last.y;
#ifdef DEBUG_MOTION
......@@ -127,10 +127,10 @@ static __inline__ int X11_WarpedMotion(_THIS, XEvent *xevent)
}
mouse_last.x = w/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);
for ( i=0; i<10; ++i ) {
XMaskEvent(SDL_Display, PointerMotionMask, xevent);
pXMaskEvent(SDL_Display, PointerMotionMask, xevent);
if ( (xevent->xmotion.x >
(mouse_last.x-MOUSE_FUDGE_FACTOR)) &&
(xevent->xmotion.x <
......@@ -160,7 +160,7 @@ static int X11_DispatchEvent(_THIS)
XEvent xevent;
memset(&xevent, '\0', sizeof (XEvent)); /* valgrind fix. --ryan. */
XNextEvent(SDL_Display, &xevent);
pXNextEvent(SDL_Display, &xevent);
posted = 0;
switch (xevent.type) {
......@@ -437,8 +437,8 @@ printf("Unhandled event %d\n", xevent.type);
int X11_Pending(Display *display)
{
/* Flush the display connection and look to see if events are queued */
XFlush(display);
if ( XEventsQueued(display, QueuedAlready) ) {
pXFlush(display);
if ( pXEventsQueued(display, QueuedAlready) ) {
return(1);
}
......@@ -452,7 +452,7 @@ int X11_Pending(Display *display)
FD_ZERO(&fdset);
FD_SET(x11_fd, &fdset);
if ( select(x11_fd+1, &fdset, NULL, NULL, &zero_time) == 1 ) {
return(XPending(display));
return(pXPending(display));
}
}
......@@ -619,7 +619,7 @@ SDL_keysym *X11_TranslateKey(Display *display, XKeyEvent *xkey, KeyCode kc,
/* Get the raw keyboard scancode */
keysym->scancode = kc;
xsym = XKeycodeToKeysym(display, kc, 0);
xsym = pXKeycodeToKeysym(display, kc, 0);
#ifdef DEBUG_KEYS
fprintf(stderr, "Translating key 0x%.4x (%d)\n", xsym, kc);
#endif
......@@ -711,7 +711,7 @@ SDL_keysym *X11_TranslateKey(Display *display, XKeyEvent *xkey, KeyCode kc,
}
#endif
/* 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) ) {
/*
* FIXME,: XLookupString() may yield more than one
......@@ -739,12 +739,12 @@ static void get_modifier_masks(Display *display)
if(got_masks)
return;
xmods = XGetModifierMapping(display);
xmods = pXGetModifierMapping(display);
n = xmods->max_keypermod;
for(i = 3; i < 8; i++) {
for(j = 0; j < 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;
switch(ks) {
case XK_Num_Lock:
......@@ -762,7 +762,7 @@ static void get_modifier_masks(Display *display)
}
}
}
XFreeModifiermap(xmods);
pXFreeModifiermap(xmods);
got_masks = 1;
}
......@@ -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);
if(modifiers & KMOD_SHIFT)
......@@ -827,7 +827,7 @@ Uint16 X11_KeyToUnicode(SDLKey keysym, SDLMod modifiers)
xkey.state |= num_mask;
unicode = 0;
if ( XLookupString(&xkey, keybuf, sizeof(keybuf), NULL, NULL) )
if ( pXLookupString(&xkey, keybuf, sizeof(keybuf), NULL, NULL) )
unicode = (unsigned char)keybuf[0];
return(unicode);
}
......@@ -851,14 +851,14 @@ void X11_SetKeyboardState(Display *display, const char *key_vec)
/* The first time the window is mapped, we initialize key state */
if ( ! key_vec ) {
XQueryKeymap(display, keys_return);
pXQueryKeymap(display, keys_return);
key_vec = keys_return;
}
/* Get the keyboard modifier state */
modstate = 0;
get_modifier_masks(display);
if ( XQueryPointer(display, DefaultRootWindow(display),
if ( pXQueryPointer(display, DefaultRootWindow(display),
&junk_window, &junk_window, &x, &y, &x, &y, &mask) ) {
if ( mask & LockMask ) {
modstate |= KMOD_CAPS;
......
......@@ -68,7 +68,7 @@ static int X11_SetGammaNoLock(_THIS, float red, float green, float blue)
}
if ( SDL_GetAppState() & SDL_APPACTIVE ) {
succeeded = SDL_NAME(XF86VidModeSetGamma)(SDL_Display, SDL_Screen, &gamma);
XSync(SDL_Display, False);
pXSync(SDL_Display, False);
} else {
gamma_saved[0] = gamma.red;
gamma_saved[1] = gamma.green;
......
......@@ -69,10 +69,10 @@ XVisualInfo *X11_GL_GetVisual(_THIS)
XVisualInfo vi_in;
int out_count;
XGetWindowAttributes(SDL_Display, SDL_Window, &a);
pXGetWindowAttributes(SDL_Display, SDL_Window, &a);
vi_in.screen = SDL_Screen;
vi_in.visualid = XVisualIDFromVisual(a.visual);
glx_visualinfo = XGetVisualInfo(SDL_Display,
vi_in.visualid = pXVisualIDFromVisual(a.visual);
glx_visualinfo = pXGetVisualInfo(SDL_Display,
VisualScreenMask|VisualIDMask, &vi_in, &out_count);
return glx_visualinfo;
}
......@@ -188,7 +188,7 @@ int X11_GL_CreateWindow(_THIS, int w, int h)
attributes.colormap = SDL_XColorMap;
mask = CWBackPixel | CWBorderPixel | CWColormap;
SDL_Window = XCreateWindow(SDL_Display, WMwindow,
SDL_Window = pXCreateWindow(SDL_Display, WMwindow,
0, 0, w, h, 0, glx_visualinfo->depth,
InputOutput, glx_visualinfo->visual,
mask, &attributes);
......@@ -209,10 +209,10 @@ int X11_GL_CreateContext(_THIS)
int retval;
#ifdef HAVE_OPENGL
/* 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_visualinfo, NULL, True);
XSync( GFX_Display, False );
pXSync( GFX_Display, False );
if (glx_context == NULL) {
SDL_SetError("Could not create GL context");
......@@ -296,7 +296,7 @@ int X11_GL_MakeCurrent(_THIS)
SDL_SetError("Unable to make GL context current");
retval = -1;
}
XSync( GFX_Display, False );
pXSync( GFX_Display, False );
/*
* The context is now current, check for glXReleaseBuffersMESA()
......
......@@ -35,9 +35,6 @@ static char rcsid =
#ifndef NO_SHARED_MEMORY
/* Shared memory information */
extern int XShmQueryExtension(Display *dpy); /* Not in X11 headers */
/* Shared memory error handler routine */
static int shm_error;
static int (*X_handler)(Display *, XErrorEvent *) = NULL;
......@@ -61,10 +58,10 @@ static void try_mitshm(_THIS, SDL_Surface *screen)
shminfo.readOnly = False;
if ( shminfo.shmaddr != (char *)-1 ) {
shm_error = False;
X_handler = XSetErrorHandler(shm_errhandler);
XShmAttach(SDL_Display, &shminfo);
XSync(SDL_Display, True);
XSetErrorHandler(X_handler);
X_handler = pXSetErrorHandler(shm_errhandler);
pXShmAttach(SDL_Display, &shminfo);
pXSync(SDL_Display, True);
pXSetErrorHandler(X_handler);
if ( shm_error )
shmdt(shminfo.shmaddr);
} else {
......@@ -90,13 +87,13 @@ int X11_SetupImage(_THIS, SDL_Surface *screen)
#ifndef NO_SHARED_MEMORY
try_mitshm(this, screen);
if(use_mitshm) {
SDL_Ximage = XShmCreateImage(SDL_Display, SDL_Visual,
SDL_Ximage = pXShmCreateImage(SDL_Display, SDL_Visual,
this->hidden->depth, ZPixmap,
shminfo.shmaddr, &shminfo,
screen->w, screen->h);
if(!SDL_Ximage) {
XShmDetach(SDL_Display, &shminfo);
XSync(SDL_Display, False);
pXShmDetach(SDL_Display, &shminfo);
pXSync(SDL_Display, False);
shmdt(shminfo.shmaddr);
screen->pixels = NULL;
goto error;
......@@ -113,7 +110,7 @@ int X11_SetupImage(_THIS, SDL_Surface *screen)
return -1;
}
bpp = screen->format->BytesPerPixel;
SDL_Ximage = XCreateImage(SDL_Display, SDL_Visual,
SDL_Ximage = pXCreateImage(SDL_Display, SDL_Visual,
this->hidden->depth, ZPixmap, 0,
(char *)screen->pixels,
screen->w, screen->h,
......@@ -136,11 +133,11 @@ error:
void X11_DestroyImage(_THIS, SDL_Surface *screen)
{
if ( SDL_Ximage ) {
XDestroyImage(SDL_Ximage);
pXDestroyImage(SDL_Ximage);
#ifndef NO_SHARED_MEMORY
if ( use_mitshm ) {
XShmDetach(SDL_Display, &shminfo);
XSync(SDL_Display, False);
pXShmDetach(SDL_Display, &shminfo);
pXSync(SDL_Display, False);
shmdt(shminfo.shmaddr);
}
#endif /* ! NO_SHARED_MEMORY */
......@@ -221,7 +218,7 @@ void X11_FreeHWSurface(_THIS, SDL_Surface *surface)
int X11_LockHWSurface(_THIS, SDL_Surface *surface)
{
if ( (surface == SDL_VideoSurface) && blit_queued ) {
XSync(GFX_Display, False);
pXSync(GFX_Display, False);
blit_queued = 0;
}
return(0);
......@@ -244,15 +241,15 @@ static void X11_NormalUpdate(_THIS, int numrects, SDL_Rect *rects)
if ( rects[i].w == 0 || rects[i].h == 0 ) { /* Clipped? */
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].w, rects[i].h);
}
if ( SDL_VideoSurface->flags & SDL_ASYNCBLIT ) {
XFlush(GFX_Display);
pXFlush(GFX_Display);
blit_queued = 1;
} else {
XSync(GFX_Display, False);
pXSync(GFX_Display, False);
}
}
......@@ -265,16 +262,16 @@ static void X11_MITSHMUpdate(_THIS, int numrects, SDL_Rect *rects)
if ( rects[i].w == 0 || rects[i].h == 0 ) { /* Clipped? */
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].w, rects[i].h,
False);
}
if ( SDL_VideoSurface->flags & SDL_ASYNCBLIT ) {
XFlush(GFX_Display);
pXFlush(GFX_Display);
blit_queued = 1;
} else {
XSync(GFX_Display, False);
pXSync(GFX_Display, False);
}
#endif /* ! NO_SHARED_MEMORY */
}
......@@ -308,14 +305,14 @@ void X11_RefreshDisplay(_THIS)
}
#ifndef NO_SHARED_MEMORY
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,
False);
} else
#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);
}
XSync(SDL_Display, False);
pXSync(SDL_Display, False);
}
......@@ -141,7 +141,7 @@ static void set_best_resolution(_THIS, int width, int height)
(modes[i]->vdisplay != mode.vdisplay) ) {
SDL_NAME(XF86VidModeSwitchToMode)(SDL_Display, SDL_Screen, modes[i]);
}
XFree(modes);
pXFree(modes);
}
}
#endif /* XFREE86_VM */
......@@ -180,7 +180,7 @@ static void set_best_resolution(_THIS, int width, int height)
SDL_modelist[i]->w,
SDL_modelist[i]->h,
0);
XSync(SDL_Display, False);
pXSync(SDL_Display, False);
}
}
}
......@@ -230,7 +230,7 @@ void X11_WaitMapped(_THIS, Window win)
{
XEvent event;
do {
XMaskEvent(SDL_Display, StructureNotifyMask, &event);
pXMaskEvent(SDL_Display, StructureNotifyMask, &event);
} while ( (event.type != MapNotify) || (event.xmap.event != win) );
}
......@@ -239,19 +239,19 @@ void X11_WaitUnmapped(_THIS, Window win)
{
XEvent event;
do {
XMaskEvent(SDL_Display, StructureNotifyMask, &event);
pXMaskEvent(SDL_Display, StructureNotifyMask, &event);
} while ( (event.type != UnmapNotify) || (event.xunmap.event != win) );
}
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)
{
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;
this->hidden->visuals[n].depth = vi.depth;
this->hidden->visuals[n].visual = vi.visual;
......@@ -267,13 +267,13 @@ static int add_visual_byid(_THIS, const char *visual_id)
if ( visual_id ) {
memset(&template, 0, (sizeof template));
template.visualid = strtol(visual_id, NULL, 0);
vi = XGetVisualInfo(SDL_Display, VisualIDMask, &template, &nvis);
vi = pXGetVisualInfo(SDL_Display, VisualIDMask, &template, &nvis);
if ( vi ) {
int n = this->hidden->nvisuals;
this->hidden->visuals[n].depth = vi->depth;
this->hidden->visuals[n].visual = vi->visual;
this->hidden->nvisuals++;
XFree(vi);
pXFree(vi);
}
}
return(this->hidden->nvisuals);
......@@ -400,7 +400,7 @@ int X11_GetVideoModes(_THIS)
}
SDL_modelist[n] = NULL;
}
XFree(modes);
pXFree(modes);
use_vidmode = vm_major * 100 + vm_minor;
save_mode(this);
......@@ -474,7 +474,7 @@ int X11_GetVideoModes(_THIS)
use_xme = 0;
}
if ( modelist ) {
XFree(modelist);
pXFree(modelist);
}
#endif /* HAVE_XIGXME */
......@@ -509,7 +509,7 @@ int X11_GetVideoModes(_THIS)
}
/* 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++) {
int d = this->hidden->visuals[i].depth;
for(j = 0; j < np; j++)
......@@ -518,7 +518,7 @@ int X11_GetVideoModes(_THIS)
this->hidden->visuals[i].bpp = j < np ? pf[j].bits_per_pixel : d;
}
XFree(pf);
pXFree(pf);
}
if ( SDL_modelist == NULL ) {
......@@ -592,7 +592,7 @@ int X11_GetVideoModes(_THIS)
xinerama_y = xinerama[i].y_org;
}
}
XFree(xinerama);
pXFree(xinerama);
}
#endif /* HAVE_XINERAMA */
......@@ -658,15 +658,15 @@ int X11_ResizeFullScreen(_THIS)
if ( current_h > real_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);
/* Center and reparent the drawing window */
x = (real_w - current_w)/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 */
XSync(SDL_Display, True); /* Flush spurious mode change events */
pXSync(SDL_Display, True); /* Flush spurious mode change events */
}
return(1);
}
......@@ -676,7 +676,7 @@ void X11_QueueEnterFullScreen(_THIS)
switch_waiting = 0x01 | SDL_FULLSCREEN;
switch_time = SDL_GetTicks() + 1500;
#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
}
......@@ -709,14 +709,14 @@ int X11_EnterFullScreen(_THIS)
if ( current_h > real_h ) {
real_h = MAX(real_h, screen_h);
}
XMoveResizeWindow(SDL_Display, FSwindow,
pXMoveResizeWindow(SDL_Display, FSwindow,
xinerama_x, xinerama_y, real_w, real_h);
XMapRaised(SDL_Display, FSwindow);
pXMapRaised(SDL_Display, FSwindow);
X11_WaitMapped(this, FSwindow);
#if 0 /* This seems to break WindowMaker in focus-follows-mouse mode */
/* 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 ) {
/* If not, try to put us there - if fail... oh well */
if ( windows[nwindows-1] != FSwindow ) {
......@@ -729,13 +729,13 @@ int X11_EnterFullScreen(_THIS)
}
}
windows[nwindows-1] = FSwindow;
XRestackWindows(SDL_Display, windows, nwindows);
XSync(SDL_Display, False);
pXRestackWindows(SDL_Display, windows, nwindows);
pXSync(SDL_Display, False);
}
XFree(windows);
pXFree(windows);
}
#else
XRaiseWindow(SDL_Display, FSwindow);
pXRaiseWindow(SDL_Display, FSwindow);
#endif
#ifdef XFREE86_VM
......@@ -753,7 +753,7 @@ int X11_EnterFullScreen(_THIS)
}
/* Set the colormap */
if ( SDL_XColorMap ) {
XInstallColormap(SDL_Display, SDL_XColorMap);
pXInstallColormap(SDL_Display, SDL_XColorMap);
}
if ( okay )
X11_GrabInputNoLock(this, this->input_grab | SDL_GRAB_FULLSCREEN);
......@@ -774,7 +774,7 @@ int X11_EnterFullScreen(_THIS)
int X11_LeaveFullScreen(_THIS)
{
if ( currently_fullscreen ) {
XReparentWindow(SDL_Display, SDL_Window, WMwindow, 0, 0);
pXReparentWindow(SDL_Display, SDL_Window, WMwindow, 0, 0);
#ifdef XFREE86_VM
if ( use_vidmode ) {
restore_mode(this);
......@@ -796,14 +796,14 @@ int X11_LeaveFullScreen(_THIS)
saved_res.width,
saved_res.height,
0);
XSync(SDL_Display, False);
pXSync(SDL_Display, False);
}
}
#endif
XUnmapWindow(SDL_Display, FSwindow);
pXUnmapWindow(SDL_Display, 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;
}
/* If we get popped out of fullscreen mode for some reason, input_grab
......
......@@ -50,8 +50,8 @@ void X11_FreeWMCursor(_THIS, WMcursor *cursor)
{
if ( SDL_Display != NULL ) {
SDL_Lock_EventThread();
XFreeCursor(SDL_Display, cursor->x_cursor);
XSync(SDL_Display, False);
pXFreeCursor(SDL_Display, cursor->x_cursor);
pXSync(SDL_Display, False);
SDL_Unlock_EventThread();
}
free(cursor);
......@@ -105,48 +105,48 @@ WMcursor *X11_CreateWMCursor(_THIS,
SDL_Lock_EventThread();
/* Create the data image */
data_image = XCreateImage(SDL_Display,
data_image = pXCreateImage(SDL_Display,
DefaultVisual(SDL_Display, SDL_Screen),
1, XYBitmap, 0, x_data, w, h, 8, w/8);
data_image->byte_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 */
mask_image = XCreateImage(SDL_Display,
mask_image = pXCreateImage(SDL_Display,
DefaultVisual(SDL_Display, SDL_Screen),
1, XYBitmap, 0, x_mask, w, h, 8, w/8);
mask_image->byte_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 */
GCvalues.function = GXcopy;
GCvalues.foreground = ~0;
GCvalues.background = 0;
GCvalues.plane_mask = AllPlanes;
GCcursor = XCreateGC(SDL_Display, data_pixmap,
GCcursor = pXCreateGC(SDL_Display, data_pixmap,
(GCFunction|GCForeground|GCBackground|GCPlaneMask),
&GCvalues);
/* 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);
XPutImage(SDL_Display, mask_pixmap, GCcursor, mask_image,
pXPutImage(SDL_Display, mask_pixmap, GCcursor, mask_image,
0, 0, 0, 0, w, h);
XFreeGC(SDL_Display, GCcursor);
pXFreeGC(SDL_Display, GCcursor);
/* These free the x_data and x_mask memory pointers */
XDestroyImage(data_image);
XDestroyImage(mask_image);
pXDestroyImage(data_image);
pXDestroyImage(mask_image);
/* 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);
XFreePixmap(SDL_Display, data_pixmap);
XFreePixmap(SDL_Display, mask_pixmap);
pXFreePixmap(SDL_Display, data_pixmap);
pXFreePixmap(SDL_Display, mask_pixmap);
/* Release the event thread */
XSync(SDL_Display, False);
pXSync(SDL_Display, False);
SDL_Unlock_EventThread();
return(cursor);
......@@ -164,13 +164,13 @@ int X11_ShowWMCursor(_THIS, WMcursor *cursor)
SDL_Lock_EventThread();
if ( cursor == NULL ) {
if ( SDL_BlankCursor != NULL ) {
XDefineCursor(SDL_Display, SDL_Window,
pXDefineCursor(SDL_Display, SDL_Window,
SDL_BlankCursor->x_cursor);
}
} 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();
}
return(1);
......@@ -187,8 +187,8 @@ void X11_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
SDL_PrivateMouseMotion(0, 0, x, y);
} else {
SDL_Lock_EventThread();
XWarpPointer(SDL_Display, None, SDL_Window, 0, 0, 0, 0, x, y);
XSync(SDL_Display, False);
pXWarpPointer(SDL_Display, None, SDL_Window, 0, 0, 0, 0, x, y);
pXSync(SDL_Display, False);
SDL_Unlock_EventThread();
}
}
......@@ -224,7 +224,7 @@ static void SetMouseAccel(_THIS, const char *accel_param)
}
}
if ( mouse_param_buf ) {
XChangePointerControl(SDL_Display, True, True,
pXChangePointerControl(SDL_Display, True, True,
accel_value[0], accel_value[1], accel_value[2]);
free(mouse_param_buf);
}
......@@ -257,7 +257,7 @@ void X11_CheckMouseModeNoLock(_THIS)
SDL_GetMouseState(&mouse_last.x, &mouse_last.y);
/* Use as raw mouse mickeys as possible */
XGetPointerControl(SDL_Display,
pXGetPointerControl(SDL_Display,
&mouse_accel.numerator,
&mouse_accel.denominator,
&mouse_accel.threshold);
......@@ -273,7 +273,7 @@ void X11_CheckMouseModeNoLock(_THIS)
if ( using_dga & DGA_MOUSE ) {
X11_DisableDGAMouse(this);
} else {
XChangePointerControl(SDL_Display, True, True,
pXChangePointerControl(SDL_Display, True, True,
mouse_accel.numerator,
mouse_accel.denominator,
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 =
#include <X11/Xlib.h>
#include <X11/Xutil.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
#include <XFree86/extensions/xf86dga.h>
#endif
......@@ -50,6 +46,7 @@ static char rcsid =
#include "SDL_mouse.h"
#include "SDL_sysvideo.h"
#include "SDL_x11dyn.h"
/* Hidden "this" pointer for the video functions */
#define _THIS SDL_VideoDevice *this
......
......@@ -123,7 +123,7 @@ void X11_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask)
SDL_iconcolors[i]--;
}
}
XFreeColors(GFX_Display, dcmap, freelist, nfree, 0);
pXFreeColors(GFX_Display, dcmap, freelist, nfree, 0);
}
if(!SDL_iconcolors)
SDL_iconcolors = malloc(256 * sizeof *SDL_iconcolors);
......@@ -138,7 +138,7 @@ void X11_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask)
c.green = want[i].g << 8;
c.blue = want[i].b << 8;
c.flags = DoRed | DoGreen | DoBlue;
if(XAllocColor(GFX_Display, dcmap, &c)) {
if(pXAllocColor(GFX_Display, dcmap, &c)) {
/* got the colour */
SDL_iconcolors[c.pixel]++;
got[c.pixel] = want[i];
......@@ -152,13 +152,13 @@ void X11_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask)
XColor cols[256];
for(i = 0; i < 256; i++)
cols[i].pixel = i;
XQueryColors(GFX_Display, dcmap, cols, 256);
pXQueryColors(GFX_Display, dcmap, cols, 256);
for(i = 0; i < 256; i++) {
got[i].r = cols[i].red >> 8;
got[i].g = cols[i].green >> 8;
got[i].b = cols[i].blue >> 8;
if(!SDL_iconcolors[i]) {
if(XAllocColor(GFX_Display, dcmap,
if(pXAllocColor(GFX_Display, dcmap,
cols + i)) {
SDL_iconcolors[i] = 1;
} else {
......@@ -191,13 +191,13 @@ void X11_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask)
memset(LSBmask, 0, masksize);
for(i = 0; i < masksize; i++)
LSBmask[i] = reverse_byte(mask[i]);
mask_pixmap = XCreatePixmapFromBitmapData(SDL_Display, WMwindow,
mask_pixmap = pXCreatePixmapFromBitmapData(SDL_Display, WMwindow,
(char *)LSBmask,
sicon->w, sicon->h,
1L, 0L, 1);
/* Transfer the image to an X11 pixmap */
icon_image = XCreateImage(SDL_Display,
icon_image = pXCreateImage(SDL_Display,
DefaultVisual(SDL_Display, SDL_Screen),
DefaultDepth(SDL_Display, SDL_Screen),
ZPixmap, 0, sicon->pixels,
......@@ -205,13 +205,13 @@ void X11_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask)
32, 0);
icon_image->byte_order = (SDL_BYTEORDER == SDL_BIG_ENDIAN)
? 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));
gc = XCreateGC(SDL_Display, icon_pixmap, 0, &GCvalues);
XPutImage(SDL_Display, icon_pixmap, gc, icon_image,
gc = pXCreateGC(SDL_Display, icon_pixmap, 0, &GCvalues);
pXPutImage(SDL_Display, icon_pixmap, gc, icon_image,
0, 0, 0, 0, sicon->w, sicon->h);
XFreeGC(SDL_Display, gc);
XDestroyImage(icon_image);
pXFreeGC(SDL_Display, gc);
pXDestroyImage(icon_image);
free(LSBmask);
sicon->pixels = NULL;
......@@ -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. */
p = getenv("SDL_VIDEO_X11_ICONWIN");
if(p && *p) {
icon_window = XCreateSimpleWindow(SDL_Display, SDL_Root,
icon_window = pXCreateSimpleWindow(SDL_Display, SDL_Root,
0, 0, sicon->w, sicon->h, 0,
CopyFromParent,
CopyFromParent);
XSetWindowBackgroundPixmap(SDL_Display, icon_window,
pXSetWindowBackgroundPixmap(SDL_Display, icon_window,
icon_pixmap);
XClearWindow(SDL_Display, icon_window);
pXClearWindow(SDL_Display, icon_window);
}
/* Set the window icon to the icon pixmap (and icon window) */
wmhints = XAllocWMHints();
wmhints = pXAllocWMHints();
wmhints->flags = (IconPixmapHint | IconMaskHint);
wmhints->icon_pixmap = icon_pixmap;
wmhints->icon_mask = mask_pixmap;
......@@ -238,9 +238,9 @@ void X11_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask)
wmhints->flags |= IconWindowHint;
wmhints->icon_window = icon_window;
}
XSetWMHints(SDL_Display, WMwindow, wmhints);
XFree(wmhints);
XSync(SDL_Display, False);
pXSetWMHints(SDL_Display, WMwindow, wmhints);
pXFree(wmhints);
pXSync(SDL_Display, False);
done:
SDL_Unlock_EventThread();
......@@ -257,30 +257,30 @@ void X11_SetCaption(_THIS, const char *title, const char *icon)
if ( title != NULL ) {
int error = XLocaleNotSupported;
#ifdef X_HAVE_UTF8_STRING
error = Xutf8TextListToTextProperty(SDL_Display,
error = pXutf8TextListToTextProperty(SDL_Display,
(char **)&title, 1, XUTF8StringStyle,
&titleprop);
#endif
if ( error != Success ) {
XStringListToTextProperty((char **)&title, 1,
pXStringListToTextProperty((char **)&title, 1,
&titleprop);
}
XSetWMName(SDL_Display, WMwindow, &titleprop);
XFree(titleprop.value);
pXSetWMName(SDL_Display, WMwindow, &titleprop);
pXFree(titleprop.value);
}
if ( icon != NULL ) {
int error = XLocaleNotSupported;
#ifdef X_HAVE_UTF8_STRING
error = Xutf8TextListToTextProperty(SDL_Display,
error = pXutf8TextListToTextProperty(SDL_Display,
(char **)&icon, 1, XUTF8StringStyle, &iconprop);
#endif
if ( error != Success ) {
XStringListToTextProperty((char **)&icon, 1, &iconprop);
pXStringListToTextProperty((char **)&icon, 1, &iconprop);
}
XSetWMIconName(SDL_Display, WMwindow, &iconprop);
XFree(iconprop.value);
pXSetWMIconName(SDL_Display, WMwindow, &iconprop);
pXFree(iconprop.value);
}
XSync(SDL_Display, False);
pXSync(SDL_Display, False);
SDL_Unlock_EventThread();
}
......@@ -291,8 +291,8 @@ int X11_IconifyWindow(_THIS)
int result;
SDL_Lock_EventThread();
result = XIconifyWindow(SDL_Display, WMwindow, SDL_Screen);
XSync(SDL_Display, False);
result = pXIconifyWindow(SDL_Display, WMwindow, SDL_Screen);
pXSync(SDL_Display, False);
SDL_Unlock_EventThread();
return(result);
}
......@@ -308,12 +308,12 @@ SDL_GrabMode X11_GrabInputNoLock(_THIS, SDL_GrabMode mode)
return(mode); /* Will be set later on mode switch */
}
if ( mode == SDL_GRAB_OFF ) {
XUngrabPointer(SDL_Display, CurrentTime);
XUngrabKeyboard(SDL_Display, CurrentTime);
pXUngrabPointer(SDL_Display, CurrentTime);
pXUngrabKeyboard(SDL_Display, CurrentTime);
} else {
if ( this->screen->flags & SDL_FULLSCREEN ) {
/* Unbind the mouse from the fullscreen window */
XUngrabPointer(SDL_Display, CurrentTime);
pXUngrabPointer(SDL_Display, CurrentTime);
}
/* Try to grab the mouse */
#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)
#else
while ( 1 ) {
#endif
result = XGrabPointer(SDL_Display, SDL_Window, True, 0,
result = pXGrabPointer(SDL_Display, SDL_Window, True, 0,
GrabModeAsync, GrabModeAsync,
SDL_Window, None, CurrentTime);
if ( result == GrabSuccess ) {
......@@ -333,17 +333,17 @@ SDL_GrabMode X11_GrabInputNoLock(_THIS, SDL_GrabMode mode)
/* Uh, oh, what do we do here? */ ;
}
/* Now grab the keyboard */
XGrabKeyboard(SDL_Display, WMwindow, True,
pXGrabKeyboard(SDL_Display, WMwindow, True,
GrabModeAsync, GrabModeAsync, CurrentTime);
/* Raise the window if we grab the mouse */
if ( !(this->screen->flags & SDL_FULLSCREEN) )
XRaiseWindow(SDL_Display, WMwindow);
pXRaiseWindow(SDL_Display, WMwindow);
/* Make sure we register input focus */
SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS);
}
XSync(SDL_Display, False);
pXSync(SDL_Display, False);
return(mode);
}
......@@ -368,7 +368,7 @@ static void unlock_display(void)
{
/* Make sure any X11 transactions are completed */
SDL_VideoDevice *this = current_video;
XSync(SDL_Display, False);
pXSync(SDL_Display, False);
SDL_Unlock_EventThread();
}
int X11_GetWMInfo(_THIS, SDL_SysWMinfo *info)
......
......@@ -159,7 +159,7 @@ SDL_Overlay *X11_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, S
}
}
if ( formats ) {
XFree(formats);
pXFree(formats);
}
}
}
......@@ -208,21 +208,21 @@ SDL_Overlay *X11_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, S
unsigned int i;
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 ) {
Atom a;
xv_error = False;
a = XInternAtom(GFX_Display, attr[i], True);
a = pXInternAtom(GFX_Display, attr[i], True);
if ( a != None ) {
SDL_NAME(XvSetPortAttribute)(GFX_Display, xv_port, a, 1);
XSync(GFX_Display, True);
pXSync(GFX_Display, True);
if ( ! xv_error ) {
break;
}
}
}
XSetErrorHandler(X_handler);
pXSetErrorHandler(X_handler);
SDL_NAME(XvSelectPortNotify)(GFX_Display, xv_port, False);
}
......@@ -262,7 +262,7 @@ SDL_Overlay *X11_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, S
#ifdef PITCH_WORKAROUND
if ( hwdata->image != NULL && hwdata->image->pitches[0] != (width*bpp) ) {
/* Ajust overlay width according to pitch */
XFree(hwdata->image);
pXFree(hwdata->image);
width = hwdata->image->pitches[0] / bpp;
hwdata->image = SDL_NAME(XvShmCreateImage)(GFX_Display, xv_port, format,
0, width, height, yuvshm);
......@@ -277,10 +277,10 @@ SDL_Overlay *X11_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, S
yuvshm->readOnly = False;
if ( yuvshm->shmaddr != (char *)-1 ) {
shm_error = False;
X_handler = XSetErrorHandler(shm_errhandler);
XShmAttach(GFX_Display, yuvshm);
XSync(GFX_Display, True);
XSetErrorHandler(X_handler);
X_handler = pXSetErrorHandler(shm_errhandler);
pXShmAttach(GFX_Display, yuvshm);
pXSync(GFX_Display, True);
pXSetErrorHandler(X_handler);
if ( shm_error )
shmdt(yuvshm->shmaddr);
} else {
......@@ -291,7 +291,7 @@ SDL_Overlay *X11_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, S
shm_error = True;
}
if ( shm_error ) {
XFree(hwdata->image);
pXFree(hwdata->image);
hwdata->yuv_use_mitshm = 0;
} else {
hwdata->image->data = yuvshm->shmaddr;
......@@ -306,7 +306,7 @@ SDL_Overlay *X11_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, S
#ifdef PITCH_WORKAROUND
if ( hwdata->image != NULL && hwdata->image->pitches[0] != (width*bpp) ) {
/* Ajust overlay width according to pitch */
XFree(hwdata->image);
pXFree(hwdata->image);
width = hwdata->image->pitches[0] / bpp;
hwdata->image = SDL_NAME(XvCreateImage)(GFX_Display, xv_port, format,
0, width, height);
......@@ -380,7 +380,7 @@ int X11_DisplayYUVOverlay(_THIS, SDL_Overlay *overlay, SDL_Rect *dstrect)
hwdata->image, 0, 0, overlay->w, overlay->h,
dstrect->x, dstrect->y, dstrect->w, dstrect->h);
}
XSync(GFX_Display, False);
pXSync(GFX_Display, False);
return(0);
}
......@@ -393,12 +393,12 @@ void X11_FreeYUVOverlay(_THIS, SDL_Overlay *overlay)
SDL_NAME(XvUngrabPort)(GFX_Display, hwdata->port, CurrentTime);
#ifndef NO_SHARED_MEMORY
if ( hwdata->yuv_use_mitshm ) {
XShmDetach(GFX_Display, &hwdata->yuvshm);
pXShmDetach(GFX_Display, &hwdata->yuvshm);
shmdt(hwdata->yuvshm.shmaddr);
}
#endif
if ( hwdata->image ) {
XFree(hwdata->image);
pXFree(hwdata->image);
}
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