Commit 5c9e54ea authored by Sam Lantinga's avatar Sam Lantinga

Added the ability to get the UIKit window through the SDL API.

You can also do this through the native API:
	UIWindow *window = [[UIApplication sharedApplication] keyWindow];

Also needed to name the union for events and window info.
parent aed4e90c
......@@ -88,6 +88,14 @@ typedef struct _NSWindow NSWindow;
#endif
#endif
#if defined(SDL_VIDEO_DRIVER_UIKIT)
#ifdef __OBJC__
#include <UIKit/UIKit.h>
#else
typedef struct _UIWindow UIWindow;
#endif
#endif
/**
* These are the various supported windowing subsystems
*/
......@@ -98,6 +106,7 @@ typedef enum
SDL_SYSWM_X11,
SDL_SYSWM_DIRECTFB,
SDL_SYSWM_COCOA,
SDL_SYSWM_UIKIT,
} SDL_SYSWM_TYPE;
/**
......@@ -133,7 +142,13 @@ struct SDL_SysWMmsg
/* No Cocoa window events yet */
} cocoa;
#endif
} /*msg*/;
#if defined(SDL_VIDEO_DRIVER_UIKIT)
struct
{
/* No UIKit window events yet */
} uikit;
#endif
} msg;
};
/**
......@@ -175,7 +190,13 @@ struct SDL_SysWMinfo
NSWindow *window; /* The Cocoa window */
} cocoa;
#endif
} /*info*/;
#if defined(SDL_VIDEO_DRIVER_UIKIT)
struct
{
UIWindow *window; /* The UIKit window */
} uikit;
#endif
} info;
};
#endif /* SDL_PROTOTYPES_ONLY */
......
......@@ -747,7 +747,7 @@ Cocoa_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
if (info->version.major <= SDL_MAJOR_VERSION) {
info->subsystem = SDL_SYSWM_COCOA;
info->cocoa.window = nswindow;
info->info.cocoa.window = nswindow;
return SDL_TRUE;
} else {
SDL_SetError("Application not compiled with SDL %d.%d\n",
......
......@@ -87,6 +87,7 @@ UIKit_CreateDevice(int devindex)
device->PumpEvents = UIKit_PumpEvents;
device->CreateWindow = UIKit_CreateWindow;
device->DestroyWindow = UIKit_DestroyWindow;
device->GetWindowWMInfo = UIKit_GetWindowWMInfo;
/* OpenGL (ES) functions */
......
......@@ -31,6 +31,8 @@ typedef struct SDL_WindowData SDL_WindowData;
extern int UIKit_CreateWindow(_THIS, SDL_Window * window);
extern void UIKit_DestroyWindow(_THIS, SDL_Window * window);
extern SDL_bool UIKit_GetWindowWMInfo(_THIS, SDL_Window * window,
struct SDL_SysWMinfo * info);
@class UIWindow;
......
......@@ -21,6 +21,7 @@
*/
#include "SDL_config.h"
#include "SDL_syswm.h"
#include "SDL_video.h"
#include "SDL_mouse.h"
#include "SDL_assert.h"
......@@ -36,7 +37,6 @@
#import "SDL_uikitopenglview.h"
#import "SDL_renderer_sw.h"
#include <UIKit/UIKit.h>
#include <Foundation/Foundation.h>
static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bool created)
......@@ -85,7 +85,8 @@ static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bo
}
int UIKit_CreateWindow(_THIS, SDL_Window *window) {
int
UIKit_CreateWindow(_THIS, SDL_Window *window) {
SDL_VideoDisplay *display = window->display;
UIScreen *uiscreen = (UIScreen *) display->driverdata;
......@@ -154,7 +155,8 @@ int UIKit_CreateWindow(_THIS, SDL_Window *window) {
}
void UIKit_DestroyWindow(_THIS, SDL_Window * window) {
void
UIKit_DestroyWindow(_THIS, SDL_Window * window) {
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
if (data) {
[data->uiwindow release];
......@@ -163,4 +165,20 @@ void UIKit_DestroyWindow(_THIS, SDL_Window * window) {
}
}
SDL_bool
UIKit_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
{
UIWindow *uiwindow = ((SDL_WindowData *) window->driverdata)->uiwindow;
if (info->version.major <= SDL_MAJOR_VERSION) {
info->subsystem = SDL_SYSWM_UIKIT;
info->info.uikit.window = uiwindow;
return SDL_TRUE;
} else {
SDL_SetError("Application not compiled with SDL %d.%d\n",
SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
return SDL_FALSE;
}
}
/* vi: set ts=4 sw=4 expandtab: */
......@@ -113,10 +113,10 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
SDL_VERSION(&wmmsg.version);
wmmsg.subsystem = SDL_SYSWM_WINDOWS;
wmmsg.win.hwnd = hwnd;
wmmsg.win.msg = msg;
wmmsg.win.wParam = wParam;
wmmsg.win.lParam = lParam;
wmmsg.msg.win.hwnd = hwnd;
wmmsg.msg.win.msg = msg;
wmmsg.msg.win.wParam = wParam;
wmmsg.msg.win.lParam = lParam;
SDL_SendSysWMEvent(&wmmsg);
}
......
......@@ -549,7 +549,7 @@ WIN_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
if (info->version.major <= SDL_MAJOR_VERSION) {
info->subsystem = SDL_SYSWM_WINDOWS;
info->win.window = hwnd;
info->info.win.window = hwnd;
return SDL_TRUE;
} else {
SDL_SetError("Application not compiled with SDL %d.%d\n",
......
......@@ -91,7 +91,7 @@ X11_DispatchEvent(_THIS)
SDL_VERSION(&wmmsg.version);
wmmsg.subsystem = SDL_SYSWM_X11;
wmmsg.x11.event = xevent;
wmmsg.msg.x11.event = xevent;
SDL_SendSysWMEvent(&wmmsg);
}
......
......@@ -1137,8 +1137,8 @@ X11_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
if (info->version.major == SDL_MAJOR_VERSION &&
info->version.minor == SDL_MINOR_VERSION) {
info->subsystem = SDL_SYSWM_X11;
info->x11.display = display;
info->x11.window = data->xwindow;
info->info.x11.display = display;
info->info.x11.window = data->xwindow;
return SDL_TRUE;
} else {
SDL_SetError("Application not compiled with SDL %d.%d\n",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment