Fixed bug #197
authorSam Lantinga
Mon, 17 Apr 2006 04:54:08 +0000
changeset 16415cf11b00b900
parent 1640 5eaab017cc28
child 1642 f1211a4b7380
Fixed bug #197

On servers with the composite extension enabled, visuals with 32-bit depth
have an alpha mask. This is pretty neat, but SDL needs a bit more work to
handle these properly, so for now, we'll just use 24 bit depth visuals.
src/video/x11/SDL_x11modes.c
src/video/x11/SDL_x11video.c
     1.1 --- a/src/video/x11/SDL_x11modes.c	Mon Apr 17 03:58:29 2006 +0000
     1.2 +++ b/src/video/x11/SDL_x11modes.c	Mon Apr 17 04:54:08 2006 +0000
     1.3 @@ -620,7 +620,11 @@
     1.4  #endif /* SDL_VIDEO_DRIVER_X11_XME */
     1.5  
     1.6      {
     1.7 +	/* It's interesting to note that if we allow 32 bit depths,
     1.8 +	   we get a visual with an alpha mask on composite servers.
     1.9          static int depth_list[] = { 32, 24, 16, 15, 8 };
    1.10 +	*/
    1.11 +        static int depth_list[] = { 24, 16, 15, 8 };
    1.12          int j, np;
    1.13          int use_directcolor = 1;
    1.14          XPixmapFormatValues *pf;
     2.1 --- a/src/video/x11/SDL_x11video.c	Mon Apr 17 03:58:29 2006 +0000
     2.2 +++ b/src/video/x11/SDL_x11video.c	Mon Apr 17 04:54:08 2006 +0000
     2.3 @@ -557,6 +557,9 @@
     2.4  	  	vformat->Gmask = SDL_Visual->green_mask;
     2.5  	  	vformat->Bmask = SDL_Visual->blue_mask;
     2.6  	}
     2.7 +	if ( this->hidden->depth == 32 ) {
     2.8 +		vformat->Amask = (0xFFFFFFFF & ~(vformat->Rmask|vformat->Gmask|vformat->Bmask));
     2.9 +	}
    2.10  	X11_SaveVidModeGamma(this);
    2.11  
    2.12  	/* See if we have been passed a window to use */
    2.13 @@ -772,6 +775,7 @@
    2.14  	int i, depth;
    2.15  	Visual *vis;
    2.16  	int vis_change;
    2.17 +	Uint32 Amask;
    2.18  
    2.19  	/* If a window is already present, destroy it and start fresh */
    2.20  	if ( SDL_Window ) {
    2.21 @@ -822,9 +826,15 @@
    2.22  	this->hidden->depth = depth;
    2.23  
    2.24  	/* Allocate the new pixel format for this video mode */
    2.25 +	if ( this->hidden->depth == 32 ) {
    2.26 +		Amask = (0xFFFFFFFF & ~(vis->red_mask|vis->green_mask|vis->blue_mask));
    2.27 +	} else {
    2.28 +		Amask = 0;
    2.29 +	}
    2.30  	if ( ! SDL_ReallocFormat(screen, bpp,
    2.31 -			vis->red_mask, vis->green_mask, vis->blue_mask, 0) )
    2.32 +			vis->red_mask, vis->green_mask, vis->blue_mask, Amask) ) {
    2.33  		return -1;
    2.34 +	}
    2.35  
    2.36  	/* Create the appropriate colormap */
    2.37  	if ( SDL_XColorMap != SDL_DisplayColormap ) {