changeset 4861:b67815cf9f25

Merged no changes?
author Sam Lantinga <slouken@libsdl.org>
date Sun, 22 Aug 2010 12:43:27 -0700
parents 8f1994e8d886 (diff) 4201864f77e7 (current diff)
children 7b1d35d98294
files src/video/SDL_shape.c
diffstat 14 files changed, 115 insertions(+), 114 deletions(-) [+]
line wrap: on
line diff
--- a/VisualC/SDL/SDL_VS2010.vcxproj	Tue Aug 10 16:30:53 2010 -0400
+++ b/VisualC/SDL/SDL_VS2010.vcxproj	Sun Aug 22 12:43:27 2010 -0700
@@ -110,7 +110,7 @@
       <Culture>0x0409</Culture>
     </ResourceCompile>
     <Link>
-      <AdditionalDependencies>msimg32.lib;winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>msvcrt.lib;msimg32.lib;winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <OutputFile>$(IntDir)SDL.dll</OutputFile>
       <IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
       <GenerateDebugInformation>true</GenerateDebugInformation>
--- a/Xcode/SDLTest/SDLTest.xcodeproj/project.pbxproj	Tue Aug 10 16:30:53 2010 -0400
+++ b/Xcode/SDLTest/SDLTest.xcodeproj/project.pbxproj	Sun Aug 22 12:43:27 2010 -0700
@@ -1184,14 +1184,14 @@
 			isa = PBXContainerItemProxy;
 			containerPortal = 003FA63A093FFD41000C53B3 /* SDL.xcodeproj */;
 			proxyType = 2;
