diff src/video/cocoa/SDL_cocoashape.m @ 4860:8f1994e8d886

Create all shaped windows at -1000,-1000 and save the real coordinates.
author egottlieb
date Tue, 17 Aug 2010 01:11:11 -0400
parents 91f4d4d5c395
children a2cf0174e5ab
line wrap: on
line diff
--- a/src/video/cocoa/SDL_cocoashape.m	Mon Aug 16 14:01:00 2010 -0400
+++ b/src/video/cocoa/SDL_cocoashape.m	Tue Aug 17 01:11:11 2010 -0400
@@ -51,13 +51,14 @@
 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,tree->data.shape.y,tree->data.shape.w,tree->data.shape.h);
+        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]];
     }
 }
@@ -75,20 +76,18 @@
         
     //[data->context saveGraphicsState];
     //data->saved = SDL_TRUE;
+	[NSGraphicsContext setCurrentContext:data->context];
     
     [[NSColor clearColor] set];
     NSRectFill([[windata->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. */
     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);
-    [NSGraphicsContext setCurrentContext:data->context];
-    [closure.path setClip];
-    [pool drain];
+    [closure.path addClip];
 }
 
 int