diff src/video/Xext/Xxf86dga/XF86DGA2.c @ 1168:045f186426e1

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.
author Ryan C. Gordon <icculus@icculus.org>
date Sat, 05 Nov 2005 19:53:37 +0000
parents f1b029d3b301
children dd2a8deeb26d
line wrap: on
line diff
--- a/src/video/Xext/Xxf86dga/XF86DGA2.c	Sat Nov 05 17:41:11 2005 +0000
+++ b/src/video/Xext/Xxf86dga/XF86DGA2.c	Sat Nov 05 19:53:37 2005 +0000
@@ -28,6 +28,14 @@
 #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 @@
   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 @@
   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 @@
   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 @@
     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 @@
 	     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 @@
     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 @@
 
     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 @@
     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 @@
 
 	   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 @@
 		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 @@
     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 @@
 	   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 @@
 		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 @@
     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 @@
     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 @@
     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);