-			remoteGlobalIDString = 00D8D9EF1195090700638393 /* testsdl.app */;
+			remoteGlobalIDString = 00D8D9EF1195090700638393;
 			remoteInfo = testsdl;
 		};
 		4537749D1209152D002F0F45 /* PBXContainerItemProxy */ = {
 			isa = PBXContainerItemProxy;
 			containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
 			proxyType = 1;
-			remoteGlobalIDString = BEC567F70761D90600A33029 /* sdlcommon */;
+			remoteGlobalIDString = BEC567F70761D90600A33029;
 			remoteInfo = sdlcommon;
 		};
 		BEC568300761D90600A33029 /* PBXContainerItemProxy */ = {
--- a/include/SDL_shape.h	Tue Aug 10 16:30:53 2010 -0400
+++ b/include/SDL_shape.h	Sun Aug 22 12:43:27 2010 -0700
@@ -112,7 +112,7 @@
  *
  * \param window The shaped window whose parameters should be set.
  * \param shape A surface encoding the desired shape for the window.
- * \param shapeMode The parameters to set for the shaped window.
+ * \param shape_mode The parameters to set for the shaped window.
  *
  * \return 0 on success, SDL_INVALID_SHAPE_ARGUMENT on invalid an invalid shape argument, or SDL_NONSHAPEABLE_WINDOW
  *           if the SDL_Window* given does not reference a valid shaped window.
@@ -120,22 +120,22 @@
  * \sa SDL_WindowShapeMode
  * \sa SDL_GetShapedWindowMode.
  */
-extern DECLSPEC int SDLCALL SDL_SetWindowShape(SDL_Window *window,SDL_Surface *shape,SDL_WindowShapeMode *shapeMode);
+extern DECLSPEC int SDLCALL SDL_SetWindowShape(SDL_Window *window,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode);
 
 /**
  * \brief Get the shape parameters of a shaped window.
  *
  * \param window The shaped window whose parameters should be retrieved.
- * \param shapeMode An empty shape-mode structure to fill, or NULL to check whether the window has a shape.
+ * \param shape_mode An empty shape-mode structure to fill, or NULL to check whether the window has a shape.
  *
- * \return 0 if the window has a shape and, provided shapeMode was not NULL, shapeMode has been filled with the mode
+ * \return 0 if the window has a shape and, provided shape_mode was not NULL, shape_mode has been filled with the mode
  *           data, SDL_NONSHAPEABLE_WINDOW if the SDL_Window given is not a shaped window, or SDL_WINDOW_LACKS_SHAPE if
  *           the SDL_Window* given is a shapeable window currently lacking a shape.
  *
  * \sa SDL_WindowShapeMode
  * \sa SDL_SetWindowShape
  */
-extern DECLSPEC int SDLCALL SDL_GetShapedWindowMode(SDL_Window *window,SDL_WindowShapeMode *shapeMode);
+extern DECLSPEC int SDLCALL SDL_GetShapedWindowMode(SDL_Window *window,SDL_WindowShapeMode *shape_mode);
 
 /* Ends C function definitions when using C++ */
 #ifdef __cplusplus
--- a/src/video/SDL_shape.c	Tue Aug 10 16:30:53 2010 -0400
+++ b/src/video/SDL_shape.c	Sun Aug 22 12:43:27 2010 -0700
@@ -32,11 +32,13 @@
 
 SDL_Window*
 SDL_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags) {
-    SDL_Window *result = SDL_CreateWindow(title,x,y,w,h,SDL_WINDOW_BORDERLESS | flags & !SDL_WINDOW_FULLSCREEN & !SDL_WINDOW_SHOWN);
+    SDL_Window *result = NULL;
+    result = SDL_CreateWindow(title,-1000,-1000,w,h,(flags | SDL_WINDOW_BORDERLESS) & (~SDL_WINDOW_FULLSCREEN) & (~SDL_WINDOW_RESIZABLE) /*& (~SDL_WINDOW_SHOWN)*/);
     if(result != NULL) {
         result->shaper = result->display->device->shape_driver.CreateShaper(result);
         if(result->shaper != NULL) {
-            result->shaper->usershownflag = flags & SDL_WINDOW_SHOWN;
+            result->shaper->userx = x;
+            result->shaper->usery = y;
             result->shaper->mode.mode = ShapeModeDefault;
             result->shaper->mode.parameters.binarizationCutoff = 1;
             result->shaper->hasshape = SDL_FALSE;
@@ -125,7 +127,7 @@
     SDL_Color key;
     SDL_ShapeTree* result = (SDL_ShapeTree*)SDL_malloc(sizeof(SDL_ShapeTree));
     SDL_Rect next = {0,0,0,0};
-    for(y=dimensions.y;y<dimensions.y + dimensions.h;y++)
+    for(y=dimensions.y;y<dimensions.y + dimensions.h;y++) {
         for(x=dimensions.x;x<dimensions.x + dimensions.w;x++) {
             pixel_value = 0;
             pixel = (Uint8 *)(mask->pixels) + (y*mask->pitch) + (x*mask->format->BytesPerPixel);
@@ -156,7 +158,7 @@
                     break;
                 case(ShapeModeColorKey):
                     key = mode.parameters.colorKey;
-                    pixel_opaque = ((key.r == r && key.g == g && key.b == b) ? SDL_TRUE : SDL_FALSE);
+                    pixel_opaque = ((key.r != r || key.g != g || key.b != b) ? SDL_TRUE : SDL_FALSE);
                     break;
             }
             if(last_opaque == -1)
@@ -170,18 +172,19 @@
                 next.x = dimensions.x;
                 next.y = dimensions.y;
                 result->data.children.upleft = (struct SDL_ShapeTree *)RecursivelyCalculateShapeTree(mode,mask,next);
-                next.x = dimensions.w / 2;
+                next.x += next.w;
                 //Unneeded: next.y = dimensions.y;
                 result->data.children.upright = (struct SDL_ShapeTree *)RecursivelyCalculateShapeTree(mode,mask,next);
                 next.x = dimensions.x;
-                next.y = dimensions.h / 2;
+                next.y += next.h;
                 result->data.children.downleft = (struct SDL_ShapeTree *)RecursivelyCalculateShapeTree(mode,mask,next);
-                next.x = dimensions.w / 2;
-                //Unneeded: next.y = dimensions.h / 2 + 1;
+                next.x += next.w;
+                //Unneeded: next.y = dimensions.y + dimensions.h /2;
                 result->data.children.downright = (struct SDL_ShapeTree *)RecursivelyCalculateShapeTree(mode,mask,next);
                 return result;
             }
         }
+    }
     //If we never recursed, all the pixels in this quadrant have the same "value".
     result->kind = (last_opaque == SDL_TRUE ? OpaqueShape : TransparentShape);
     result->data.shape = dimensions;
@@ -214,15 +217,15 @@
 }
 
 void
-SDL_FreeShapeTree(SDL_ShapeTree** shapeTree) {
-    if((*shapeTree)->kind == QuadShape) {
-        SDL_FreeShapeTree((SDL_ShapeTree **)&(*shapeTree)->data.children.upleft);
-        SDL_FreeShapeTree((SDL_ShapeTree **)&(*shapeTree)->data.children.upright);
-        SDL_FreeShapeTree((SDL_ShapeTree **)&(*shapeTree)->data.children.downleft);
-        SDL_FreeShapeTree((SDL_ShapeTree **)&(*shapeTree)->data.children.downright);
+SDL_FreeShapeTree(SDL_ShapeTree** shape_tree) {
+    if((*shape_tree)->kind == QuadShape) {
+        SDL_FreeShapeTree((SDL_ShapeTree **)&(*shape_tree)->data.children.upleft);
+        SDL_FreeShapeTree((SDL_ShapeTree **)&(*shape_tree)->data.children.upright);
+        SDL_FreeShapeTree((SDL_ShapeTree **)&(*shape_tree)->data.children.downleft);
+        SDL_FreeShapeTree((SDL_ShapeTree **)&(*shape_tree)->data.children.downright);
     }
-    SDL_free(*shapeTree);
-    *shapeTree = NULL;
+    SDL_free(*shape_tree);
+    *shape_tree = NULL;
 }
 
 int
@@ -239,9 +242,10 @@
         window->shaper->mode = *shape_mode;
     result = window->display->device->shape_driver.SetWindowShape(window->shaper,shape,shape_mode);
     window->shaper->hasshape = SDL_TRUE;
-    if((window->shaper->usershownflag & SDL_WINDOW_SHOWN) == SDL_WINDOW_SHOWN) {
-        SDL_ShowWindow(window);
-        window->shaper->usershownflag &= !SDL_WINDOW_SHOWN;
+    if(window->shaper->userx != 0 && window->shaper->usery != 0) {
+        SDL_SetWindowPosition(window,window->shaper->userx,window->shaper->usery);
+        window->shaper->userx = 0;
+        window->shaper->usery = 0;
     }
     return result;
 }
--- a/src/video/SDL_shape_internals.h	Tue Aug 10 16:30:53 2010 -0400
+++ b/src/video/SDL_shape_internals.h	Sun Aug 22 12:43:27 2010 -0700
@@ -57,7 +57,7 @@
 extern void SDL_CalculateShapeBitmap(SDL_WindowShapeMode mode,SDL_Surface *shape,Uint8* bitmap,Uint8 ppb);
 extern SDL_ShapeTree* SDL_CalculateShapeTree(SDL_WindowShapeMode mode,SDL_Surface* shape);
 extern void SDL_TraverseShapeTree(SDL_ShapeTree *tree,SDL_TraversalFunction function,void* closure);
-extern void SDL_FreeShapeTree(SDL_ShapeTree** shapeTree);
+extern void SDL_FreeShapeTree(SDL_ShapeTree** shape_tree);
 
 /* Ends C function definitions when using C++ */
 #ifdef __cplusplus
--- a/src/video/SDL_sysvideo.h	Tue Aug 10 16:30:53 2010 -0400
+++ b/src/video/SDL_sysvideo.h	Sun Aug 22 12:43:27 2010 -0700
@@ -141,8 +141,8 @@
     /* The window associated with the shaper */
     SDL_Window *window;
     
-    /* The user's specified SDL_WINDOW_SHOWN flag, for use once the user gives the window a shape. */
-    Uint32 usershownflag;
+    /* The user's specified coordinates for the window, for once we give it a shape. */
+    Uint32 userx,usery;
     
     /* The parameters for shape calculation. */
     SDL_WindowShapeMode mode;
@@ -157,7 +157,7 @@
 struct SDL_ShapeDriver
 {
     SDL_WindowShaper *(*CreateShaper)(SDL_Window * window);
-    int (*SetWindowShape)(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shapeMode);
+    int (*SetWindowShape)(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode);
     int (*ResizeWindowShape)(SDL_Window *window);
 };
 
--- a/src/video/cocoa/SDL_cocoashape.h	Tue Aug 10 16:30:53 2010 -0400
+++ b/src/video/cocoa/SDL_cocoashape.h	Sun Aug 22 12:43:27 2010 -0700
@@ -38,7 +38,7 @@
 } SDL_ShapeData;
 
 extern SDL_WindowShaper* Cocoa_CreateShaper(SDL_Window* window);
-extern int Cocoa_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shapeMode);
+extern int Cocoa_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode);
 extern int Cocoa_ResizeWindowShape(SDL_Window *window);
 
 #endif
