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.
authorEli Gottlieb <eligottlieb@gmail.com>
Mon, 26 Jul 2010 17:27:04 -0400
changeset 4809329708ffe2a7
parent 4808 2ae79ed78a5a
child 4810 7a602fd2121f
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
src/video/SDL_sysvideo.h
src/video/SDL_video.c
src/video/cocoa/SDL_cocoashape.c
src/video/cocoa/SDL_cocoashape.m
src/video/win32/SDL_win32shape.c
src/video/win32/SDL_win32shape.h
src/video/win32/SDL_win32video.c
src/video/x11/SDL_x11shape.c
src/video/x11/SDL_x11shape.h
src/video/x11/SDL_x11video.c
test/testshape.c
     1.1 --- a/src/video/SDL_shape.c	Fri Jul 23 01:48:42 2010 -0400
     1.2 +++ b/src/video/SDL_shape.c	Mon Jul 26 17:27:04 2010 -0400
     1.3 @@ -28,8 +28,11 @@
     1.4  #include "SDL_surface.h"
     1.5  #include "SDL_shape.h"
     1.6  
     1.7 +extern SDL_VideoDisplay* SDL_ThisDisplay();
     1.8 +
     1.9  SDL_Window* SDL_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags) {
    1.10 -	SDL_Window *result = SDL_CreateWindow(title,x,y,w,h,SDL_WINDOW_BORDERLESS | flags & !SDL_WINDOW_FULLSCREEN & !SDL_WINDOW_SHOWN);
    1.11 +	SDL_VideoDisplay* display = SDL_ThisDisplay();
    1.12 +	SDL_Window *result = display->device->shape_driver.CreateShapedWindow(title,x,y,w,h,SDL_WINDOW_BORDERLESS | flags & !SDL_WINDOW_FULLSCREEN & !SDL_WINDOW_SHOWN);
    1.13  	if(result != NULL) {
    1.14  		result->shaper = result->display->device->shape_driver.CreateShaper(result);
    1.15  		if(result->shaper != NULL) {
     2.1 --- a/src/video/SDL_sysvideo.h	Fri Jul 23 01:48:42 2010 -0400
     2.2 +++ b/src/video/SDL_sysvideo.h	Mon Jul 26 17:27:04 2010 -0400
     2.3 @@ -156,6 +156,7 @@
     2.4  /* Define the SDL shape driver structure */
     2.5  struct SDL_ShapeDriver
     2.6  {
     2.7 +    SDL_Window *(*CreateShapedWindow)(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags);
     2.8      SDL_WindowShaper *(*CreateShaper)(SDL_Window * window);
     2.9      int (*SetWindowShape)(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shapeMode);
    2.10      int (*ResizeWindowShape)(SDL_Window *window);
     3.1 --- a/src/video/SDL_video.c	Fri Jul 23 01:48:42 2010 -0400
     3.2 +++ b/src/video/SDL_video.c	Mon Jul 26 17:27:04 2010 -0400
     3.3 @@ -105,6 +105,10 @@
     3.4  
     3.5  static SDL_VideoDevice *_this = NULL;
     3.6  
     3.7 +SDL_VideoDisplay* SDL_ThisDisplay() {
     3.8 +    return SDL_CurrentDisplay;
     3.9 +}
    3.10 +
    3.11  #define CHECK_WINDOW_MAGIC(window, retval) \
    3.12      if (!_this) { \
    3.13          SDL_UninitializedVideo(); \
     4.1 --- a/src/video/cocoa/SDL_cocoashape.c	Fri Jul 23 01:48:42 2010 -0400
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,25 +0,0 @@
     4.4 -/*
     4.5 -    SDL - Simple DirectMedia Layer
     4.6 -    Copyright (C) 2010 Eli Gottlieb
     4.7 -
     4.8 -    This library is free software; you can redistribute it and/or
     4.9 -    modify it under the terms of the GNU Lesser General Public
    4.10 -    License as published by the Free Software Foundation; either
    4.11 -    version 2.1 of the License, or (at your option) any later version.
    4.12 -
    4.13 -    This library is distributed in the hope that it will be useful,
    4.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
    4.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    4.16 -    Lesser General Public License for more details.
    4.17 -
    4.18 -    You should have received a copy of the GNU Lesser General Public
    4.19 -    License along with this library; if not, write to the Free Software
    4.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    4.21 -
    4.22 -    Eli Gottlieb
    4.23 -    eligottlieb@gmail.com
    4.24 -*/
    4.25 -
    4.26 -#include "SDL_shape.h"
    4.27 -
    4.28 -/* Functions implementing shaped windows for Cocoa will be implemented when the API is decided on. */
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/src/video/cocoa/SDL_cocoashape.m	Mon Jul 26 17:27:04 2010 -0400
     5.3 @@ -0,0 +1,25 @@
     5.4 +/*
     5.5 +    SDL - Simple DirectMedia Layer
     5.6 +    Copyright (C) 2010 Eli Gottlieb
     5.7 +
     5.8 +    This library is free software; you can redistribute it and/or
     5.9 +    modify it under the terms of the GNU Lesser General Public
    5.10 +    License as published by the Free Software Foundation; either
    5.11 +    version 2.1 of the License, or (at your option) any later version.
    5.12 +
    5.13 +    This library is distributed in the hope that it will be useful,
    5.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    5.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    5.16 +    Lesser General Public License for more details.
    5.17 +
    5.18 +    You should have received a copy of the GNU Lesser General Public
    5.19 +    License along with this library; if not, write to the Free Software
    5.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    5.21 +
    5.22 +    Eli Gottlieb
    5.23 +    eligottlieb@gmail.com
    5.24 +*/
    5.25 +
    5.26 +#include "SDL_shape.h"
    5.27 +
    5.28 +/* Functions implementing shaped windows for Cocoa will be implemented when the API is decided on. */
     6.1 --- a/src/video/win32/SDL_win32shape.c	Fri Jul 23 01:48:42 2010 -0400
     6.2 +++ b/src/video/win32/SDL_win32shape.c	Mon Jul 26 17:27:04 2010 -0400
     6.3 @@ -23,6 +23,10 @@
     6.4  #include <windows.h>
     6.5  #include "SDL_win32shape.h"
     6.6  
     6.7 +SDL_Window* Win32_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags) {
     6.8 +	return SDL_CreateWindow(title,x,y,w,h,flags);
     6.9 +}
    6.10 +
    6.11  SDL_WindowShaper* Win32_CreateShaper(SDL_Window * window) {
    6.12  	SDL_WindowShaper* result = malloc(sizeof(SDL_WindowShaper));
    6.13  	result->window = window;
     7.1 --- a/src/video/win32/SDL_win32shape.h	Fri Jul 23 01:48:42 2010 -0400
     7.2 +++ b/src/video/win32/SDL_win32shape.h	Mon Jul 26 17:27:04 2010 -0400
     7.3 @@ -34,6 +34,7 @@
     7.4  	Uint32 buffersize;
     7.5  } SDL_ShapeData;
     7.6  
     7.7 +extern SDL_Window* Win32_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags);
     7.8  extern SDL_WindowShaper* Win32_CreateShaper(SDL_Window * window);
     7.9  extern int Win32_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shapeMode);
    7.10  extern int Win32_ResizeWindowShape(SDL_Window *window);
     8.1 --- a/src/video/win32/SDL_win32video.c	Fri Jul 23 01:48:42 2010 -0400
     8.2 +++ b/src/video/win32/SDL_win32video.c	Mon Jul 26 17:27:04 2010 -0400
     8.3 @@ -185,6 +185,7 @@
     8.4      device->DestroyWindow = WIN_DestroyWindow;
     8.5      device->GetWindowWMInfo = WIN_GetWindowWMInfo;
     8.6      
     8.7 +    device->shape_driver.CreateShapedWindow = Win32_CreateShapedWindow;
     8.8      device->shape_driver.CreateShaper = Win32_CreateShaper;
     8.9      device->shape_driver.SetWindowShape = Win32_SetWindowShape;
    8.10      device->shape_driver.ResizeWindowShape = Win32_ResizeWindowShape;
     9.1 --- a/src/video/x11/SDL_x11shape.c	Fri Jul 23 01:48:42 2010 -0400
     9.2 +++ b/src/video/x11/SDL_x11shape.c	Mon Jul 26 17:27:04 2010 -0400
     9.3 @@ -25,6 +25,10 @@
     9.4  #include "SDL_x11shape.h"
     9.5  #include "SDL_x11window.h"
     9.6  
     9.7 +SDL_Window* X11_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags) {
     9.8 +	return SDL_CreateWindow(title,x,y,w,h,flags);
     9.9 +}
    9.10 +
    9.11  SDL_WindowShaper* X11_CreateShaper(SDL_Window* window) {
    9.12  	SDL_WindowShaper* result = NULL;
    9.13  
    10.1 --- a/src/video/x11/SDL_x11shape.h	Fri Jul 23 01:48:42 2010 -0400
    10.2 +++ b/src/video/x11/SDL_x11shape.h	Mon Jul 26 17:27:04 2010 -0400
    10.3 @@ -33,6 +33,7 @@
    10.4  	Uint32 bitmapsize;
    10.5  } SDL_ShapeData;
    10.6  
    10.7 +extern SDL_Window* X11_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags);
    10.8  extern SDL_WindowShaper* X11_CreateShaper(SDL_Window* window);
    10.9  extern int X11_ResizeWindowShape(SDL_Window* window);
   10.10  extern int X11_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shapeMode);	
    11.1 --- a/src/video/x11/SDL_x11video.c	Fri Jul 23 01:48:42 2010 -0400
    11.2 +++ b/src/video/x11/SDL_x11video.c	Mon Jul 26 17:27:04 2010 -0400
    11.3 @@ -203,6 +203,7 @@
    11.4      device->SetWindowGrab = X11_SetWindowGrab;
    11.5      device->DestroyWindow = X11_DestroyWindow;
    11.6      device->GetWindowWMInfo = X11_GetWindowWMInfo;
    11.7 +    device->shape_driver.CreateShapedWindow = X11_CreateShapedWindow;
    11.8      device->shape_driver.CreateShaper = X11_CreateShaper;
    11.9      device->shape_driver.SetWindowShape = X11_SetWindowShape;
   11.10      device->shape_driver.ResizeWindowShape = X11_ResizeWindowShape;
    12.1 --- a/test/testshape.c	Fri Jul 23 01:48:42 2010 -0400
    12.2 +++ b/test/testshape.c	Mon Jul 26 17:27:04 2010 -0400
    12.3 @@ -12,7 +12,7 @@
    12.4  #define SHAPED_WINDOW_Y 150
    12.5  #define SHAPED_WINDOW_DIMENSION 640
    12.6  
    12.7 -#define TICK_INTERVAL 18
    12.8 +#define TICK_INTERVAL 1000/60
    12.9  
   12.10  typedef struct LoadedPicture {
   12.11  	SDL_Surface *surface;