# HG changeset patch # User Eli Gottlieb # Date 1281471026 14400 # Node ID 4f1573996a655773a96d0de4d170196eef7a55bd # Parent 61cb2d20a46f5a8c3d2a32e92e75c0179ea239ae Fixed a bug in X11 shaping that refused to use color-key mode. diff -r 61cb2d20a46f -r 4f1573996a65 include/SDL_shape.h --- a/include/SDL_shape.h Tue Aug 10 15:45:59 2010 -0400 +++ b/include/SDL_shape.h Tue Aug 10 16:10:26 2010 -0400 @@ -89,6 +89,9 @@ /** \brief A color key is applied. */ ShapeModeColorKey } WindowShapeMode; + +#define SDL_SHAPEMODEALPHA(mode) (mode == ShapeModeDefault || mode == ShapeModeBinarizeAlpha || mode == ShapeModeReverseBinarizeAlpha) + /** \brief A union containing parameters for shaped windows. */ typedef union { /** \brief a cutoff alpha value for binarization of the window shape's alpha channel. */ diff -r 61cb2d20a46f -r 4f1573996a65 src/video/SDL_shape.c --- a/src/video/SDL_shape.c Tue Aug 10 15:45:59 2010 -0400 +++ b/src/video/SDL_shape.c Tue Aug 10 16:10:26 2010 -0400 @@ -104,7 +104,7 @@ break; case(ShapeModeColorKey): key = mode.parameters.colorKey; - mask_value = ((key.r != r && key.g != g && key.b != b) ? 1 : 0); + mask_value = ((key.r != r || key.g != g || key.b != b) ? 1 : 0); break; } bitmap[bitmap_pixel / ppb] |= mask_value << (7 - ((ppb - 1) - (bitmap_pixel % ppb))); @@ -237,7 +237,6 @@ if(shapeMode != NULL) window->shaper->mode = *shapeMode; - //TODO: Platform-specific implementations of SetWindowShape. X11 is finished. Win32 is finished. Debugging is in progress on both. result = window->display->device->shape_driver.SetWindowShape(window->shaper,shape,shapeMode); window->shaper->hasshape = SDL_TRUE; if((window->shaper->usershownflag & SDL_WINDOW_SHOWN) == SDL_WINDOW_SHOWN) { diff -r 61cb2d20a46f -r 4f1573996a65 src/video/x11/SDL_x11shape.c --- a/src/video/x11/SDL_x11shape.c Tue Aug 10 15:45:59 2010 -0400 +++ b/src/video/x11/SDL_x11shape.c Tue Aug 10 16:10:26 2010 -0400 @@ -81,12 +81,12 @@ } int -X11_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shapeMode) { +X11_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode) { if(shaper == NULL || shape == NULL || shaper->driverdata == NULL) return -1; #if SDL_VIDEO_DRIVER_X11_XSHAPE - if(!SDL_ISPIXELFORMAT_ALPHA(SDL_MasksToPixelFormatEnum(shape->format->BitsPerPixel,shape->format->Rmask,shape->format->Gmask,shape->format->Bmask,shape->format->Amask))) + if(shape->format->Amask == 0 && SDL_SHAPEMODEALPHA(shape_mode->mode)) return -2; if(shape->w != shaper->window->w || shape->h != shaper->window->h) return -3;