Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Changed flags and positioning (for the fake-hiding) as Andreas recomm…
Browse files Browse the repository at this point in the history
…ended.
  • Loading branch information
Eli Gottlieb committed Aug 15, 2010
1 parent f2f3bcb commit e5a705c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
12 changes: 7 additions & 5 deletions src/video/SDL_shape.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions src/video/SDL_sysvideo.h
Expand Up @@ -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;
Expand Down
6 changes: 4 additions & 2 deletions src/video/win32/SDL_win32shape.c
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
}
6 changes: 4 additions & 2 deletions src/video/x11/SDL_x11shape.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit e5a705c

Please sign in to comment.