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

Commit

Permalink
OK, it appears that dramatic hacks are not necessary to make Cocoa wo…
Browse files Browse the repository at this point in the history
…rk...
  • Loading branch information
Eli Gottlieb committed Jul 27, 2010
1 parent 7936ff8 commit bcfdeff
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 22 deletions.
21 changes: 11 additions & 10 deletions TODO
@@ -1,20 +1,21 @@
Eli Gottlieb's checklist for the GSOC shaped windows project. Dated July 9, 2010.
1. Enable proper linking of the X11 implementation and test it.
--> Find the place in the build system for platform-specific linking flags. STATUS: BLOODY IMPOSSIBLE.
--> Add a linker flag to bring in libXext.a. STATUS: WILL BE SIMPLE ONCE PREVIOUS STEP IS ACCOMPLISHED (kshemashiach yagia).
--> Find the place in the build system for platform-specific linking flags. STATUS: DONE
--> Add a linker flag to bring in libXext.a. STATUS: DONE.
2. Build the Win32 implementation of shaped-windows functionality.
--> Add driver functions to the SDL_ShapeDriver in the Win32 driver's SDL_DisplayDevice at the proper point in the code. STATUS: CHECK.
--> Add a hook in the Windows resize-window code to call Win32_ResizeWindowShape(). STATUS: CHECK.
--> Get the Windows code to build and run properly. STATUS: IN PROGRESS.
3. Enable building the testeyes program.
--> Reprogram it to use the latest shaped-windows API. STATUS: CHECK.
--> Get it, along with the rest of the test suite in my branch, building successfully. STATUS: REQUIRES X11 IMPLEMENTATION TO LINK PROPERLY AND/OR A BUILD-BUDDY BUILDING AND RUNNING THE TEST FOR ME.
--> Debug testeyes and the platform-specific shaped-window implementations in tandem. STATUS: TO BEGIN, CURRENT SPRINT.
4. Implement the SDL shaped-windows API for Mac OS X using Cocoa. STATUS: NEXT SPRINT.
--> Locate (once more) the API documentation for shaped windows under Cocoa.
--> Design and encode a version of SDL_ShapeData for Cocoa.
--> Write Cocoa_CreateShaper().
--> Write Cocoa_ResizeWindowShape().
--> Write Cocoa_SetWindowShape().
--> Get it, along with the rest of the test suite in my branch, building successfully. STATUS: DONE.
--> Debug testeyes and the platform-specific shaped-window implementations in tandem. STATUS: IN PROGRESS.
4. Implement the SDL shaped-windows API for Mac OS X using Cocoa. STATUS: IN PROGRESS
--> Locate (once more) the API documentation for shaped windows under Cocoa. STATUS: NEARLY FINISHED.
--> Design and encode a version of SDL_ShapeData for Cocoa. STATUS: IN PROGRESS.
--> Write Cocoa_CreateShaper(). STATUS: IN PROGRESS.
--> Write Cocoa_ResizeWindowShape(). STATUS: IN PROGRESS.
--> Write Cocoa_SetWindowShape(). STATUS: IN PROGRESS.
--> If necessary, implement functionality adjunct to SDL_CalculateShapeBitmap() for Cocoa usage.
5. Use testeyes to debug all implementations. STATUS: SPRINT + 2.
--> Debug Cocoa implementation.
Expand Down
5 changes: 1 addition & 4 deletions src/video/SDL_shape.c
Expand Up @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion src/video/SDL_sysvideo.h
Expand Up @@ -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);
Expand Down
4 changes: 0 additions & 4 deletions src/video/SDL_video.c
Expand Up @@ -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(); \
Expand Down
19 changes: 18 additions & 1 deletion src/video/cocoa/SDL_cocoashape.m
Expand Up @@ -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);
5 changes: 5 additions & 0 deletions src/video/cocoa/SDL_cocoavideo.m
Expand Up @@ -92,6 +92,11 @@
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;
Expand Down
1 change: 0 additions & 1 deletion src/video/win32/SDL_win32video.c
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion src/video/x11/SDL_x11video.c
Expand Up @@ -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;
Expand Down

0 comments on commit bcfdeff

Please sign in to comment.