diff src/video/x11/SDL_x11wm.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 3acd16ea0180
children c9b51268668f
line wrap: on
line diff
--- a/src/video/x11/SDL_x11wm.c	Sat Nov 05 17:41:11 2005 +0000
+++ b/src/video/x11/SDL_x11wm.c	Sat Nov 05 19:53:37 2005 +0000
@@ -123,7 +123,7 @@
 					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 @@
 			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 @@
 			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 @@
 	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 @@
 				  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 @@
 	   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 @@
 		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 @@
 	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 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 @@
 		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 @@
 #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 @@
 			/* 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 @@
 {
 	/* 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)