--- a/src/video/cocoa/SDL_cocoashape.m	Tue Aug 10 16:30:53 2010 -0400
+++ b/src/video/cocoa/SDL_cocoashape.m	Sun Aug 22 12:43:27 2010 -0700
@@ -23,47 +23,71 @@
 #include "SDL_cocoavideo.h"
 #include "SDL_shape.h"
 #include "SDL_cocoashape.h"
+#include "../src/video/SDL_sysvideo.h"
 
 SDL_WindowShaper*
 Cocoa_CreateShaper(SDL_Window* window) {
-    SDL_WindowData* data = (SDL_WindowData*)window->driverdata;
-    [data->nswindow setAlpha:1.0];
-    [data->nswindow setOpaque:YES];
-    [data->nswindow setStyleMask:NSBorderlessWindowMask];
-    SDL_Shaper* result = result = malloc(sizeof(SDL_WindowShaper));
+    SDL_WindowData* windata = (SDL_WindowData*)window->driverdata;
+    [windata->nswindow setOpaque:NO];
+    [windata->nswindow setStyleMask:NSBorderlessWindowMask];
+    SDL_WindowShaper* result = result = malloc(sizeof(SDL_WindowShaper));
     result->window = window;
     result->mode.mode = ShapeModeDefault;
     result->mode.parameters.binarizationCutoff = 1;
-    result->usershownflag = 0;
+    result->userx = result->usery = 0;
     window->shaper = result;
     
     SDL_ShapeData* data = malloc(sizeof(SDL_ShapeData));
     result->driverdata = data;
-    data->context = [data->nswindow graphicsContext];
-    data->saved = SDL_False;
-    data->rects = NULL;
-    data->count = 0;
+    data->context = [windata->nswindow graphicsContext];
+    data->saved = SDL_FALSE;
+    data->shape = NULL;
     
     int resized_properly = Cocoa_ResizeWindowShape(window);
     assert(resized_properly == 0);
     return result;
 }
 
+typedef struct {
+    NSView* view;
+    NSBezierPath* path;
+    SDL_Window* window;
+} SDL_CocoaClosure;
+
+void
+ConvertRects(SDL_ShapeTree* tree,void* closure) {
+    SDL_CocoaClosure* data = (SDL_CocoaClosure*)closure;
+    if(tree->kind == OpaqueShape) {
+        NSRect rect = NSMakeRect(tree->data.shape.x,data->window->h - tree->data.shape.y,tree->data.shape.w,tree->data.shape.h);
+        [data->path appendBezierPathWithRect:[data->view convertRect:rect toView:nil]];
+    }
+}
+
 int
-Cocoa_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shapeMode) {
-    SDL_WindowData* data = (SDL_WindowData*)shaper->window->driverdata;
-    if(data->saved == SDL_True) {
+Cocoa_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode) {
+    SDL_ShapeData* data = (SDL_ShapeData*)shaper->driverdata;
+	SDL_WindowData* windata = (SDL_WindowData*)shaper->window->driverdata;
+	SDL_CocoaClosure closure;
+	NSAutoreleasePool *pool = NULL;
+    if(data->saved == SDL_TRUE) {
         [data->context restoreGraphicsState];
-        data->saved = SDL_False;
+        data->saved = SDL_FALSE;
     }
         
-    [data->context saveGraphicsState];
-    data->saved = SDL_True;
+    //[data->context saveGraphicsState];
+    //data->saved = SDL_TRUE;
+	[NSGraphicsContext setCurrentContext:data->context];
     
     [[NSColor clearColor] set];
-    NSRectFill([[data->nswindow contentView] frame]);
-    /* TODO: It looks like Cocoa can set a clipping path based on a list of rectangles.  That's what we get from the
-           Windoze shape-calculation code: a list of rectangles.  This will work... I think. */
+    NSRectFill([[windata->nswindow contentView] frame]);
+    data->shape = SDL_CalculateShapeTree(*shape_mode,shape);
+	
+	pool = [[NSAutoreleasePool alloc] init];
+    closure.view = [windata->nswindow contentView];
+    closure.path = [[NSBezierPath bezierPath] autorelease];
+	closure.window = shaper->window;
+    SDL_TraverseShapeTree(data->shape,&ConvertRects,&closure);
+    [closure.path addClip];
 }
 
 int
--- a/src/video/win32/SDL_win32shape.c	Tue Aug 10 16:30:53 2010 -0400
+++ b/src/video/win32/SDL_win32shape.c	Sun Aug 22 12:43:27 2010 -0700
@@ -20,6 +20,8 @@
     eligottlieb@gmail.com
 */
 
+#include <stdio.h>
+#include "SDL_assert.h"
 #include "SDL_win32shape.h"
 #include "SDL_win32video.h"
 
@@ -30,7 +32,7 @@
     result->window = window;
     result->mode.mode = ShapeModeDefault;
     result->mode.parameters.binarizationCutoff = 1;
-    result->usershownflag = 0;
+    result->userx = result->usery = 0;
     result->driverdata = (SDL_ShapeData*)SDL_malloc(sizeof(SDL_ShapeData));
     ((SDL_ShapeData*)result->driverdata)->mask_tree = NULL;
     //Put some driver-data here.
@@ -38,78 +40,44 @@
     resized_properly = Win32_ResizeWindowShape(window);
     if (resized_properly != 0)
             return NULL;
-
+    
     return result;
 }
 
