From 2ab35016f7de84a7ca68e71bf5e1def4ad618819 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Thu, 12 Jan 2006 22:46:36 +0000 Subject: [PATCH] Add XME hooks to X11 driver instead of relying on libxme...libxme hasn't changed in five years, and it's a small .c file that just calls into the X11 dependencies we already use elsewhere. Including it directly allows us to make use of the dynamic X11 code. Fixes Bugzilla #41. --ryan. --- configure.in | 10 +- src/video/Xext/Makefile.am | 2 +- src/video/Xext/XME/Makefile.am | 6 + src/video/Xext/XME/xme.c | 397 ++++++++++++++++++++++++++ src/video/Xext/extensions/Makefile.am | 4 +- src/video/Xext/extensions/xme.h | 41 +++ src/video/x11/SDL_x11video.h | 2 +- 7 files changed, 450 insertions(+), 12 deletions(-) create mode 100644 src/video/Xext/XME/Makefile.am create mode 100644 src/video/Xext/XME/xme.c create mode 100644 src/video/Xext/extensions/xme.h diff --git a/configure.in b/configure.in index 0a5588926..9b1adbb77 100644 --- a/configure.in +++ b/configure.in @@ -760,19 +760,11 @@ CheckX11() , enable_video_x11_xme=yes) if test x$enable_video_x11_xme = xyes; then AC_MSG_CHECKING(for Xi Graphics XiGMiscExtension support) - video_x11_xme=no - AC_TRY_COMPILE([ - #include - #include - ],[ - XiGMiscResolutionInfo *resolutions; - ],[ video_x11_xme=yes - ]) AC_MSG_RESULT($video_x11_xme) if test x$video_x11_xme = xyes; then CFLAGS="$CFLAGS -DHAVE_XIGXME" - SYSTEM_LIBS="$SYSTEM_LIBS -lxme" + SYSTEM_LIBS="$SYSTEM_LIBS" fi fi fi diff --git a/src/video/Xext/Makefile.am b/src/video/Xext/Makefile.am index ed8fe24c0..21a7498be 100644 --- a/src/video/Xext/Makefile.am +++ b/src/video/Xext/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = extensions Xinerama Xv Xxf86dga Xxf86vm +SUBDIRS = extensions Xinerama Xv Xxf86dga Xxf86vm XME EXTRA_DIST = README diff --git a/src/video/Xext/XME/Makefile.am b/src/video/Xext/XME/Makefile.am new file mode 100644 index 000000000..a7f119363 --- /dev/null +++ b/src/video/Xext/XME/Makefile.am @@ -0,0 +1,6 @@ + +## Makefile.am for the XME library + +noinst_LTLIBRARIES = libXME.la +libXME_la_SOURCES = xme.c + diff --git a/src/video/Xext/XME/xme.c b/src/video/Xext/XME/xme.c new file mode 100644 index 000000000..332b76632 --- /dev/null +++ b/src/video/Xext/XME/xme.c @@ -0,0 +1,397 @@ +/* + * Copyright 1993-2001 by Xi Graphics, Inc. + * All Rights Reserved. + * + * Please see the LICENSE file accompanying this distribution for licensing + * information. + * + * Please send any bug fixes and modifications to src@xig.com. + * + * $XiGId: xme.c,v 1.2 2001/11/30 21:56:59 jon Exp $ + * + */ + +#define NEED_EVENTS +#define NEED_REPLIES + +#include +#include +#include +#include +#include +#include "extutil.h" + +#include "../../x11/SDL_x11dyn.h" + +/*****************************************************************************/ + + +#define XIGMISC_PROTOCOL_NAME "XiG-SUNDRY-NONSTANDARD" +#define XIGMISC_MAJOR_VERSION 2 +#define XIGMISC_MINOR_VERSION 0 + +#define XiGMiscNumberEvents 0 + +#define X_XiGMiscQueryVersion 0 +#define X_XiGMiscQueryViews 1 +#define X_XiGMiscQueryResolutions 2 +#define X_XiGMiscChangeResolution 3 +#define X_XiGMiscFullScreen 4 + +#define sz_xXiGMiscQueryVersionReq 8 +#define sz_xXiGMiscQueryViewsReq 8 +#define sz_xXiGMiscQueryResolutionsReq 8 +#define sz_xXiGMiscChangeResolutionReq 16 +#define sz_xXiGMiscFullScreenReq 16 + +#define sz_xXiGMiscQueryVersionReply 32 +#define sz_xXiGMiscQueryViewsReply 32 +#define sz_xXiGMiscQueryResolutionsReply 32 +#define sz_xXiGMiscQueryFullScreenReply 32 + +/*******************************************************************/ + +typedef struct { + CARD8 reqType; /* always codes->major_opcode */ + CARD8 xigmiscReqType; /* always X_XiGMiscQueryVersion */ + CARD16 length; + CARD16 major; + CARD16 minor; +} xXiGMiscQueryVersionReq; + +typedef struct { + CARD8 reqType; /* always codes->major_opcode */ + CARD8 xigmiscReqType; /* always X_XiGMiscQueryViews */ + CARD16 length; + CARD8 screen; + CARD8 pad0; + CARD16 pad1; +} xXiGMiscQueryViewsReq; + +typedef struct { + CARD8 reqType; /* always codes->major_opcode */ + CARD8 xigmiscReqType; /* always X_XiGMiscQueryResolutions */ + CARD16 length; + CARD8 screen; + CARD8 view; + CARD16 pad0; +} xXiGMiscQueryResolutionsReq; + +typedef struct { + CARD8 reqType; /* always codes->major_opcode */ + CARD8 xigmiscReqType; /* always X_XiGMiscChangeResolution */ + CARD16 length; + CARD8 screen; + CARD8 view; + CARD16 pad0; + CARD16 width; + CARD16 height; + INT32 refresh; +} xXiGMiscChangeResolutionReq; + +typedef struct { + CARD8 reqType; /* always codes->major_opcode */ + CARD8 xigmiscReqType; /* always X_XiGMiscFullScreen */ + CARD16 length; + CARD8 screen; + CARD8 pad0; + CARD16 pad1; + CARD32 window; + CARD32 cmap; +} xXiGMiscFullScreenReq; + +/*******************************************************************/ + +typedef struct { + BYTE type; /* X_Reply */ + CARD8 pad0; + CARD16 sequenceNumber; + CARD32 length; + CARD16 major; + CARD16 minor; + CARD32 pad1; + CARD32 pad2; + CARD32 pad3; + CARD32 pad4; + CARD32 pad5; +} xXiGMiscQueryVersionReply; + +typedef struct { + BYTE type; /* X_Reply */ + CARD8 pad0; + CARD16 sequenceNumber; + CARD32 length; + CARD32 nviews; + CARD32 pad1; + CARD32 pad2; + CARD32 pad3; + CARD32 pad4; + CARD32 pad5; +} xXiGMiscQueryViewsReply; + +typedef struct { + BYTE type; /* X_Reply */ + CARD8 pad0; + CARD16 sequenceNumber; + CARD32 length; + CARD16 active; + CARD16 nresolutions; + CARD32 pad1; + CARD32 pad2; + CARD32 pad3; + CARD32 pad4; + CARD32 pad5; +} xXiGMiscQueryResolutionsReply; + +typedef struct { + BYTE type; /* X_Reply */ + BOOL success; + CARD16 sequenceNumber; + CARD32 length; + CARD32 pad1; + CARD32 pad2; + CARD32 pad3; + CARD32 pad4; + CARD32 pad5; + CARD32 pad6; +} xXiGMiscFullScreenReply; + +/*******************************************************************/ + +typedef struct { + INT16 x; + INT16 y; + CARD16 w; + CARD16 h; +} XiGMiscViewInfo; + +typedef struct { + CARD16 width; + CARD16 height; + INT32 refresh; +} XiGMiscResolutionInfo; + +/*****************************************************************************/ + +static XExtensionInfo *xigmisc_info = NULL; +static char *xigmisc_extension_name = XIGMISC_PROTOCOL_NAME; + +#define XiGMiscCheckExtension(dpy,i,val) \ + XextCheckExtension (dpy, i, xigmisc_extension_name, val) +#define XiGMiscSimpleCheckExtension(dpy,i) \ + XextSimpleCheckExtension (dpy, i, xigmisc_extension_name) + +#if defined(__STDC__) && !defined(UNIXCPP) +#define XiGMiscGetReq(name,req,info) GetReq (name, req); \ + req->reqType = info->codes->major_opcode; \ + req->xigmiscReqType = X_##name; + +#define XiGMiscGetReqExtra(name,n,req,info) GetReqExtra (name, n, req); \ + req->reqType = info->codes->major_opcode; \ + req->xigmicReqType = X_##name; +#else +#define XiGMiscGetReq(name,req,info) GetReq (name, req); \ + req->reqType = info->codes->major_opcode; \ + req->xigmiscReqType = X_/**/name; +#define XiGMiscGetReqExtra(name,n,req,info) GetReqExtra (name, n, req); \ + req->reqType = info->codes->major_opcode; \ + req->xigmiscReqType = X_/**/name; +#endif + + + +/* + * find_display - locate the display info block + */ +static int XiGMiscCloseDisplay(); + +static XExtensionHooks xigmisc_extension_hooks = { + NULL, /* create_gc */ + NULL, /* copy_gc */ + NULL, /* flush_gc */ + NULL, /* free_gc */ + NULL, /* create_font */ + NULL, /* free_font */ + XiGMiscCloseDisplay, /* close_display */ + NULL, /* wire_to_event */ + NULL, /* event_to_wire */ + NULL, /* error */ + NULL, /* error_string */ +}; + + +static XEXT_GENERATE_CLOSE_DISPLAY (XiGMiscCloseDisplay, xigmisc_info) + +static XEXT_GENERATE_FIND_DISPLAY (XiGMiscFindDisplay, xigmisc_info, + xigmisc_extension_name, + &xigmisc_extension_hooks, XiGMiscNumberEvents, NULL) + + +/*****************************************************************************/ + +Bool XiGMiscQueryVersion(Display *dpy, int *major, int *minor) +{ + int opcode, event, error; + xXiGMiscQueryVersionReq *req; + xXiGMiscQueryVersionReply rep; + XExtDisplayInfo *info = XiGMiscFindDisplay(dpy); + + if (!pXQueryExtension(dpy, XIGMISC_PROTOCOL_NAME, &opcode, &event, &error)) + return xFalse; + + XiGMiscCheckExtension(dpy, info, xFalse); + + LockDisplay (dpy); + XiGMiscGetReq (XiGMiscQueryVersion, req, info); + + req->major = XIGMISC_MAJOR_VERSION; + req->minor = XIGMISC_MINOR_VERSION; + + if (!p_XReply (dpy, (xReply *)&rep, 0, xTrue)) { + UnlockDisplay(dpy); + SyncHandle(); + return xFalse; + } + + *major = rep.major; + *minor = rep.minor; + UnlockDisplay(dpy); + SyncHandle(); + + return xTrue; +} + +int XiGMiscQueryViews(Display *dpy, int screen, XiGMiscViewInfo **pviews) +{ + int n, size; + XiGMiscViewInfo *views; + xXiGMiscQueryViewsReq *req; + xXiGMiscQueryViewsReply rep; + XExtDisplayInfo *info = XiGMiscFindDisplay(dpy); + XiGMiscCheckExtension(dpy, info, 0); + + LockDisplay (dpy); + XiGMiscGetReq (XiGMiscQueryViews, req, info); + req->screen = screen; + + if (!p_XReply (dpy, (xReply *)&rep, 0, xFalse)) { + UnlockDisplay(dpy); + SyncHandle(); + return 0; + } + + n = rep.nviews; + + if (n > 0) { + size = sizeof(XiGMiscViewInfo) * n; + views = (XiGMiscViewInfo*)Xmalloc(size); + if (!views) { + p_XEatData(dpy, (unsigned long)size); + UnlockDisplay(dpy); + SyncHandle(); + return 0; + } + + p_XReadPad(dpy, (void*)views, size); + + *pviews = views; + } + + UnlockDisplay(dpy); + SyncHandle(); + + return n; +} + +int XiGMiscQueryResolutions(Display *dpy, int screen, int view, int *pactive, XiGMiscResolutionInfo **presolutions) +{ + int n, size; + XiGMiscResolutionInfo *resolutions; + xXiGMiscQueryResolutionsReq *req; + xXiGMiscQueryResolutionsReply rep; + XExtDisplayInfo *info = XiGMiscFindDisplay(dpy); + XiGMiscCheckExtension(dpy, info, 0); + + LockDisplay (dpy); + XiGMiscGetReq (XiGMiscQueryResolutions, req, info); + req->screen = screen; + req->view = view; + + if (!p_XReply (dpy, (xReply *)&rep, 0, xFalse)) { + UnlockDisplay(dpy); + SyncHandle(); + return 0; + } + + n = rep.nresolutions; + + if (n > 0) { + size = sizeof(XiGMiscResolutionInfo) * n; + resolutions = (XiGMiscResolutionInfo*)Xmalloc(size); + if (!resolutions) { + p_XEatData(dpy, (unsigned long)size); + UnlockDisplay(dpy); + SyncHandle(); + return 0; + } + + p_XReadPad(dpy, (void*)resolutions, size); + + *presolutions = resolutions; + *pactive = rep.active; + } + + UnlockDisplay(dpy); + SyncHandle(); + + return n; +} + +void XiGMiscChangeResolution(Display *dpy, int screen, int view, int width, int height, int refresh) +{ + xXiGMiscChangeResolutionReq *req; + XExtDisplayInfo *info = XiGMiscFindDisplay(dpy); + + XiGMiscSimpleCheckExtension(dpy, info); + + LockDisplay (dpy); + XiGMiscGetReq (XiGMiscChangeResolution, req, info); + req->screen = screen; + req->view = view; + req->width = width; + req->height = height; + req->refresh = refresh; + + UnlockDisplay(dpy); + SyncHandle(); +} + + +Bool XiGMiscFullScreen(Display *dpy, int screen, XID window, XID cmap) +{ + xXiGMiscFullScreenReq *req; + xXiGMiscFullScreenReply rep; + XExtDisplayInfo *info = XiGMiscFindDisplay(dpy); + + XiGMiscCheckExtension(dpy, info, xFalse); + + LockDisplay (dpy); + XiGMiscGetReq (XiGMiscFullScreen, req, info); + req->screen = screen; + req->pad0 = 0; + req->pad1 = 0; + req->window = window; + req->cmap = cmap; + + if (!p_XReply (dpy, (xReply *)&rep, 0, xTrue)) { + UnlockDisplay(dpy); + SyncHandle(); + return xFalse; + } + + UnlockDisplay(dpy); + SyncHandle(); + + return (rep.success ? xTrue : xFalse); +} + diff --git a/src/video/Xext/extensions/Makefile.am b/src/video/Xext/extensions/Makefile.am index 591d0a3c3..eae168ee5 100644 --- a/src/video/Xext/extensions/Makefile.am +++ b/src/video/Xext/extensions/Makefile.am @@ -12,4 +12,6 @@ noinst_HEADERS = \ Xinerama.h \ Xv.h \ Xvlib.h \ - Xvproto.h + Xvproto.h \ + xme.h + diff --git a/src/video/Xext/extensions/xme.h b/src/video/Xext/extensions/xme.h new file mode 100644 index 000000000..41bb416ad --- /dev/null +++ b/src/video/Xext/extensions/xme.h @@ -0,0 +1,41 @@ +/* + * Copyright 1993-2001 by Xi Graphics, Inc. + * All Rights Reserved. + * + * Please see the LICENSE file accompanying this distribution for licensing + * information. + * + * Please send any bug fixes and modifications to src@xig.com. + * + * $XiGId: xme.h,v 1.1.1.1 2001/11/19 19:01:10 jon Exp $ + * + */ + + +#ifndef _XME_H_INCLUDED +#define _XME_H_INCLUDED + +typedef struct { + short x; + short y; + unsigned short w; + unsigned short h; +} XiGMiscViewInfo; + +typedef struct { + unsigned short width; + unsigned short height; + int refresh; +} XiGMiscResolutionInfo; + +extern Bool XiGMiscQueryVersion(Display *dpy, int *major, int *minor); +extern int XiGMiscQueryViews(Display *dpy, int screen, + XiGMiscViewInfo **pviews); +extern int XiGMiscQueryResolutions(Display *dpy, int screen, int view, + int *pactive, + XiGMiscResolutionInfo **presolutions); +extern void XiGMiscChangeResolution(Display *dpy, int screen, int view, + int width, int height, int refresh); +#endif /* _XME_H_INCLUDED */ + + diff --git a/src/video/x11/SDL_x11video.h b/src/video/x11/SDL_x11video.h index 524c65226..b4c520c53 100644 --- a/src/video/x11/SDL_x11video.h +++ b/src/video/x11/SDL_x11video.h @@ -39,7 +39,7 @@ static char rcsid = #include #endif #ifdef HAVE_XIGXME -#include +#include #endif #include