diff src/video/x11/SDL_x11image.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 26a0e2d69d39
children c9b51268668f
line wrap: on
line diff
--- a/src/video/x11/SDL_x11image.c	Sat Nov 05 17:41:11 2005 +0000
+++ b/src/video/x11/SDL_x11image.c	Sat Nov 05 19:53:37 2005 +0000
@@ -35,9 +35,6 @@
 
 #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 @@
 		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 @@
 #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 @@
 			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 @@
 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 @@
 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 @@
 		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 @@
 		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 @@
 	}
 #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);
 }