From e5a705c43fde0c8b04ea3421b50e3e7944bb2589 Mon Sep 17 00:00:00 2001 From: Eli Gottlieb Date: Sun, 15 Aug 2010 18:52:57 -0400 Subject: [PATCH] Changed flags and positioning (for the fake-hiding) as Andreas recommended. --- src/video/SDL_shape.c | 12 +++++++----- src/video/SDL_sysvideo.h | 4 ++-- src/video/win32/SDL_win32shape.c | 6 ++++-- src/video/x11/SDL_x11shape.c | 6 ++++-- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/video/SDL_shape.c b/src/video/SDL_shape.c index 22a84eb51..a608268c5 100644 --- a/src/video/SDL_shape.c +++ b/src/video/SDL_shape.c @@ -32,11 +32,12 @@ 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,flags | SDL_WINDOW_BORDERLESS & !SDL_WINDOW_FULLSCREEN & !SDL_WINDOW_SHOWN); + SDL_Window *result = SDL_CreateWindow(title,x,y,w,h,flags | SDL_WINDOW_BORDERLESS & !SDL_WINDOW_FULLSCREEN & !SDL_WINDOW_RESIZABLE); 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; @@ -239,9 +240,10 @@ SDL_SetWindowShape(SDL_Window *window,SDL_Surface *shape,SDL_WindowShapeMode *sh 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; } diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h index e982f58f4..c7f294fac 100644 --- a/src/video/SDL_sysvideo.h +++ b/src/video/SDL_sysvideo.h @@ -141,8 +141,8 @@ struct SDL_WindowShaper /* 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; diff --git a/src/video/win32/SDL_win32shape.c b/src/video/win32/SDL_win32shape.c index 5d927f32b..718ca1bd1 100644 --- a/src/video/win32/SDL_win32shape.c +++ b/src/video/win32/SDL_win32shape.c @@ -32,7 +32,7 @@ Win32_CreateShaper(SDL_Window * window) { 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. @@ -101,7 +101,9 @@ Win32_ResizeWindowShape(SDL_Window *window) { if(data->mask_tree != NULL) SDL_FreeShapeTree(&data->mask_tree); - 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; } diff --git a/src/video/x11/SDL_x11shape.c b/src/video/x11/SDL_x11shape.c index c57680699..74ee903a8 100644 --- a/src/video/x11/SDL_x11shape.c +++ b/src/video/x11/SDL_x11shape.c @@ -40,7 +40,7 @@ X11_CreateShaper(SDL_Window* window) { 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 @@ X11_ResizeWindowShape(SDL_Window* window) { } 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; }