Add XME hooks to X11 driver instead of relying on libxme...libxme hasn't
authorRyan C. Gordon <icculus@icculus.org>
Thu, 12 Jan 2006 22:46:36 +0000
changeset 1242caf0328c8058
parent 1241 4b2146866b82
child 1243 08c730212ca2
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
src/video/Xext/Makefile.am
src/video/Xext/XME/Makefile.am
src/video/Xext/XME/xme.c
src/video/Xext/extensions/Makefile.am
src/video/Xext/extensions/xme.h
src/video/x11/SDL_x11video.h
     1.1 --- a/configure.in	Tue Jan 10 20:52:35 2006 +0000
     1.2 +++ b/configure.in	Thu Jan 12 22:46:36 2006 +0000
     1.3 @@ -760,19 +760,11 @@
     1.4                              , enable_video_x11_xme=yes)
     1.5              if test x$enable_video_x11_xme = xyes; then
     1.6                  AC_MSG_CHECKING(for Xi Graphics XiGMiscExtension support)
     1.7 -                video_x11_xme=no
     1.8 -                AC_TRY_COMPILE([
     1.9 -                 #include <X11/Xlib.h>
    1.10 -                 #include <X11/extensions/xme.h>
    1.11 -                ],[
    1.12 -                 XiGMiscResolutionInfo *resolutions;
    1.13 -                ],[
    1.14                  video_x11_xme=yes
    1.15 -                ])
    1.16                  AC_MSG_RESULT($video_x11_xme)
    1.17                  if test x$video_x11_xme = xyes; then
    1.18                      CFLAGS="$CFLAGS -DHAVE_XIGXME"
    1.19 -                    SYSTEM_LIBS="$SYSTEM_LIBS -lxme"
    1.20 +                    SYSTEM_LIBS="$SYSTEM_LIBS"
    1.21                  fi
    1.22              fi
    1.23          fi
     2.1 --- a/src/video/Xext/Makefile.am	Tue Jan 10 20:52:35 2006 +0000
     2.2 +++ b/src/video/Xext/Makefile.am	Thu Jan 12 22:46:36 2006 +0000
     2.3 @@ -1,4 +1,4 @@
     2.4  
     2.5 -SUBDIRS = extensions Xinerama Xv Xxf86dga Xxf86vm
     2.6 +SUBDIRS = extensions Xinerama Xv Xxf86dga Xxf86vm XME
     2.7  
     2.8  EXTRA_DIST = README
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/src/video/Xext/XME/Makefile.am	Thu Jan 12 22:46:36 2006 +0000
     3.3 @@ -0,0 +1,6 @@
     3.4 +
     3.5 +## Makefile.am for the XME library
     3.6 +
     3.7 +noinst_LTLIBRARIES = libXME.la
     3.8 +libXME_la_SOURCES = xme.c
     3.9 +
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/src/video/Xext/XME/xme.c	Thu Jan 12 22:46:36 2006 +0000
     4.3 @@ -0,0 +1,397 @@
     4.4 +/*
     4.5 + * Copyright 1993-2001 by Xi Graphics, Inc.
     4.6 + * All Rights Reserved.
     4.7 + *
     4.8 + * Please see the LICENSE file accompanying this distribution for licensing 
     4.9 + * information. 
    4.10 + *
    4.11 + * Please send any bug fixes and modifications to src@xig.com.
    4.12 + *
    4.13 + * $XiGId: xme.c,v 1.2 2001/11/30 21:56:59 jon Exp $
    4.14 + *
    4.15 + */
    4.16 +
    4.17 +#define NEED_EVENTS
    4.18 +#define NEED_REPLIES
    4.19 +
    4.20 +#include <X11/Xlibint.h>
    4.21 +#include <X11/Xthreads.h>
    4.22 +#include <X11/Xmd.h>
    4.23 +#include <X11/Xproto.h>
    4.24 +#include <X11/extensions/Xext.h>
    4.25 +#include "extutil.h"
    4.26 +
    4.27 +#include "../../x11/SDL_x11dyn.h"
    4.28 +
    4.29 +/*****************************************************************************/
    4.30 +
    4.31 +
    4.32 +#define	XIGMISC_PROTOCOL_NAME 		     "XiG-SUNDRY-NONSTANDARD"
    4.33 +#define XIGMISC_MAJOR_VERSION	             2
    4.34 +#define XIGMISC_MINOR_VERSION 	             0
    4.35 +
    4.36 +#define XiGMiscNumberEvents	             0
    4.37 +
    4.38 +#define	X_XiGMiscQueryVersion		     0
    4.39 +#define	X_XiGMiscQueryViews		     1
    4.40 +#define X_XiGMiscQueryResolutions            2
    4.41 +#define X_XiGMiscChangeResolution            3
    4.42 +#define X_XiGMiscFullScreen                  4
    4.43 +
    4.44 +#define sz_xXiGMiscQueryVersionReq	     8
    4.45 +#define sz_xXiGMiscQueryViewsReq	     8
    4.46 +#define sz_xXiGMiscQueryResolutionsReq       8
    4.47 +#define sz_xXiGMiscChangeResolutionReq       16
    4.48 +#define sz_xXiGMiscFullScreenReq             16
    4.49 +
    4.50 +#define sz_xXiGMiscQueryVersionReply	     32
    4.51 +#define sz_xXiGMiscQueryViewsReply	     32
    4.52 +#define sz_xXiGMiscQueryResolutionsReply     32
    4.53 +#define sz_xXiGMiscQueryFullScreenReply      32
    4.54 +
    4.55 +/*******************************************************************/
    4.56 +
    4.57 +typedef struct {
    4.58 +  CARD8         reqType;                /* always codes->major_opcode        */
    4.59 +  CARD8         xigmiscReqType;         /* always X_XiGMiscQueryVersion      */
    4.60 +  CARD16        length;
    4.61 +  CARD16        major;
    4.62 +  CARD16        minor;
    4.63 +} xXiGMiscQueryVersionReq;
    4.64 +
    4.65 +typedef struct {
    4.66 +  CARD8         reqType;                /* always codes->major_opcode        */
    4.67 +  CARD8         xigmiscReqType;         /* always X_XiGMiscQueryViews        */
    4.68 +  CARD16        length;
    4.69 +  CARD8		screen;
    4.70 +  CARD8		pad0;
    4.71 +  CARD16	pad1;
    4.72 +} xXiGMiscQueryViewsReq;
    4.73 +
    4.74 +typedef struct {
    4.75 +  CARD8         reqType;                /* always codes->major_opcode        */
    4.76 +  CARD8         xigmiscReqType;         /* always X_XiGMiscQueryResolutions  */
    4.77 +  CARD16        length;
    4.78 +  CARD8		screen;
    4.79 +  CARD8		view;
    4.80 +  CARD16	pad0;
    4.81 +} xXiGMiscQueryResolutionsReq;
    4.82 +
    4.83 +typedef struct {
    4.84 +  CARD8         reqType;                /* always codes->major_opcode        */
    4.85 +  CARD8         xigmiscReqType;         /* always X_XiGMiscChangeResolution  */
    4.86 +  CARD16        length;
    4.87 +  CARD8		screen;
    4.88 +  CARD8		view;
    4.89 +  CARD16	pad0;
    4.90 +  CARD16        width;
    4.91 +  CARD16        height;
    4.92 +  INT32         refresh;
    4.93 +} xXiGMiscChangeResolutionReq;
    4.94 +
    4.95 +typedef struct {
    4.96 +  CARD8         reqType;                /* always codes->major_opcode        */
    4.97 +  CARD8         xigmiscReqType;         /* always X_XiGMiscFullScreen        */
    4.98 +  CARD16        length;
    4.99 +  CARD8		screen;
   4.100 +  CARD8		pad0;
   4.101 +  CARD16	pad1;
   4.102 +  CARD32	window;
   4.103 +  CARD32	cmap;
   4.104 +} xXiGMiscFullScreenReq;
   4.105 +
   4.106 +/*******************************************************************/
   4.107 +
   4.108 +typedef struct {        
   4.109 +  BYTE          type;                   /* X_Reply                           */
   4.110 +  CARD8         pad0;
   4.111 +  CARD16        sequenceNumber;
   4.112 +  CARD32        length;
   4.113 +  CARD16        major;
   4.114 +  CARD16        minor;
   4.115 +  CARD32        pad1;
   4.116 +  CARD32        pad2;
   4.117 +  CARD32        pad3;
   4.118 +  CARD32        pad4;
   4.119 +  CARD32        pad5;
   4.120 +} xXiGMiscQueryVersionReply;
   4.121 +
   4.122 +typedef struct {        
   4.123 +  BYTE          type;                   /* X_Reply                           */
   4.124 +  CARD8         pad0;
   4.125 +  CARD16        sequenceNumber;
   4.126 +  CARD32        length;
   4.127 +  CARD32        nviews;
   4.128 +  CARD32        pad1;
   4.129 +  CARD32        pad2;
   4.130 +  CARD32        pad3;
   4.131 +  CARD32        pad4;
   4.132 +  CARD32        pad5;
   4.133 +} xXiGMiscQueryViewsReply;
   4.134 +
   4.135 +typedef struct {        
   4.136 +  BYTE          type;                   /* X_Reply                           */
   4.137 +  CARD8         pad0;
   4.138 +  CARD16        sequenceNumber;
   4.139 +  CARD32        length;
   4.140 +  CARD16        active;
   4.141 +  CARD16        nresolutions;
   4.142 +  CARD32        pad1;
   4.143 +  CARD32        pad2;
   4.144 +  CARD32        pad3;
   4.145 +  CARD32        pad4;
   4.146 +  CARD32        pad5;
   4.147 +} xXiGMiscQueryResolutionsReply;
   4.148 +
   4.149 +typedef struct {        
   4.150 +  BYTE          type;                   /* X_Reply                           */
   4.151 +  BOOL          success;
   4.152 +  CARD16        sequenceNumber;
   4.153 +  CARD32        length;
   4.154 +  CARD32        pad1;
   4.155 +  CARD32        pad2;
   4.156 +  CARD32        pad3;
   4.157 +  CARD32        pad4;
   4.158 +  CARD32        pad5;
   4.159 +  CARD32        pad6;
   4.160 +} xXiGMiscFullScreenReply;
   4.161 +
   4.162 +/*******************************************************************/
   4.163 +
   4.164 +typedef struct {        
   4.165 +  INT16		x;
   4.166 +  INT16		y;
   4.167 +  CARD16	w;
   4.168 +  CARD16	h;
   4.169 +} XiGMiscViewInfo;
   4.170 +
   4.171 +typedef struct {        
   4.172 +  CARD16        width;
   4.173 +  CARD16        height;
   4.174 +  INT32         refresh;
   4.175 +} XiGMiscResolutionInfo;
   4.176 +
   4.177 +/*****************************************************************************/
   4.178 +
   4.179 +static XExtensionInfo *xigmisc_info = NULL;
   4.180 +static char *xigmisc_extension_name = XIGMISC_PROTOCOL_NAME;
   4.181 +
   4.182 +#define XiGMiscCheckExtension(dpy,i,val) \
   4.183 +  XextCheckExtension (dpy, i, xigmisc_extension_name, val)
   4.184 +#define XiGMiscSimpleCheckExtension(dpy,i) \
   4.185 +  XextSimpleCheckExtension (dpy, i, xigmisc_extension_name)
   4.186 +
   4.187 +#if defined(__STDC__) && !defined(UNIXCPP)
   4.188 +#define XiGMiscGetReq(name,req,info) GetReq (name, req); \
   4.189 +        req->reqType = info->codes->major_opcode; \
   4.190 +        req->xigmiscReqType = X_##name;
   4.191 +
   4.192 +#define XiGMiscGetReqExtra(name,n,req,info) GetReqExtra (name, n, req); \
   4.193 +        req->reqType = info->codes->major_opcode; \
   4.194 +        req->xigmicReqType = X_##name;
   4.195 +#else
   4.196 +#define XiGMiscGetReq(name,req,info) GetReq (name, req); \
   4.197 +        req->reqType = info->codes->major_opcode; \
   4.198 +        req->xigmiscReqType = X_/**/name;
   4.199 +#define XiGMiscGetReqExtra(name,n,req,info) GetReqExtra (name, n, req); \
   4.200 +        req->reqType = info->codes->major_opcode; \
   4.201 +        req->xigmiscReqType = X_/**/name;
   4.202 +#endif
   4.203 +
   4.204 +
   4.205 +
   4.206 +/*
   4.207 + * find_display - locate the display info block
   4.208 + */
   4.209 +static int XiGMiscCloseDisplay();
   4.210 +
   4.211 +static XExtensionHooks xigmisc_extension_hooks = {
   4.212 +    NULL,                               /* create_gc */
   4.213 +    NULL,                               /* copy_gc */
   4.214 +    NULL,                               /* flush_gc */
   4.215 +    NULL,                               /* free_gc */
   4.216 +    NULL,                               /* create_font */
   4.217 +    NULL,                               /* free_font */
   4.218 +    XiGMiscCloseDisplay,                /* close_display */
   4.219 +    NULL,                               /* wire_to_event */
   4.220 +    NULL,                               /* event_to_wire */
   4.221 +    NULL,                               /* error */
   4.222 +    NULL,                               /* error_string */
   4.223 +};
   4.224 +
   4.225 +
   4.226 +static XEXT_GENERATE_CLOSE_DISPLAY (XiGMiscCloseDisplay, xigmisc_info)
   4.227 +
   4.228 +static XEXT_GENERATE_FIND_DISPLAY (XiGMiscFindDisplay, xigmisc_info,
   4.229 +				   xigmisc_extension_name, 
   4.230 +				   &xigmisc_extension_hooks, XiGMiscNumberEvents, NULL)
   4.231 +
   4.232 +
   4.233 +/*****************************************************************************/
   4.234 +
   4.235 +Bool XiGMiscQueryVersion(Display *dpy, int *major, int *minor)
   4.236 +{
   4.237 +  int opcode, event, error;
   4.238 +  xXiGMiscQueryVersionReq *req;
   4.239 +  xXiGMiscQueryVersionReply rep;
   4.240 +  XExtDisplayInfo *info = XiGMiscFindDisplay(dpy);
   4.241 +
   4.242 +  if (!pXQueryExtension(dpy, XIGMISC_PROTOCOL_NAME, &opcode, &event, &error))
   4.243 +    return xFalse;
   4.244 +
   4.245 +  XiGMiscCheckExtension(dpy, info, xFalse);
   4.246 +
   4.247 +  LockDisplay (dpy);
   4.248 +  XiGMiscGetReq (XiGMiscQueryVersion, req, info);
   4.249 +
   4.250 +  req->major = XIGMISC_MAJOR_VERSION;
   4.251 +  req->minor = XIGMISC_MINOR_VERSION;
   4.252 +
   4.253 +  if (!p_XReply (dpy, (xReply *)&rep, 0, xTrue)) {
   4.254 +    UnlockDisplay(dpy);
   4.255 +    SyncHandle();
   4.256 +    return xFalse;
   4.257 +  }
   4.258 +
   4.259 +  *major = rep.major;
   4.260 +  *minor = rep.minor;
   4.261 +  UnlockDisplay(dpy);
   4.262 +  SyncHandle();
   4.263 +
   4.264 +  return xTrue;
   4.265 +}
   4.266 +
   4.267 +int XiGMiscQueryViews(Display *dpy, int screen, XiGMiscViewInfo **pviews)
   4.268 +{
   4.269 +  int n, size;
   4.270 +  XiGMiscViewInfo *views;
   4.271 +  xXiGMiscQueryViewsReq *req;
   4.272 +  xXiGMiscQueryViewsReply rep;
   4.273 +  XExtDisplayInfo *info = XiGMiscFindDisplay(dpy);
   4.274 +  XiGMiscCheckExtension(dpy, info, 0);
   4.275 +
   4.276 +  LockDisplay (dpy);
   4.277 +  XiGMiscGetReq (XiGMiscQueryViews, req, info);
   4.278 +  req->screen = screen;
   4.279 +
   4.280 +  if (!p_XReply (dpy, (xReply *)&rep, 0, xFalse)) {
   4.281 +    UnlockDisplay(dpy);
   4.282 +    SyncHandle();
   4.283 +    return 0;
   4.284 +  }
   4.285 +
   4.286 +  n = rep.nviews;
   4.287 +
   4.288 +  if (n > 0) {
   4.289 +    size = sizeof(XiGMiscViewInfo) * n;
   4.290 +    views = (XiGMiscViewInfo*)Xmalloc(size);
   4.291 +    if (!views) {
   4.292 +      p_XEatData(dpy, (unsigned long)size);
   4.293 +      UnlockDisplay(dpy);
   4.294 +      SyncHandle();
   4.295 +      return 0;
   4.296 +    }
   4.297 +
   4.298 +    p_XReadPad(dpy, (void*)views, size);
   4.299 +
   4.300 +    *pviews = views;
   4.301 +  }
   4.302 +
   4.303 +  UnlockDisplay(dpy);
   4.304 +  SyncHandle();
   4.305 +
   4.306 +  return n;
   4.307 +}
   4.308 +
   4.309 +int XiGMiscQueryResolutions(Display *dpy, int screen, int view, int *pactive, XiGMiscResolutionInfo **presolutions)
   4.310 +{
   4.311 +  int n, size;
   4.312 +  XiGMiscResolutionInfo *resolutions;
   4.313 +  xXiGMiscQueryResolutionsReq *req;
   4.314 +  xXiGMiscQueryResolutionsReply rep;
   4.315 +  XExtDisplayInfo *info = XiGMiscFindDisplay(dpy);
   4.316 +  XiGMiscCheckExtension(dpy, info, 0);
   4.317 +
   4.318 +  LockDisplay (dpy);
   4.319 +  XiGMiscGetReq (XiGMiscQueryResolutions, req, info);
   4.320 +  req->screen = screen;
   4.321 +  req->view   = view;
   4.322 +
   4.323 +  if (!p_XReply (dpy, (xReply *)&rep, 0, xFalse)) {
   4.324 +    UnlockDisplay(dpy);
   4.325 +    SyncHandle();
   4.326 +    return 0;
   4.327 +  }
   4.328 +
   4.329 +  n = rep.nresolutions;
   4.330 +
   4.331 +  if (n > 0) {
   4.332 +    size = sizeof(XiGMiscResolutionInfo) * n;
   4.333 +    resolutions = (XiGMiscResolutionInfo*)Xmalloc(size);
   4.334 +    if (!resolutions) {
   4.335 +      p_XEatData(dpy, (unsigned long)size);
   4.336 +      UnlockDisplay(dpy);
   4.337 +      SyncHandle();
   4.338 +      return 0;
   4.339 +    }
   4.340 +
   4.341 +    p_XReadPad(dpy, (void*)resolutions, size);
   4.342 +
   4.343 +    *presolutions = resolutions;
   4.344 +    *pactive = rep.active;
   4.345 +  }
   4.346 +
   4.347 +  UnlockDisplay(dpy);
   4.348 +  SyncHandle();
   4.349 +
   4.350 +  return n;
   4.351 +}
   4.352 +
   4.353 +void XiGMiscChangeResolution(Display *dpy, int screen, int view, int width, int height, int refresh)
   4.354 +{
   4.355 +  xXiGMiscChangeResolutionReq *req;
   4.356 +  XExtDisplayInfo *info = XiGMiscFindDisplay(dpy);
   4.357 +
   4.358 +  XiGMiscSimpleCheckExtension(dpy, info);
   4.359 +
   4.360 +  LockDisplay (dpy);
   4.361 +  XiGMiscGetReq (XiGMiscChangeResolution, req, info);
   4.362 +  req->screen = screen;
   4.363 +  req->view = view;
   4.364 +  req->width = width;
   4.365 +  req->height = height;
   4.366 +  req->refresh = refresh;
   4.367 +
   4.368 +  UnlockDisplay(dpy);
   4.369 +  SyncHandle();
   4.370 +}
   4.371 +
   4.372 +
   4.373 +Bool XiGMiscFullScreen(Display *dpy, int screen, XID window, XID cmap)
   4.374 +{
   4.375 +  xXiGMiscFullScreenReq *req;
   4.376 +  xXiGMiscFullScreenReply rep;
   4.377 +  XExtDisplayInfo *info = XiGMiscFindDisplay(dpy);
   4.378 +
   4.379 +  XiGMiscCheckExtension(dpy, info, xFalse);
   4.380 +
   4.381 +  LockDisplay (dpy);
   4.382 +  XiGMiscGetReq (XiGMiscFullScreen, req, info);
   4.383 +  req->screen = screen;
   4.384 +  req->pad0 = 0;
   4.385 +  req->pad1 = 0;
   4.386 +  req->window = window;
   4.387 +  req->cmap = cmap;
   4.388 +
   4.389 +  if (!p_XReply (dpy, (xReply *)&rep, 0, xTrue)) {
   4.390 +    UnlockDisplay(dpy);
   4.391 +    SyncHandle();
   4.392 +    return xFalse;
   4.393 +  }
   4.394 +
   4.395 +  UnlockDisplay(dpy);
   4.396 +  SyncHandle();
   4.397 +
   4.398 +  return (rep.success ? xTrue : xFalse);
   4.399 +}
   4.400 +
     5.1 --- a/src/video/Xext/extensions/Makefile.am	Tue Jan 10 20:52:35 2006 +0000
     5.2 +++ b/src/video/Xext/extensions/Makefile.am	Thu Jan 12 22:46:36 2006 +0000
     5.3 @@ -12,4 +12,6 @@
     5.4  	Xinerama.h	\
     5.5  	Xv.h		\
     5.6  	Xvlib.h		\
     5.7 -	Xvproto.h
     5.8 +	Xvproto.h	\
     5.9 +	xme.h
    5.10 +
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/src/video/Xext/extensions/xme.h	Thu Jan 12 22:46:36 2006 +0000
     6.3 @@ -0,0 +1,41 @@
     6.4 +/*
     6.5 + * Copyright 1993-2001 by Xi Graphics, Inc.
     6.6 + * All Rights Reserved.
     6.7 + *
     6.8 + * Please see the LICENSE file accompanying this distribution for licensing 
     6.9 + * information. 
    6.10 + *
    6.11 + * Please send any bug fixes and modifications to src@xig.com.
    6.12 + *
    6.13 + * $XiGId: xme.h,v 1.1.1.1 2001/11/19 19:01:10 jon Exp $
    6.14 + *
    6.15 + */
    6.16 +
    6.17 +
    6.18 +#ifndef _XME_H_INCLUDED 
    6.19 +#define _XME_H_INCLUDED
    6.20 +
    6.21 +typedef struct {        
    6.22 +  short		        x;
    6.23 +  short		        y;
    6.24 +  unsigned short	w;
    6.25 +  unsigned short	h;
    6.26 +} XiGMiscViewInfo;
    6.27 +
    6.28 +typedef struct {        
    6.29 +  unsigned short        width;
    6.30 +  unsigned short        height;
    6.31 +  int                   refresh;
    6.32 +} XiGMiscResolutionInfo;
    6.33 +
    6.34 +extern Bool XiGMiscQueryVersion(Display *dpy, int *major, int *minor);
    6.35 +extern int XiGMiscQueryViews(Display *dpy, int screen, 
    6.36 +			     XiGMiscViewInfo **pviews);
    6.37 +extern int XiGMiscQueryResolutions(Display *dpy, int screen, int view, 
    6.38 +			    int *pactive, 
    6.39 +			    XiGMiscResolutionInfo **presolutions);
    6.40 +extern void XiGMiscChangeResolution(Display *dpy, int screen, int view, 
    6.41 +			     int width, int height, int refresh);
    6.42 +#endif /* _XME_H_INCLUDED */
    6.43 +
    6.44 +
     7.1 --- a/src/video/x11/SDL_x11video.h	Tue Jan 10 20:52:35 2006 +0000
     7.2 +++ b/src/video/x11/SDL_x11video.h	Thu Jan 12 22:46:36 2006 +0000
     7.3 @@ -39,7 +39,7 @@
     7.4  #include <XFree86/extensions/xf86vmode.h>
     7.5  #endif
     7.6  #ifdef HAVE_XIGXME
     7.7 -#include <X11/extensions/xme.h>
     7.8 +#include <XFree86/extensions/xme.h>
     7.9  #endif
    7.10  
    7.11  #include <string.h>