OK, it appears that dramatic hacks are not necessary to make Cocoa work...

This commit is contained in:
Eli Gottlieb 2010-07-26 20:41:45 -04:00
parent 155833dd81
commit 01cddf42c7
8 changed files with 35 additions and 22 deletions

View file

@ -28,11 +28,8 @@
#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_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);
SDL_Window *result = SDL_CreateWindow(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) {

View file

@ -156,7 +156,6 @@ 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);

View file

@ -105,10 +105,6 @@ 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(); \

View file

@ -21,5 +21,22 @@
*/
#include "SDL_shape.h"
#include "SDL_cocoashape.h"
/* Functions implementing shaped windows for Cocoa will be implemented when the API is decided on. */
SDL_WindowShaper* Cocoa_CreateShaper(SDL_Window* window) {
SDL_WindowData* data = (SDL_WindowData*)window->driverdata;
[data->nswindow setAlpha:1.0];
[data->nswindow setOpaque:YES];
SDL_Shaper* result = result = malloc(sizeof(SDL_WindowShaper));
result->window = window;
result->mode.mode = ShapeModeDefault;
result->mode.parameters.binarizationCutoff = 1;
result->usershownflag = 0;
window->shaper = result;
int resized_properly = Cocoa_ResizeWindowShape(window);
assert(resized_properly == 0);
return result;
}
extern int Cocoa_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shapeMode);
extern int Cocoa_ResizeWindowShape(SDL_Window *window);

View file

@ -92,6 +92,11 @@ Cocoa_CreateDevice(int devindex)
device->SetWindowGrab = Cocoa_SetWindowGrab;
device->DestroyWindow = Cocoa_DestroyWindow;
device->GetWindowWMInfo = Cocoa_GetWindowWMInfo;
device->shape_driver.CreateShaper = Cocoa_CreateShaper;
device->shape_driver.SetWindowShape = Cocoa_SetWindowShape;
device->shape_driver.ResizeWindowShape = Cocoa_ResizeWindowShape;
#ifdef SDL_VIDEO_OPENGL_CGL
device->GL_LoadLibrary = Cocoa_GL_LoadLibrary;
device->GL_GetProcAddress = Cocoa_GL_GetProcAddress;

View file

@ -185,7 +185,6 @@ 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;

View file

@ -203,7 +203,6 @@ 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;