Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Fixed a bug in X11 shaping that refused to use color-key mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
Eli Gottlieb committed Aug 10, 2010
1 parent 4a1d19c commit 02c1b25
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
3 changes: 3 additions & 0 deletions include/SDL_shape.h
Expand Up @@ -89,6 +89,9 @@ typedef enum {
/** \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. */
Expand Down
3 changes: 1 addition & 2 deletions src/video/SDL_shape.c
Expand Up @@ -104,7 +104,7 @@ SDL_CalculateShapeBitmap(SDL_WindowShapeMode mode,SDL_Surface *shape,Uint8* bitm
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)));
Expand Down Expand Up @@ -237,7 +237,6 @@ SDL_SetWindowShape(SDL_Window *window,SDL_Surface *shape,SDL_WindowShapeMode *sh

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) {
Expand Down
4 changes: 2 additions & 2 deletions src/video/x11/SDL_x11shape.c
Expand Up @@ -81,12 +81,12 @@ X11_ResizeWindowShape(SDL_Window* window) {
}

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;
Expand Down

0 comments on commit 02c1b25

Please sign in to comment.