Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
authorEli Gottlieb <eligottlieb@gmail.com>
Wed, 30 Jun 2010 16:19:44 -0400
changeset 4782b6930aefd008
parent 4781 fc4c775b468a
child 4783 43826836b995
Finished X11 shaped-window functionality and removed ellipse+polygon rendering.
Makefile.in
include/SDL_shape.h
include/SDL_video.h
src/video/SDL_shape.c
src/video/SDL_sysvideo.h
src/video/SDL_video.c
src/video/x11/SDL_x11shape.c
src/video/x11/SDL_x11video.c
src/video/x11/SDL_x11window.c
     1.1 --- a/Makefile.in	Mon Jun 21 23:08:10 2010 -0400
     1.2 +++ b/Makefile.in	Wed Jun 30 16:19:44 2010 -0400
     1.3 @@ -44,7 +44,7 @@
     1.4  
     1.5  DIST = acinclude autogen.sh Borland.html Borland.zip BUGS build-scripts configure configure.in COPYING CREDITS include INSTALL Makefile.minimal Makefile.in README* sdl-config.in sdl.m4 sdl.pc.in SDL.spec SDL.spec.in src test TODO VisualC.html VisualC VisualCE Watcom-Win32.zip WhatsNew Xcode Xcode-iPhoneOS
     1.6  
     1.7 -HDRS = SDL.h SDL_assert.h SDL_atomic.h SDL_audio.h SDL_compat.h SDL_cpuinfo.h SDL_ellipse.h SDL_endian.h SDL_error.h SDL_events.h SDL_haptic.h SDL_joystick.h SDL_keyboard.h SDL_keysym.h SDL_loadso.h SDL_main.h SDL_mouse.h SDL_mutex.h SDL_name.h SDL_opengl.h SDL_opengles.h SDL_pixels.h SDL_platform.h SDL_poly.h SDL_power.h SDL_quit.h SDL_rect.h SDL_revision.h SDL_rwops.h SDL_scancode.h SDL_shape.h SDL_stdinc.h SDL_surface.h SDL_syswm.h SDL_thread.h SDL_timer.h SDL_types.h SDL_version.h SDL_video.h begin_code.h close_code.h
     1.8 +HDRS = SDL.h SDL_assert.h SDL_atomic.h SDL_audio.h SDL_compat.h SDL_cpuinfo.h SDL_endian.h SDL_error.h SDL_events.h SDL_haptic.h SDL_joystick.h SDL_keyboard.h SDL_keysym.h SDL_loadso.h SDL_main.h SDL_mouse.h SDL_mutex.h SDL_name.h SDL_opengl.h SDL_opengles.h SDL_pixels.h SDL_platform.h SDL_power.h SDL_quit.h SDL_rect.h SDL_revision.h SDL_rwops.h SDL_scancode.h SDL_shape.h SDL_stdinc.h SDL_surface.h SDL_syswm.h SDL_thread.h SDL_timer.h SDL_types.h SDL_version.h SDL_video.h begin_code.h close_code.h
     1.9  
    1.10  LT_AGE      = @LT_AGE@
    1.11  LT_CURRENT  = @LT_CURRENT@
     2.1 --- a/include/SDL_shape.h	Mon Jun 21 23:08:10 2010 -0400
     2.2 +++ b/include/SDL_shape.h	Wed Jun 30 16:19:44 2010 -0400
     2.3 @@ -114,10 +114,11 @@
     2.4   * \brief Get the shape parameters of a shaped window.
     2.5   *
     2.6   * \param window The shaped window whose parameters should be retrieved.
     2.7 - * \param shapeMode An empty shape-parameters structure to fill.
     2.8 + * \param shapeMode An empty shape-mode structure to fill, or NULL to check whether the window has a shape.
     2.9   *
    2.10 - * \return 0 on success, -1 on a null shapeMode, or -2 if the SDL_Window given is not a shaped window, or -3 if the
    2.11 - *         SDL_Window given is a window that can be shaped but isn't.
    2.12 + * \return 0 if the window has a shape and, provided shapeMode was not NULL, shapeMode has been filled with the mode
    2.13 + *           data, -1 if the SDL_Window given is not a shaped window, or -2 if the SDL_Window* given is a shapeable
    2.14 + *           window currently lacking a shape.
    2.15   *
    2.16   * \sa SDL_WindowShapeMode
    2.17   * \sa SDL_SetWindowShape
     3.1 --- a/include/SDL_video.h	Mon Jun 21 23:08:10 2010 -0400
     3.2 +++ b/include/SDL_video.h	Wed Jun 30 16:19:44 2010 -0400
     3.3 @@ -1240,82 +1240,6 @@
     3.4  extern DECLSPEC int SDLCALL SDL_RenderFillRects(const SDL_Rect ** rect, int count);
     3.5  
     3.6  /**
     3.7 - *  \brief Draw an ellipse on the current rendering target with the drawing color.
     3.8 - *
     3.9 - *  \param ellipse The destination ellipse.
    3.10 - *
    3.11 - *  \return 0 on success, or -1 if there is no rendering context current.
    3.12 - */
    3.13 -extern DECLSPEC int SDLCALL SDL_RenderDrawEllipse(const SDL_Ellipse ellipse);
    3.14 -
    3.15 -/**
    3.16 - *  \brief Draw some number of ellipses in the current rendering target with the drawing color.
    3.17 - *  
    3.18 - *  \param ellipse A pointer to an array of destination ellipses.
    3.19 - *  \param count The number of ellipses.
    3.20 - *  
    3.21 - *  \return 0 on success, or -1 if there is no rendering context current.
    3.22 - */
    3.23 -extern DECLSPEC int SDLCALL SDL_RenderDrawEllipses(const SDL_Ellipse * ellipse, int count);
    3.24 -
    3.25 -/**
    3.26 - *  \brief Fill an ellipse on the current rendering target with the drawing color.
    3.27 - *  
    3.28 - *  \param ellipse The destination ellipse
    3.29 - *  
    3.30 - *  \return 0 on success, or -1 if there is no rendering context current.
    3.31 - */
    3.32 -extern DECLSPEC int SDLCALL SDL_RenderFillEllipse(const SDL_Ellipse ellipse);
    3.33 -
    3.34 -/**
    3.35 - *  \brief Fill some number of ellipses in the current rendering target with the drawing color.
    3.36 - *  
    3.37 - *  \param ellipse A pointer to an array of destination ellipses.
    3.38 - *  \param count The number of ellipses.
    3.39 - *  
    3.40 - *  \return 0 on success, or -1 if there is no rendering context current.
    3.41 - */
    3.42 -extern DECLSPEC int SDLCALL SDL_RenderFillEllipses(const SDL_Ellipse *ellipse, int count);
    3.43 -
    3.44 -/**
    3.45 - *  \brief Draw a polygon on the current rendering target with the drawing color.
    3.46 - *
    3.47 - *  \param poly The destination polygon.
    3.48 - *
    3.49 - *  \return 0 on success, or -1 if there is no rendering context current.
    3.50 - */
    3.51 -extern DECLSPEC int SDLCALL SDL_RenderDrawPoly(const SDL_Poly poly);
    3.52 -
    3.53 -/**
    3.54 - *  \brief Draw some number of polygons in the current rendering target with the drawing color.
    3.55 - *  
    3.56 - *  \param poly A pointer to an array of destination polygons.
    3.57 - *  \param count The number of polygons.
    3.58 - *  
    3.59 - *  \return 0 on success, or -1 if there is no rendering context current.
    3.60 - */
    3.61 -extern DECLSPEC int SDLCALL SDL_RenderDrawPolys(const SDL_Poly *poly, int count);
    3.62 -
    3.63 -/**
    3.64 - *  \brief Fill a polygon on the current rendering target with the drawing color.
    3.65 - *  
    3.66 - *  \param poly The destination polygon
    3.67 - *  
    3.68 - *  \return 0 on success, or -1 if there is no rendering context current.
    3.69 - */
    3.70 -extern DECLSPEC int SDLCALL SDL_RenderFillPoly(const SDL_Poly poly);
    3.71 -
    3.72 -/**
    3.73 - *  \brief Fill some number of polygons in the current rendering target with the drawing color.
    3.74 - *  
    3.75 - *  \param poly A pointer to an array of destination polygons.
    3.76 - *  \param count The number of polygons.
    3.77 - *  
    3.78 - *  \return 0 on success, or -1 if there is no rendering context current.
    3.79 - */
    3.80 -extern DECLSPEC int SDLCALL SDL_RenderFillPolys(const SDL_Poly *poly, int count);
    3.81 -
    3.82 -/**
    3.83   *  \brief Copy a portion of the texture to the current rendering target.
    3.84   *  
    3.85   *  \param texture The source texture.
     4.1 --- a/src/video/SDL_shape.c	Mon Jun 21 23:08:10 2010 -0400
     4.2 +++ b/src/video/SDL_shape.c	Wed Jun 30 16:19:44 2010 -0400
     4.3 @@ -24,28 +24,99 @@
     4.4  #include "SDL.h"
     4.5  #include "SDL_video.h"
     4.6  #include "SDL_sysvideo.h"
     4.7 +#include "SDL_pixels.h"
     4.8 +#include "SDL_surface.h"
     4.9  #include "SDL_shape.h"
    4.10  
    4.11  SDL_Window* SDL_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags) {
    4.12 -	return NULL;
    4.13 +	SDL_Window *result = SDL_CreateWindow(title,x,y,w,h,SDL_WINDOW_BORDERLESS | flags & !SDL_WINDOW_FULLSCREEN & !SDL_WINDOW_SHOWN);
    4.14 +	result->shaper = result->display->device->shape_driver.CreateShaper(result);
    4.15 +	result->shaper->usershownflag = flags & SDL_WINDOW_SHOWN;
    4.16 +	result->shaper->alphacutoff = 1;
    4.17 +	result->shaper->hasshape = SDL_FALSE;
    4.18 +	return result;
    4.19  }
    4.20  
    4.21  SDL_bool SDL_IsShapedWindow(const SDL_Window *window) {
    4.22 -	return SDL_FALSE;
    4.23 +	if(window == NULL)
    4.24 +		return SDL_FALSE;
    4.25 +	else
    4.26 +		return window->shaper != NULL;
    4.27 +}
    4.28 +
    4.29 +/* REQUIRES that bitmap point to a w-by-h bitmap with 1bpp. */
    4.30 +void SDL_CalculateShapeBitmap(Uint8 alphacutoff,SDL_Surface *shape,Uint8* bitmap) {
    4.31 +	if(SDL_MUSTLOCK(shape))
    4.32 +		SDL_LockSurface(shape);
    4.33 +	int x = 0,y = 0;
    4.34 +	for(x = 0;x<shape->w;x++)
    4.35 +		for(y = 0;y<shape->h;y++) {
    4.36 +			void* pixel = shape->pixels + (y*shape->pitch) + (x*shape->format->BytesPerPixel);
    4.37 +			Uint8 alpha = 0;
    4.38 +			SDL_GetRGBA(*(Uint32*)pixel,shape->format,NULL,NULL,NULL,&alpha);
    4.39 +			Uint32 bitmap_pixel = y*shape->w + x;
    4.40 +			bitmap[bitmap_pixel / 8] |= (alpha >= alphacutoff ? 1 : 0) << (8 - (bitmap_pixel % 8));
    4.41 +		}
    4.42 +	if(SDL_MUSTLOCK(shape))
    4.43 +		SDL_UnlockSurface(shape);
    4.44  }
    4.45  
    4.46  int SDL_SetWindowShape(SDL_Window *window,SDL_Surface *shape,SDL_WindowShapeMode *shapeMode) {
    4.47  	if(window == NULL || !SDL_WindowIsShaped(window))
    4.48 +		//The window given was not a shapeable window.
    4.49  		return -2;
    4.50  	if(shape == NULL)
    4.51 +		//Invalid shape argument.
    4.52  		return -1;
    4.53 -	return -3;
    4.54 +	
    4.55 +	if(shapeMode != NULL) {
    4.56 +		switch(shapeMode->mode) {
    4.57 +			case ShapeModeDefault: {
    4.58 +				window->shaper->alphacutoff = 1;
    4.59 +				break;
    4.60 +			}
    4.61 +			case ShapeModeBinarizeAlpha: {
    4.62 +				window->shaper->alphacutoff = shapeMode->parameters.binarizationCutoff;
    4.63 +				break;
    4.64 +			}
    4.65 +		}
    4.66 +	}
    4.67 +	//TODO: Platform-specific implementations of SetWindowShape.  X11 is in-progress.
    4.68 +	int result = window->display->device->shape_driver.SetWindowShape(window->shaper,shape,shapeMode);
    4.69 +	window->shaper->hasshape = SDL_TRUE;
    4.70 +	if(window->shaper->usershownflag & SDL_WINDOW_SHOWN == SDL_WINDOW_SHOWN) {
    4.71 +		SDL_ShowWindow(window);
    4.72 +		window->shaper->usershownflag &= !SDL_WINDOW_SHOWN;
    4.73 +	}
    4.74 +	return result;
    4.75 +}
    4.76 +
    4.77 +SDL_bool SDL_WindowHasAShape(SDL_Window *window) {
    4.78 +	assert(window != NULL && SDL_IsShapedWindow(window));
    4.79 +	return window->shaper->hasshape;
    4.80  }
    4.81  
    4.82  int SDL_GetShapedWindowMode(SDL_Window *window,SDL_WindowShapeMode *shapeMode) {
    4.83 -	if(shapeMode == NULL)
    4.84 +	if(window != NULL && SDL_IsShapedWindow(window)) {
    4.85 +		if(shapeMode == NULL) {
    4.86 +			if(SDL_WindowHasAShape(window))
    4.87 +				//The window given has a shape.
    4.88 +				return 0;
    4.89 +			else
    4.90 +				//The window given is shapeable but lacks a shape.
    4.91 +				return -2;
    4.92 +		}
    4.93 +		else {
    4.94 +			if(window->shaper->alphacutoff != 1) {
    4.95 +				shapeMode->mode = ShapeModeBinarizeAlpha;
    4.96 +				shapeMode->parameters.binarizationCutoff = window->shaper->alphacutoff;
    4.97 +			}
    4.98 +			else
    4.99 +				shapeMode->mode = ShapeModeDefault;
   4.100 +			return 0;
   4.101 +		}
   4.102 +	}
   4.103 +	else
   4.104 +		//The window given is not a valid shapeable window.
   4.105  		return -1;
   4.106 -	if(window == NULL || !SDL_WindowIsShaped(window))
   4.107 -		return -2;
   4.108 -	return -3;
   4.109  }
     5.1 --- a/src/video/SDL_sysvideo.h	Mon Jun 21 23:08:10 2010 -0400
     5.2 +++ b/src/video/SDL_sysvideo.h	Wed Jun 30 16:19:44 2010 -0400
     5.3 @@ -26,11 +26,14 @@
     5.4  
     5.5  #include "SDL_mouse.h"
     5.6  #include "SDL_keysym.h"
     5.7 +#include "SDL_shape.h"
     5.8  
     5.9  /* The SDL video driver */
    5.10  
    5.11  typedef struct SDL_Renderer SDL_Renderer;
    5.12  typedef struct SDL_RenderDriver SDL_RenderDriver;
    5.13 +typedef struct SDL_WindowShaper SDL_WindowShaper;
    5.14 +typedef struct SDL_ShapeDriver SDL_ShapeDriver;
    5.15  typedef struct SDL_VideoDisplay SDL_VideoDisplay;
    5.16  typedef struct SDL_VideoDevice SDL_VideoDevice;
    5.17  
    5.18 @@ -97,10 +100,6 @@
    5.19                              int count);
    5.20      int (*RenderFillRects) (SDL_Renderer * renderer, const SDL_Rect ** rects,
    5.21                              int count);
    5.22 -    int (*RenderDrawEllipse) (SDL_Renderer * renderer, int x, int y,
    5.23 -                              int w, int h);
    5.24 -    int (*RenderFillEllipse) (SDL_Renderer * renderer, int x, int y,
    5.25 -                              int w, int h);
    5.26      int (*RenderCopy) (SDL_Renderer * renderer, SDL_Texture * texture,
    5.27                         const SDL_Rect * srcrect, const SDL_Rect * dstrect);
    5.28      int (*RenderReadPixels) (SDL_Renderer * renderer, const SDL_Rect * rect,
    5.29 @@ -136,6 +135,33 @@
    5.30      SDL_RendererInfo info;
    5.31  };
    5.32  
    5.33 +/* Define the SDL window-shaper structure */
    5.34 +struct SDL_WindowShaper
    5.35 +{   
    5.36 +    /* The window associated with the shaper */
    5.37 +    SDL_Window *window;
    5.38 +    
    5.39 +    /* The user's specified SDL_WINDOW_SHOWN flag, for use once the user gives the window a shape. */
    5.40 +    Uint32 usershownflag;
    5.41 +    
    5.42 +    /* The cutoff value for alpha-channel binarization.  When alpha is greater-than-or-equal-to this value in the shape
    5.43 +       image, the corresponding pixel of the actual window will be considered part of the window's shape. */
    5.44 +    Uint8 alphacutoff;
    5.45 +    
    5.46 +    /* Has this window been assigned a shape? */
    5.47 +    SDL_bool hasshape;
    5.48 +    
    5.49 +    void *driverdata;
    5.50 +};
    5.51 +
    5.52 +/* Define the SDL shape driver structure */
    5.53 +struct SDL_ShapeDriver
    5.54 +{
    5.55 +    SDL_WindowShaper *(*CreateShaper)(SDL_Window * window);
    5.56 +    int (*SetWindowShape)(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shapeMode);
    5.57 +    int (*ResizeWindowShape)(SDL_Window *window);
    5.58 +};
    5.59 +
    5.60  /* Define the SDL window structure, corresponding to toplevel windows */
    5.61  struct SDL_Window
    5.62  {
    5.63 @@ -150,6 +176,8 @@
    5.64      SDL_Renderer *renderer;
    5.65  
    5.66      SDL_DisplayMode fullscreen_mode;
    5.67 +    
    5.68 +    SDL_WindowShaper *shaper;
    5.69  
    5.70      void *userdata;
    5.71      void *driverdata;
    5.72 @@ -270,6 +298,12 @@
    5.73      void (*RestoreWindow) (_THIS, SDL_Window * window);
    5.74      void (*SetWindowGrab) (_THIS, SDL_Window * window);
    5.75      void (*DestroyWindow) (_THIS, SDL_Window * window);
    5.76 +    
    5.77 +    /* * * */
    5.78 +    /*
    5.79 +     * Shaped-window functions
    5.80 +     */
    5.81 +    SDL_ShapeDriver shape_driver;
    5.82  
    5.83      /* Get some platform dependent window information */
    5.84        SDL_bool(*GetWindowWMInfo) (_THIS, SDL_Window * window,
     6.1 --- a/src/video/SDL_video.c	Mon Jun 21 23:08:10 2010 -0400
     6.2 +++ b/src/video/SDL_video.c	Wed Jun 30 16:19:44 2010 -0400
     6.3 @@ -2534,38 +2534,6 @@
     6.4      return renderer->RenderFillRects(renderer, rects, count);
     6.5  }
     6.6  
     6.7 -int SDL_RenderDrawEllipse(const SDL_Ellipse ellipse) {
     6.8 -	return SDL_RenderDrawEllipses(&ellipse,1);
     6.9 -}
    6.10 -
    6.11 -int SDL_RenderDrawEllipses(const SDL_Ellipse * ellipse, int count) {
    6.12 -	return -1;
    6.13 -}
    6.14 -
    6.15 -int SDL_RenderFillEllipse(const SDL_Ellipse ellipse) {
    6.16 -    return SDL_RenderFillEllipses(&ellipse,1);
    6.17 -}
    6.18 -
    6.19 -int SDL_RenderFillEllipses(const SDL_Ellipse * ellipse, int count) {
    6.20 -    return -1;
    6.21 -}
    6.22 -
    6.23 -int SDL_RenderDrawPoly(const SDL_Poly poly) {
    6.24 -    return SDL_RenderDrawPolys(&poly,1);
    6.25 -}
    6.26 -
    6.27 -int SDL_RenderDrawPolys(const SDL_Poly *poly, int count) {
    6.28 -    return -1;
    6.29 -}
    6.30 -
    6.31 -int SDL_RenderFillPoly(const SDL_Poly poly) {
    6.32 -    return SDL_RenderFillPolys(&poly,1);
    6.33 -}
    6.34 -
    6.35 -int SDL_RenderFillPolys(const SDL_Poly *poly, int count) {
    6.36 -    return -1;
    6.37 -}
    6.38 -
    6.39  int
    6.40  SDL_RenderCopy(SDL_Texture * texture, const SDL_Rect * srcrect,
    6.41                 const SDL_Rect * dstrect)
     7.1 --- a/src/video/x11/SDL_x11shape.c	Mon Jun 21 23:08:10 2010 -0400
     7.2 +++ b/src/video/x11/SDL_x11shape.c	Wed Jun 30 16:19:44 2010 -0400
     7.3 @@ -20,6 +20,69 @@
     7.4      eligottlieb@gmail.com
     7.5  */
     7.6  
     7.7 -#include "SDL_shape.h"
     7.8 +#include <X11/Xos.h>
     7.9 +#include <X11/IntrinsicP.h>
    7.10 +#include <X11/StringDefs.h>
    7.11 +#include <X11/Xmu/Converters.h>
    7.12 +#include <X11/extensions/shape.h>
    7.13 +#include "SDL_x11shape.h"
    7.14 +#include "SDL_x11window.h"
    7.15 +#include "SDL_x11video.h"
    7.16  
    7.17 -/* Functions implementing shaped-window functionality for X Window System will be implemented when the API is decided. */
    7.18 +SDL_WindowShaper* X11_CreateShaper(SDL_Window* window) {
    7.19 +	SDL_WindowShaper* result = malloc(sizeof(SDL_WindowShaper));
    7.20 +	result->window = window;
    7.21 +	result->alphacutoff = 0;
    7.22 +	result->usershownflag = 0;
    7.23 +	result->driverdata = malloc(sizeof(SDL_ShapeData));
    7.24 +	window->shaper = result;
    7.25 +	int resized_properly = X11ResizeWindowShape(window);
    7.26 +	assert(resized_properly == 0);
    7.27 +	return result;
    7.28 +}
    7.29 +
    7.30 +int X11_ResizeWindowShape(SDL_Window* window) {
    7.31 +	SDL_ShapeData* data = window->shaper->driverdata;
    7.32 +	assert(data != NULL);
    7.33 +	
    7.34 +	unsigned int bitmapsize = window->w / 8;
    7.35 +	if(window->w % 8 > 0)
    7.36 +		bitmapsize += 1;
    7.37 +	bitmapsize *= window->h;
    7.38 +	if(data->bitmapsize != bitmapsize || data->bitmap == NULL) {
    7.39 +		data->bitmapsize = bitmapsize;
    7.40 +		if(data->bitmap != NULL)
    7.41 +			free(data->bitmap);
    7.42 +		data->bitmap = malloc(data->bitmapsize);
    7.43 +		if(data->bitmap == NULL) {
    7.44 +			SDL_SetError("Could not allocate memory for shaped-window bitmap.");
    7.45 +			return -1;
    7.46 +		}
    7.47 +	}
    7.48 +	
    7.49 +	window->shaper->usershownflag = window->flags & SDL_WINDOW_SHOWN;
    7.50 +	
    7.51 +	return 0;
    7.52 +}
    7.53 +	
    7.54 +int X11_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shapeMode) {
    7.55 +	if(!SDL_ISPIXELFORMAT_ALPHA(SDL_MasksToPixelFormatEnum(shape->format->BitsPerPixel,shape->format->Rmask,shape->format->Gmask,shape->format->Bmask,shape->format->Amask)))
    7.56 +		return -2;
    7.57 +	if(shape->w != shaper->window->w || shape->h != shaper->window->h)
    7.58 +		return -3;
    7.59 +	SDL_ShapeData *data = shaper->driverdata;
    7.60 +	assert(data != NULL);
    7.61 +	
    7.62 +	/* Assume that shaper->alphacutoff already has a value. */
    7.63 +	SDL_CalculateShapeBitmap(shaper->alphacutoff,shape,data->bitmap);
    7.64 +		
    7.65 +	SDL_WindowData *windowdata = (SDL_WindowData*)(shaper->window->driverdata);
    7.66 +	Pixmap shapemask = XCreateBitmapFromData(windowdata->videodata->display,windowdata->xwindow,data->bitmap,shaper->window->w,shaper->window->h);
    7.67 +	
    7.68 +	XShapeCombineMask(windowdata->videodata->display,windowdata->xwindow, ShapeBounding, 0, 0,shapemask, ShapeSet);
    7.69 +	XSync(windowdata->videodata->display,False);
    7.70 +
    7.71 +	XFreePixmap(windowdata->videodata->display,shapemask);
    7.72 +	
    7.73 +	return 0;
    7.74 +}
     8.1 --- a/src/video/x11/SDL_x11video.c	Mon Jun 21 23:08:10 2010 -0400
     8.2 +++ b/src/video/x11/SDL_x11video.c	Wed Jun 30 16:19:44 2010 -0400
     8.3 @@ -28,6 +28,7 @@
     8.4  
     8.5  #include "SDL_x11video.h"
     8.6  #include "SDL_x11render.h"
     8.7 +#include "SDL_x11shape.h"
     8.8  
     8.9  #if SDL_VIDEO_DRIVER_PANDORA
    8.10  #include "SDL_x11opengles.h"
    8.11 @@ -202,6 +203,9 @@
    8.12      device->SetWindowGrab = X11_SetWindowGrab;
    8.13      device->DestroyWindow = X11_DestroyWindow;
    8.14      device->GetWindowWMInfo = X11_GetWindowWMInfo;
    8.15 +    device->shape_driver.CreateShaper = X11_CreateShaper;
    8.16 +    device->shape_driver.SetWindowShape = X11_SetWindowShape;
    8.17 +    device->shape_driver.ResizeWindowShape = X11_ResizeWindowShape;
    8.18  #ifdef SDL_VIDEO_OPENGL_GLX
    8.19      device->GL_LoadLibrary = X11_GL_LoadLibrary;
    8.20      device->GL_GetProcAddress = X11_GL_GetProcAddress;
     9.1 --- a/src/video/x11/SDL_x11window.c	Mon Jun 21 23:08:10 2010 -0400
     9.2 +++ b/src/video/x11/SDL_x11window.c	Wed Jun 30 16:19:44 2010 -0400
     9.3 @@ -28,6 +28,7 @@
     9.4  #include "SDL_x11video.h"
     9.5  #include "SDL_x11mouse.h"
     9.6  #include "SDL_x11gamma.h"
     9.7 +#include "SDL_x11shape.h"
     9.8  #include "../Xext/extensions/StdCmap.h"
     9.9  
    9.10  #ifdef SDL_VIDEO_DRIVER_PANDORA
    9.11 @@ -897,6 +898,8 @@
    9.12      SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
    9.13      Display *display = data->videodata->display;
    9.14  
    9.15 +    if(SDL_IsShapedWindow(window))
    9.16 +        X11_ResizeWindowShape(window);
    9.17      XResizeWindow(display, data->xwindow, window->w, window->h);
    9.18  }
    9.19