diff src/video/uikit/SDL_uikitwindow.m @ 5056:8b7988f42fcb

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.
author Sam Lantinga <slouken@libsdl.org>
date Thu, 20 Jan 2011 16:05:59 -0800
parents 8b03a20b320f
children fb424691cfc7
line wrap: on
line diff
--- a/src/video/uikit/SDL_uikitwindow.m	Thu Jan 20 11:51:23 2011 -0500
+++ b/src/video/uikit/SDL_uikitwindow.m	Thu Jan 20 16:05:59 2011 -0800
@@ -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 @@
     
 }
 
-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 @@
     
 }
 
-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 @@
     }
 }
 
+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: */