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

Commit

Permalink
Rejiggering the way shaped windows are created as preparation for OS …
Browse files Browse the repository at this point in the history
…X implementation. Fixed overdrive bug in test program that appears to have been introduced by someone other than myself.
  • Loading branch information
Eli Gottlieb committed Jul 26, 2010
1 parent 9600256 commit 7936ff8
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/video/SDL_shape.c
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions src/video/SDL_sysvideo.h
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions src/video/SDL_video.c
Expand Up @@ -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(); \
Expand Down
File renamed without changes.
4 changes: 4 additions & 0 deletions src/video/win32/SDL_win32shape.c
Expand Up @@ -23,6 +23,10 @@
#include <windows.h>
#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;
Expand Down
1 change: 1 addition & 0 deletions src/video/win32/SDL_win32shape.h
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/video/win32/SDL_win32video.c
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions src/video/x11/SDL_x11shape.c
Expand Up @@ -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;

Expand Down
1 change: 1 addition & 0 deletions src/video/x11/SDL_x11shape.h
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/video/x11/SDL_x11video.c
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion test/testshape.c
Expand Up @@ -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;
Expand Down

0 comments on commit 7936ff8

Please sign in to comment.