Mercurial > sdl-ios-xcode
comparison 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 |
comparison
equal
deleted
inserted
replaced
5055:2936fc46b015 | 5056:8b7988f42fcb |
---|---|
19 Sam Lantinga | 19 Sam Lantinga |
20 slouken@libsdl.org | 20 slouken@libsdl.org |
21 */ | 21 */ |
22 #include "SDL_config.h" | 22 #include "SDL_config.h" |
23 | 23 |
24 #include "SDL_syswm.h" | |
24 #include "SDL_video.h" | 25 #include "SDL_video.h" |
25 #include "SDL_mouse.h" | 26 #include "SDL_mouse.h" |
26 #include "SDL_assert.h" | 27 #include "SDL_assert.h" |
27 #include "../SDL_sysvideo.h" | 28 #include "../SDL_sysvideo.h" |
28 #include "../SDL_pixels_c.h" | 29 #include "../SDL_pixels_c.h" |
34 #import "SDL_uikitappdelegate.h" | 35 #import "SDL_uikitappdelegate.h" |
35 | 36 |
36 #import "SDL_uikitopenglview.h" | 37 #import "SDL_uikitopenglview.h" |
37 #import "SDL_renderer_sw.h" | 38 #import "SDL_renderer_sw.h" |
38 | 39 |
39 #include <UIKit/UIKit.h> | |
40 #include <Foundation/Foundation.h> | 40 #include <Foundation/Foundation.h> |
41 | 41 |
42 static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bool created) | 42 static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bool created) |
43 { | 43 { |
44 SDL_VideoDisplay *display = window->display; | 44 SDL_VideoDisplay *display = window->display; |
83 | 83 |
84 return 0; | 84 return 0; |
85 | 85 |
86 } | 86 } |
87 | 87 |
88 int UIKit_CreateWindow(_THIS, SDL_Window *window) { | 88 int |
89 UIKit_CreateWindow(_THIS, SDL_Window *window) { | |
89 | 90 |
90 SDL_VideoDisplay *display = window->display; | 91 SDL_VideoDisplay *display = window->display; |
91 UIScreen *uiscreen = (UIScreen *) display->driverdata; | 92 UIScreen *uiscreen = (UIScreen *) display->driverdata; |
92 | 93 |
93 // SDL currently puts this window at the start of display's linked list. We rely on this. | 94 // SDL currently puts this window at the start of display's linked list. We rely on this. |
152 | 153 |
153 return 1; | 154 return 1; |
154 | 155 |
155 } | 156 } |
156 | 157 |
157 void UIKit_DestroyWindow(_THIS, SDL_Window * window) { | 158 void |
159 UIKit_DestroyWindow(_THIS, SDL_Window * window) { | |
158 SDL_WindowData *data = (SDL_WindowData *)window->driverdata; | 160 SDL_WindowData *data = (SDL_WindowData *)window->driverdata; |
159 if (data) { | 161 if (data) { |
160 [data->uiwindow release]; | 162 [data->uiwindow release]; |
161 SDL_free(data); | 163 SDL_free(data); |
162 window->driverdata = NULL; | 164 window->driverdata = NULL; |
163 } | 165 } |
164 } | 166 } |
165 | 167 |
168 SDL_bool | |
169 UIKit_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info) | |
170 { | |
171 UIWindow *uiwindow = ((SDL_WindowData *) window->driverdata)->uiwindow; | |
172 | |
173 if (info->version.major <= SDL_MAJOR_VERSION) { | |
174 info->subsystem = SDL_SYSWM_UIKIT; | |
175 info->info.uikit.window = uiwindow; | |
176 return SDL_TRUE; | |
177 } else { | |
178 SDL_SetError("Application not compiled with SDL %d.%d\n", | |
179 SDL_MAJOR_VERSION, SDL_MINOR_VERSION); | |
180 return SDL_FALSE; | |
181 } | |
182 } | |
183 | |
166 /* vi: set ts=4 sw=4 expandtab: */ | 184 /* vi: set ts=4 sw=4 expandtab: */ |