-typedef struct {
-	POINT corners[4];
-	void* next;
-} SDL_ShapeRect;
-
 void
 CombineRectRegions(SDL_ShapeTree* node,void* closure) {
-    SDL_ShapeRect* rect_list = *((SDL_ShapeRect**)closure);
+    HRGN mask_region = *((HRGN*)closure),temp_region = NULL;
     if(node->kind == OpaqueShape) {
-        SDL_ShapeRect* rect = SDL_malloc(sizeof(SDL_ShapeRect));
-        rect->corners[0].x = node->data.shape.x; rect->corners[0].y = node->data.shape.y;
-        rect->corners[1].x = node->data.shape.x + node->data.shape.w; rect->corners[1].y = node->data.shape.y;
-        rect->corners[2].x = node->data.shape.x + node->data.shape.w; rect->corners[2].y = node->data.shape.y + node->data.shape.h;
-        rect->corners[3].x = node->data.shape.x; rect->corners[3].y = node->data.shape.y + node->data.shape.h;
-        rect->next = *((SDL_ShapeRect**)closure);
-        *((SDL_ShapeRect**)closure) = rect;
-    }
-}
-
-Uint32 num_shape_rects(SDL_ShapeRect* rect) {
-    if(rect == NULL)
-        return 0;
-	else
-		return 1 + num_shape_rects(rect->next);
+        //Win32 API regions exclude their outline, so we widen the region by one pixel in each direction to include the real outline.
+        temp_region = CreateRectRgn(node->data.shape.x,node->data.shape.y,node->data.shape.x + node->data.shape.w + 1,node->data.shape.y + node->data.shape.h + 1);
+        if(mask_region != NULL) {
+            CombineRgn(mask_region,mask_region,temp_region,RGN_OR);
+            DeleteObject(temp_region);
+		}
+		else
+            *((HRGN*)closure) = temp_region;
+	}
 }
 
 int
-Win32_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shapeMode) {
+Win32_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode) {
     SDL_ShapeData *data;
-    HRGN mask_region;
-	SDL_ShapeRect* rects = NULL,*old = NULL;
-	Uint16 num_rects = 0,i = 0;
-	int* polygonVertexNumbers = NULL;
-	POINT* polygons = NULL;
+    HRGN mask_region = NULL;
 
     if (shaper == NULL || shape == NULL)
         return SDL_INVALID_SHAPE_ARGUMENT;
-    if(shape->format->Amask == 0 && shapeMode->mode != ShapeModeColorKey || shape->w != shaper->window->w || shape->h != shaper->window->h)
+    if(shape->format->Amask == 0 && shape_mode->mode != ShapeModeColorKey || shape->w != shaper->window->w || shape->h != shaper->window->h)
         return SDL_INVALID_SHAPE_ARGUMENT;
     
     data = (SDL_ShapeData*)shaper->driverdata;
     if(data->mask_tree != NULL)
         SDL_FreeShapeTree(&data->mask_tree);
-    data->mask_tree = SDL_CalculateShapeTree(*shapeMode,shape);
+    data->mask_tree = SDL_CalculateShapeTree(*shape_mode,shape);
     
-    SDL_TraverseShapeTree(data->mask_tree,&CombineRectRegions,&rects);
-    num_rects = num_shape_rects(rects);
-    polygonVertexNumbers = (int*)SDL_malloc(sizeof(int)*num_rects);
-    for(i=0;i<num_rects;i++)
-        polygonVertexNumbers[i] = 4;
-    polygons = (POINT*)SDL_malloc(sizeof(POINT)*4*num_rects);
-    for(i=0;i<num_rects*4;i++) {
-        polygons[i] = rects[i / 4].corners[i % 4];
-        if(i % 4 == 3) {
-            old = rects;
-            rects = rects->next;
-            SDL_free(old);
-		}
-	}
+    SDL_TraverseShapeTree(data->mask_tree,&CombineRectRegions,&mask_region);
+	SDL_assert(mask_region != NULL);
 
-    /*
-     * Set the new region mask for the window 
-     */
-	mask_region = CreatePolyPolygonRgn(polygons,polygonVertexNumbers,num_rects,WINDING);
     SetWindowRgn(((SDL_WindowData *)(shaper->window->driverdata))->hwnd, mask_region, TRUE);
-
-	SDL_free(polygons);
-	SDL_free(polygonVertexNumbers);
     
     return 0;
 }
