Commit b72231e5 authored by egottlieb's avatar egottlieb

Create all shaped windows at -1000,-1000 and save the real coordinates.

parent 18dce59e
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
SDL_Window* SDL_Window*
SDL_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags) { SDL_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags) {
SDL_Window *result = NULL; SDL_Window *result = NULL;
result = SDL_CreateWindow(title,x,y,w,h,(flags | SDL_WINDOW_BORDERLESS) & (~SDL_WINDOW_FULLSCREEN) & (~SDL_WINDOW_RESIZABLE) /*& (~SDL_WINDOW_SHOWN)*/); result = SDL_CreateWindow(title,-1000,-1000,w,h,(flags | SDL_WINDOW_BORDERLESS) & (~SDL_WINDOW_FULLSCREEN) & (~SDL_WINDOW_RESIZABLE) /*& (~SDL_WINDOW_SHOWN)*/);
if(result != NULL) { if(result != NULL) {
result->shaper = result->display->device->shape_driver.CreateShaper(result); result->shaper = result->display->device->shape_driver.CreateShaper(result);
if(result->shaper != NULL) { if(result->shaper != NULL) {
......
...@@ -51,13 +51,14 @@ Cocoa_CreateShaper(SDL_Window* window) { ...@@ -51,13 +51,14 @@ Cocoa_CreateShaper(SDL_Window* window) {
typedef struct { typedef struct {
NSView* view; NSView* view;
NSBezierPath* path; NSBezierPath* path;
SDL_Window* window;
} SDL_CocoaClosure; } SDL_CocoaClosure;
void void
ConvertRects(SDL_ShapeTree* tree,void* closure) { ConvertRects(SDL_ShapeTree* tree,void* closure) {
SDL_CocoaClosure* data = (SDL_CocoaClosure*)closure; SDL_CocoaClosure* data = (SDL_CocoaClosure*)closure;
if(tree->kind == OpaqueShape) { 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]]; [data->path appendBezierPathWithRect:[data->view convertRect:rect toView:nil]];
} }
} }
...@@ -75,20 +76,18 @@ Cocoa_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShape ...@@ -75,20 +76,18 @@ Cocoa_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShape
//[data->context saveGraphicsState]; //[data->context saveGraphicsState];
//data->saved = SDL_TRUE; //data->saved = SDL_TRUE;
[NSGraphicsContext setCurrentContext:data->context];
[[NSColor clearColor] set]; [[NSColor clearColor] set];
NSRectFill([[windata->nswindow contentView] frame]); 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); data->shape = SDL_CalculateShapeTree(*shape_mode,shape);
pool = [[NSAutoreleasePool alloc] init]; pool = [[NSAutoreleasePool alloc] init];
closure.view = [windata->nswindow contentView]; closure.view = [windata->nswindow contentView];
closure.path = [[NSBezierPath bezierPath] autorelease]; closure.path = [[NSBezierPath bezierPath] autorelease];
closure.window = shaper->window;
SDL_TraverseShapeTree(data->shape,&ConvertRects,&closure); SDL_TraverseShapeTree(data->shape,&ConvertRects,&closure);
[NSGraphicsContext setCurrentContext:data->context]; [closure.path addClip];
[closure.path setClip];
[pool drain];
} }
int int
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment