Commit b3840496 authored by Eli Gottlieb's avatar Eli Gottlieb

Changed flags and positioning (for the fake-hiding) as Andreas recommended.

parent 6d464375
......@@ -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;
}
......
......@@ -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;
......
......@@ -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;
}
......@@ -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;
}
......
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