@@ -126,8 +94,11 @@
     
     if(data->mask_tree != NULL)
         SDL_FreeShapeTree(&data->mask_tree);
-    
-    window->shaper->usershownflag |= window->flags & SDL_WINDOW_SHOWN;
+    if(window->shaper->hasshape == SDL_TRUE) {
+        window->shaper->userx = window->x;
+        window->shaper->usery = window->y;
+        SDL_SetWindowPosition(window,-1000,-1000);
+	}
     
     return 0;
 }
--- a/src/video/win32/SDL_win32shape.h	Tue Aug 10 16:30:53 2010 -0400
+++ b/src/video/win32/SDL_win32shape.h	Sun Aug 22 12:43:27 2010 -0700
@@ -35,7 +35,7 @@
 } SDL_ShapeData;
 
 extern SDL_WindowShaper* Win32_CreateShaper(SDL_Window * window);
-extern int Win32_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shapeMode);
+extern int Win32_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode);
 extern int Win32_ResizeWindowShape(SDL_Window *window);
 
 #endif /* _SDL_win32shape_h */
--- a/src/video/x11/SDL_x11shape.c	Tue Aug 10 16:30:53 2010 -0400
+++ b/src/video/x11/SDL_x11shape.c	Sun Aug 22 12:43:27 2010 -0700
@@ -40,7 +40,7 @@
         result->window = window;
         result->mode.mode = ShapeModeDefault;
         result->mode.parameters.binarizationCutoff = 1;
-        result->usershownflag = 0;
+        result->userx = result->usery = 0;
         SDL_ShapeData* data = SDL_malloc(sizeof(SDL_ShapeData));
         result->driverdata = data;
         data->bitmapsize = 0;
@@ -75,7 +75,9 @@
     }
     memset(data->bitmap,0,data->bitmapsize);
     
-    window->shaper->usershownflag |= window->flags & SDL_WINDOW_SHOWN;
+    window->shaper->userx = window->x;
+    window->shaper->usery = window->y;
+    SDL_SetWindowPosition(window,-1000,-1000);
     
     return 0;
 }
Binary file test/shapes/trollface_24.bmp has changed
Binary file test/shapes/trollface_32alpha.bmp has changed
--- a/test/testshape.c	Tue Aug 10 16:30:53 2010 -0400
+++ b/test/testshape.c	Sun Aug 22 12:43:27 2010 -0700
@@ -8,7 +8,7 @@
 #define SHAPED_WINDOW_Y 150
 #define SHAPED_WINDOW_DIMENSION 640
 
-#define TICK_INTERVAL 1000/60
+#define TICK_INTERVAL 1000/10
 
 typedef struct LoadedPicture {
 	SDL_Surface *surface;
@@ -32,11 +32,11 @@
 static Uint32 next_time;
 
 Uint32 time_left() {
-	Uint32 now = SDL_GetTicks();
-	if(next_time <= now)
-		return 0;
+    Uint32 now = SDL_GetTicks();
+    if(next_time <= now)
+        return 0;
 	else
-		return next_time - now;
+        return next_time - now;
 }
 
 int main(int argc,char** argv) {
@@ -85,7 +85,7 @@
 		format = pictures[i].surface->format;
 		if(format->Amask != 0) {
 			pictures[i].mode.mode = ShapeModeBinarizeAlpha;
-			pictures[i].mode.parameters.binarizationCutoff = 1;
+			pictures[i].mode.parameters.binarizationCutoff = 255;
 		}
 		else {
 			pictures[i].mode.mode = ShapeModeColorKey;