From 155833dd81bd66ca44c399623482e61fc70b4134 Mon Sep 17 00:00:00 2001 From: Eli Gottlieb Date: Mon, 26 Jul 2010 17:27:04 -0400 Subject: [PATCH] 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. --- src/video/SDL_shape.c | 5 ++++- src/video/SDL_sysvideo.h | 1 + src/video/SDL_video.c | 4 ++++ src/video/cocoa/{SDL_cocoashape.c => SDL_cocoashape.m} | 0 src/video/win32/SDL_win32shape.c | 4 ++++ src/video/win32/SDL_win32shape.h | 1 + src/video/win32/SDL_win32video.c | 1 + src/video/x11/SDL_x11shape.c | 4 ++++ src/video/x11/SDL_x11shape.h | 1 + src/video/x11/SDL_x11video.c | 1 + test/testshape.c | 2 +- 11 files changed, 22 insertions(+), 2 deletions(-) rename src/video/cocoa/{SDL_cocoashape.c => SDL_cocoashape.m} (100%) diff --git a/src/video/SDL_shape.c b/src/video/SDL_shape.c index 3affe1fd4..fea819d97 100644 --- a/src/video/SDL_shape.c +++ b/src/video/SDL_shape.c @@ -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 --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h index b8508740a..919ab3421 100644 --- a/src/video/SDL_sysvideo.h +++ b/src/video/SDL_sysvideo.h @@ -156,6 +156,7 @@ struct SDL_WindowShaper /* 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 --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 8ac0d1d4c..7ae4f274f 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -105,6 +105,10 @@ static VideoBootStrap *bootstrap[] = { static SDL_VideoDevice *_this = NULL; +SDL_VideoDisplay* SDL_ThisDisplay() { + return SDL_CurrentDisplay; +} + #define CHECK_WINDOW_MAGIC(window, retval) \ if (!_this) { \ SDL_UninitializedVideo(); \ diff --git a/src/video/cocoa/SDL_cocoashape.c b/src/video/cocoa/SDL_cocoashape.m similarity index 100% rename from src/video/cocoa/SDL_cocoashape.c rename to src/video/cocoa/SDL_cocoashape.m diff --git a/src/video/win32/SDL_win32shape.c b/src/video/win32/SDL_win32shape.c index 4c3d202ca..6d7c22d70 100644 --- a/src/video/win32/SDL_win32shape.c +++ b/src/video/win32/SDL_win32shape.c @@ -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 --git a/src/video/win32/SDL_win32shape.h b/src/video/win32/SDL_win32shape.h index eb04046a3..67fab1c2b 100644 --- a/src/video/win32/SDL_win32shape.h +++ b/src/video/win32/SDL_win32shape.h @@ -34,6 +34,7 @@ typedef struct { 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 --git a/src/video/win32/SDL_win32video.c b/src/video/win32/SDL_win32video.c index 4e7dc3f5b..82ec69cbc 100644 --- a/src/video/win32/SDL_win32video.c +++ b/src/video/win32/SDL_win32video.c @@ -185,6 +185,7 @@ WIN_CreateDevice(int devindex) 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 --git a/src/video/x11/SDL_x11shape.c b/src/video/x11/SDL_x11shape.c index 36d5fa2e2..ebbe78470 100644 --- a/src/video/x11/SDL_x11shape.c +++ b/src/video/x11/SDL_x11shape.c @@ -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 --git a/src/video/x11/SDL_x11shape.h b/src/video/x11/SDL_x11shape.h index 82ecb0e49..fa8ea1c6d 100644 --- a/src/video/x11/SDL_x11shape.h +++ b/src/video/x11/SDL_x11shape.h @@ -33,6 +33,7 @@ typedef struct { 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 --git a/src/video/x11/SDL_x11video.c b/src/video/x11/SDL_x11video.c index b320aaafe..28a85e0e6 100644 --- a/src/video/x11/SDL_x11video.c +++ b/src/video/x11/SDL_x11video.c @@ -203,6 +203,7 @@ X11_CreateDevice(int devindex) 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 --git a/test/testshape.c b/test/testshape.c index ece437707..16d79835a 100644 --- a/test/testshape.c +++ b/test/testshape.c @@ -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;