# HG changeset patch # User Eli Gottlieb # Date 1280179624 14400 # Node ID 329708ffe2a7f19ff14ac1fd421c85f16fa932f5 # Parent 2ae79ed78a5a4dbe17232a683221a5bbb31ae4c5 Rejiggering the way shaped windows are created as preparation for OS X implementation. Fixed overdrive bug in test program that appears to have been introduced by someone other than myself. diff -r 2ae79ed78a5a -r 329708ffe2a7 src/video/SDL_shape.c --- a/src/video/SDL_shape.c Fri Jul 23 01:48:42 2010 -0400 +++ b/src/video/SDL_shape.c Mon Jul 26 17:27:04 2010 -0400 @@ -28,8 +28,11 @@ #include "SDL_surface.h" #include "SDL_shape.h" +extern SDL_VideoDisplay* SDL_ThisDisplay(); + 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,SDL_WINDOW_BORDERLESS | flags & !SDL_WINDOW_FULLSCREEN & !SDL_WINDOW_SHOWN); + SDL_VideoDisplay* display = SDL_ThisDisplay(); + SDL_Window *result = display->device->shape_driver.CreateShapedWindow(title,x,y,w,h,SDL_WINDOW_BORDERLESS | flags & !SDL_WINDOW_FULLSCREEN & !SDL_WINDOW_SHOWN); if(result != NULL) { result->shaper = result->display->device->shape_driver.CreateShaper(result); if(result->shaper != NULL) { diff -r 2ae79ed78a5a -r 329708ffe2a7 src/video/SDL_sysvideo.h --- a/src/video/SDL_sysvideo.h Fri Jul 23 01:48:42 2010 -0400 +++ b/src/video/SDL_sysvideo.h Mon Jul 26 17:27:04 2010 -0400 @@ -156,6 +156,7 @@ /* Define the SDL shape driver structure */ struct SDL_ShapeDriver { + SDL_Window *(*CreateShapedWindow)(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags); SDL_WindowShaper *(*CreateShaper)(SDL_Window * window); int (*SetWindowShape)(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shapeMode); int (*ResizeWindowShape)(SDL_Window *window); diff -r 2ae79ed78a5a -r 329708ffe2a7 src/video/SDL_video.c --- a/src/video/SDL_video.c Fri Jul 23 01:48:42 2010 -0400 +++ b/src/video/SDL_video.c Mon Jul 26 17:27:04 2010 -0400 @@ -105,6 +105,10 @@ static SDL_VideoDevice *_this = NULL; +SDL_VideoDisplay* SDL_ThisDisplay() { + return SDL_CurrentDisplay; +} + #define CHECK_WINDOW_MAGIC(window, retval) \ if (!_this) { \ SDL_UninitializedVideo(); \ diff -r 2ae79ed78a5a -r 329708ffe2a7 src/video/cocoa/SDL_cocoashape.c --- a/src/video/cocoa/SDL_cocoashape.c Fri Jul 23 01:48:42 2010 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 2010 Eli Gottlieb - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Eli Gottlieb - eligottlieb@gmail.com -*/ - -#include "SDL_shape.h" - -/* Functions implementing shaped windows for Cocoa will be implemented when the API is decided on. */ diff -r 2ae79ed78a5a -r 329708ffe2a7 src/video/cocoa/SDL_cocoashape.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/video/cocoa/SDL_cocoashape.m Mon Jul 26 17:27:04 2010 -0400 @@ -0,0 +1,25 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 2010 Eli Gottlieb + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Eli Gottlieb + eligottlieb@gmail.com +*/ + +#include "SDL_shape.h" + +/* Functions implementing shaped windows for Cocoa will be implemented when the API is decided on. */ diff -r 2ae79ed78a5a -r 329708ffe2a7 src/video/win32/SDL_win32shape.c --- a/src/video/win32/SDL_win32shape.c Fri Jul 23 01:48:42 2010 -0400 +++ b/src/video/win32/SDL_win32shape.c Mon Jul 26 17:27:04 2010 -0400 @@ -23,6 +23,10 @@ #include #include "SDL_win32shape.h" +SDL_Window* Win32_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags) { + return SDL_CreateWindow(title,x,y,w,h,flags); +} + SDL_WindowShaper* Win32_CreateShaper(SDL_Window * window) { SDL_WindowShaper* result = malloc(sizeof(SDL_WindowShaper)); result->window = window; diff -r 2ae79ed78a5a -r 329708ffe2a7 src/video/win32/SDL_win32shape.h --- a/src/video/win32/SDL_win32shape.h Fri Jul 23 01:48:42 2010 -0400 +++ b/src/video/win32/SDL_win32shape.h Mon Jul 26 17:27:04 2010 -0400 @@ -34,6 +34,7 @@ Uint32 buffersize; } SDL_ShapeData; +extern SDL_Window* Win32_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags); extern SDL_WindowShaper* Win32_CreateShaper(SDL_Window * window); extern int Win32_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shapeMode); extern int Win32_ResizeWindowShape(SDL_Window *window); diff -r 2ae79ed78a5a -r 329708ffe2a7 src/video/win32/SDL_win32video.c --- a/src/video/win32/SDL_win32video.c Fri Jul 23 01:48:42 2010 -0400 +++ b/src/video/win32/SDL_win32video.c Mon Jul 26 17:27:04 2010 -0400 @@ -185,6 +185,7 @@ device->DestroyWindow = WIN_DestroyWindow; device->GetWindowWMInfo = WIN_GetWindowWMInfo; + device->shape_driver.CreateShapedWindow = Win32_CreateShapedWindow; device->shape_driver.CreateShaper = Win32_CreateShaper; device->shape_driver.SetWindowShape = Win32_SetWindowShape; device->shape_driver.ResizeWindowShape = Win32_ResizeWindowShape; diff -r 2ae79ed78a5a -r 329708ffe2a7 src/video/x11/SDL_x11shape.c --- a/src/video/x11/SDL_x11shape.c Fri Jul 23 01:48:42 2010 -0400 +++ b/src/video/x11/SDL_x11shape.c Mon Jul 26 17:27:04 2010 -0400 @@ -25,6 +25,10 @@ #include "SDL_x11shape.h" #include "SDL_x11window.h" +SDL_Window* X11_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags) { + return SDL_CreateWindow(title,x,y,w,h,flags); +} + SDL_WindowShaper* X11_CreateShaper(SDL_Window* window) { SDL_WindowShaper* result = NULL; diff -r 2ae79ed78a5a -r 329708ffe2a7 src/video/x11/SDL_x11shape.h --- a/src/video/x11/SDL_x11shape.h Fri Jul 23 01:48:42 2010 -0400 +++ b/src/video/x11/SDL_x11shape.h Mon Jul 26 17:27:04 2010 -0400 @@ -33,6 +33,7 @@ Uint32 bitmapsize; } SDL_ShapeData; +extern SDL_Window* X11_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags); extern SDL_WindowShaper* X11_CreateShaper(SDL_Window* window); extern int X11_ResizeWindowShape(SDL_Window* window); extern int X11_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shapeMode); diff -r 2ae79ed78a5a -r 329708ffe2a7 src/video/x11/SDL_x11video.c --- a/src/video/x11/SDL_x11video.c Fri Jul 23 01:48:42 2010 -0400 +++ b/src/video/x11/SDL_x11video.c Mon Jul 26 17:27:04 2010 -0400 @@ -203,6 +203,7 @@ device->SetWindowGrab = X11_SetWindowGrab; device->DestroyWindow = X11_DestroyWindow; device->GetWindowWMInfo = X11_GetWindowWMInfo; + device->shape_driver.CreateShapedWindow = X11_CreateShapedWindow; device->shape_driver.CreateShaper = X11_CreateShaper; device->shape_driver.SetWindowShape = X11_SetWindowShape; device->shape_driver.ResizeWindowShape = X11_ResizeWindowShape; diff -r 2ae79ed78a5a -r 329708ffe2a7 test/testshape.c --- a/test/testshape.c Fri Jul 23 01:48:42 2010 -0400 +++ b/test/testshape.c Mon Jul 26 17:27:04 2010 -0400 @@ -12,7 +12,7 @@ #define SHAPED_WINDOW_Y 150 #define SHAPED_WINDOW_DIMENSION 640 -#define TICK_INTERVAL 18 +#define TICK_INTERVAL 1000/60 typedef struct LoadedPicture { SDL_Surface *surface;