Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libSDL
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PocketInsanity
libSDL
Commits
b6ef5b01
Commit
b6ef5b01
authored
May 02, 2010
by
Ryan C. Gordon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Much improved multi-display support for iPad.
Fixes most issues and limitations, I think.
parent
953d5e65
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
138 additions
and
78 deletions
+138
-78
SDL_uikitappdelegate.h
src/video/uikit/SDL_uikitappdelegate.h
+0
-5
SDL_uikitappdelegate.m
src/video/uikit/SDL_uikitappdelegate.m
+34
-16
SDL_uikitopengles.m
src/video/uikit/SDL_uikitopengles.m
+6
-6
SDL_uikitvideo.h
src/video/uikit/SDL_uikitvideo.h
+4
-0
SDL_uikitvideo.m
src/video/uikit/SDL_uikitvideo.m
+22
-22
SDL_uikitwindow.h
src/video/uikit/SDL_uikitwindow.h
+0
-1
SDL_uikitwindow.m
src/video/uikit/SDL_uikitwindow.m
+72
-28
No files found.
src/video/uikit/SDL_uikitappdelegate.h
View file @
b6ef5b01
...
@@ -25,13 +25,8 @@
...
@@ -25,13 +25,8 @@
/* *INDENT-OFF* */
/* *INDENT-OFF* */
@interface
SDLUIKitDelegate
:
NSObject
<
UIApplicationDelegate
>
{
@interface
SDLUIKitDelegate
:
NSObject
<
UIApplicationDelegate
>
{
SDL_Window
*
window
;
UIWindow
*
uiwindow
;
}
}
@property
(
readwrite
,
assign
)
SDL_Window
*
window
;
@property
(
readwrite
,
retain
)
UIWindow
*
uiwindow
;
+
(
SDLUIKitDelegate
*
)
sharedAppDelegate
;
+
(
SDLUIKitDelegate
*
)
sharedAppDelegate
;
@end
@end
...
...
src/video/uikit/SDL_uikitappdelegate.m
View file @
b6ef5b01
...
@@ -20,6 +20,8 @@
...
@@ -20,6 +20,8 @@
slouken@libsdl.org
slouken@libsdl.org
*/
*/
#import "../SDL_sysvideo.h"
#import "SDL_uikitappdelegate.h"
#import "SDL_uikitappdelegate.h"
#import "SDL_uikitopenglview.h"
#import "SDL_uikitopenglview.h"
#import "SDL_events_c.h"
#import "SDL_events_c.h"
...
@@ -55,9 +57,6 @@ int main(int argc, char **argv) {
...
@@ -55,9 +57,6 @@ int main(int argc, char **argv) {
@implementation
SDLUIKitDelegate
@implementation
SDLUIKitDelegate
@synthesize
window
;
@synthesize
uiwindow
;
/* convenience method */
/* convenience method */
+
(
SDLUIKitDelegate
*
)
sharedAppDelegate
{
+
(
SDLUIKitDelegate
*
)
sharedAppDelegate
{
/* the delegate is set in UIApplicationMain(), which is garaunteed to be called before this method */
/* the delegate is set in UIApplicationMain(), which is garaunteed to be called before this method */
...
@@ -66,8 +65,6 @@ int main(int argc, char **argv) {
...
@@ -66,8 +65,6 @@ int main(int argc, char **argv) {
-
(
id
)
init
{
-
(
id
)
init
{
self
=
[
super
init
];
self
=
[
super
init
];
window
=
NULL
;
uiwindow
=
nil
;
return
self
;
return
self
;
}
}
...
@@ -106,21 +103,42 @@ afterDelay:0.0];
...
@@ -106,21 +103,42 @@ afterDelay:0.0];
-
(
void
)
applicationWillResignActive
:
(
UIApplication
*
)
application
-
(
void
)
applicationWillResignActive
:
(
UIApplication
*
)
application
{
{
// NSLog(@"%@", NSStringFromSelector(_cmd));
//NSLog(@"%@", NSStringFromSelector(_cmd));
SDL_SendWindowEvent
(
self
.
window
,
SDL_WINDOWEVENT_MINIMIZED
,
0
,
0
);
// Send every window on every screen a MINIMIZED event.
SDL_VideoDevice
*
_this
=
SDL_GetVideoDevice
();
if
(
!
_this
)
{
return
;
}
int
i
;
for
(
i
=
0
;
i
<
_this
->
num_displays
;
i
++
)
{
const
SDL_VideoDisplay
*
display
=
&
_this
->
displays
[
i
];
SDL_Window
*
window
;
for
(
window
=
display
->
windows
;
window
!=
nil
;
window
=
window
->
next
)
{
SDL_SendWindowEvent
(
window
,
SDL_WINDOWEVENT_MINIMIZED
,
0
,
0
);
}
}
}
}
-
(
void
)
applicationDidBecomeActive
:
(
UIApplication
*
)
application
-
(
void
)
applicationDidBecomeActive
:
(
UIApplication
*
)
application
{
{
// NSLog(@"%@", NSStringFromSelector(_cmd));
//NSLog(@"%@", NSStringFromSelector(_cmd));
SDL_SendWindowEvent
(
self
.
window
,
SDL_WINDOWEVENT_RESTORED
,
0
,
0
);
}
// Send every window on every screen a RESTORED event.
SDL_VideoDevice
*
_this
=
SDL_GetVideoDevice
();
if
(
!
_this
)
{
return
;
-
(
void
)
dealloc
{
}
[
uiwindow
release
];
[
super
dealloc
];
int
i
;
for
(
i
=
0
;
i
<
_this
->
num_displays
;
i
++
)
{
const
SDL_VideoDisplay
*
display
=
&
_this
->
displays
[
i
];
SDL_Window
*
window
;
for
(
window
=
display
->
windows
;
window
!=
nil
;
window
=
window
->
next
)
{
SDL_SendWindowEvent
(
window
,
SDL_WINDOWEVENT_RESTORED
,
0
,
0
);
}
}
}
}
@end
@end
src/video/uikit/SDL_uikitopengles.m
View file @
b6ef5b01
...
@@ -99,13 +99,13 @@ void UIKit_GL_SwapWindow(_THIS, SDL_Window * window)
...
@@ -99,13 +99,13 @@ void UIKit_GL_SwapWindow(_THIS, SDL_Window * window)
SDL
_
GLContext
UIKit
_
GL
_
CreateContext
(
_
THIS
,
SDL
_
Window
*
window
)
SDL
_
GLContext
UIKit
_
GL
_
CreateContext
(
_
THIS
,
SDL
_
Window
*
window
)
{
{
SDL
_
uikitopenglview
*
view
;
SDL
_
uikitopenglview
*
view
;
SDL
_
WindowData
*
data
=
(
SDL
_
WindowData
*
)
window
->
driverdata
;
UIScreen
*
uiscreen
=
(
UIScreen
*
)
window
->
display
->
driverdata
;
UIWindow
*
uiwindow
=
data
->
uiwindow
;
SDL
_
WindowData
*
data
=
(
SDL
_
WindowData
*
)
window
->
driverdata
;
/*
construct
our
view
,
passing
in
SDL
'
s
OpenGL
configuration
data
*/
view
=
[[
SDL
_
uikitopenglview
alloc
]
initWithFrame
:
[
uiwindow
bounds
]
\
/*
construct
our
view
,
passing
in
SDL
'
s
OpenGL
configuration
data
*/
view
=
[[
SDL
_
uikitopenglview
alloc
]
initWithFrame
:
[[
UIScreen
mainScreen
]
applicationFrame
]
\
retainBacking
:
_
this
->
gl
_
config
.
retained
_
backing
\
retainBacking
:
_
this
->
gl
_
config
.
retained
_
backing
\
rBits
:
_
this
->
gl
_
config
.
red
_
size
\
rBits
:
_
this
->
gl
_
config
.
red
_
size
\
gBits
:
_
this
->
gl
_
config
.
green
_
size
\
gBits
:
_
this
->
gl
_
config
.
green
_
size
\
...
@@ -116,7 +116,7 @@ SDL_GLContext UIKit_GL_CreateContext(_THIS, SDL_Window * window)
...
@@ -116,7 +116,7 @@ SDL_GLContext UIKit_GL_CreateContext(_THIS, SDL_Window * window)
data
->
view
=
view
;
data
->
view
=
view
;
/*
add
the
view
to
our
window
*/
/*
add
the
view
to
our
window
*/
[
data
->
uiwindow
addSubview
:
view
]
;
[
uiwindow
addSubview
:
view
]
;
/*
Don
'
t
worry
,
the
window
retained
the
view
*/
/*
Don
'
t
worry
,
the
window
retained
the
view
*/
[
view
release
]
;
[
view
release
]
;
...
...
src/video/uikit/SDL_uikitvideo.h
View file @
b6ef5b01
...
@@ -26,6 +26,10 @@
...
@@ -26,6 +26,10 @@
#include "../SDL_sysvideo.h"
#include "../SDL_sysvideo.h"
#include <UIKit/UIKit.h>
extern
BOOL
SDL_UIKit_supports_multiple_displays
;
#endif
/* _SDL_uikitvideo_h */
#endif
/* _SDL_uikitvideo_h */
/* vi: set ts=4 sw=4 expandtab: */
/* vi: set ts=4 sw=4 expandtab: */
src/video/uikit/SDL_uikitvideo.m
View file @
b6ef5b01
...
@@ -49,7 +49,7 @@ static int UIKit_SetDisplayMode(_THIS, SDL_VideoDisplay * display,
...
@@ -49,7 +49,7 @@ static int UIKit_SetDisplayMode(_THIS, SDL_VideoDisplay * display,
SDL_DisplayMode
*
mode
);
SDL_DisplayMode
*
mode
);
static
void
UIKit_VideoQuit
(
_THIS
);
static
void
UIKit_VideoQuit
(
_THIS
);
static
BOOL
supports_multiple_displays
=
NO
;
BOOL
SDL_UIKit_
supports_multiple_displays
=
NO
;
/* DUMMY driver bootstrap functions */
/* DUMMY driver bootstrap functions */
...
@@ -124,14 +124,14 @@ The main screen should list a AxB mode for portrait orientation, and then
...
@@ -124,14 +124,14 @@ The main screen should list a AxB mode for portrait orientation, and then
static
void
static
void
UIKit_GetDisplayModes
(
_THIS
,
SDL_VideoDisplay
*
display
)
UIKit_GetDisplayModes
(
_THIS
,
SDL_VideoDisplay
*
display
)
{
{
const
UIScreen
*
screen
=
(
UIScreen
*
)
display
->
driverdata
;
UIScreen
*
ui
screen
=
(
UIScreen
*
)
display
->
driverdata
;
SDL_DisplayMode
mode
;
SDL_DisplayMode
mode
;
SDL_zero
(
mode
);
SDL_zero
(
mode
);
// availableModes showed up in 3.2 (the iPad and later). We should only
// availableModes showed up in 3.2 (the iPad and later). We should only
// land here for at least that version of the OS.
// land here for at least that version of the OS.
if
(
!
supports_multiple_displays
)
{
if
(
!
SDL_UIKit_
supports_multiple_displays
)
{
const
CGRect
rect
=
[
screen
bounds
];
const
CGRect
rect
=
[
ui
screen
bounds
];
mode
.
format
=
SDL_PIXELFORMAT_ABGR8888
;
mode
.
format
=
SDL_PIXELFORMAT_ABGR8888
;
mode
.
w
=
(
int
)
rect
.
size
.
width
;
mode
.
w
=
(
int
)
rect
.
size
.
width
;
mode
.
h
=
(
int
)
rect
.
size
.
height
;
mode
.
h
=
(
int
)
rect
.
size
.
height
;
...
@@ -141,7 +141,7 @@ UIKit_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
...
@@ -141,7 +141,7 @@ UIKit_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
return
;
return
;
}
}
const
NSArray
*
modes
=
[
screen
availableModes
];
const
NSArray
*
modes
=
[
ui
screen
availableModes
];
const
NSUInteger
mode_count
=
[
modes
count
];
const
NSUInteger
mode_count
=
[
modes
count
];
NSUInteger
i
;
NSUInteger
i
;
for
(
i
=
0
;
i
<
mode_count
;
i
++
)
{
for
(
i
=
0
;
i
<
mode_count
;
i
++
)
{
...
@@ -159,11 +159,10 @@ UIKit_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
...
@@ -159,11 +159,10 @@ UIKit_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
static
void
static
void
UIKit_AddDisplay
(
UIScreen
*
screen
,
int
w
,
int
h
)
UIKit_AddDisplay
(
UIScreen
*
ui
screen
,
int
w
,
int
h
)
{
{
SDL_VideoDisplay
display
;
SDL_VideoDisplay
display
;
SDL_DisplayMode
mode
;
SDL_DisplayMode
mode
;
SDL_zero
(
mode
);
SDL_zero
(
mode
);
mode
.
format
=
SDL_PIXELFORMAT_ABGR8888
;
mode
.
format
=
SDL_PIXELFORMAT_ABGR8888
;
mode
.
w
=
w
;
mode
.
w
=
w
;
...
@@ -173,8 +172,9 @@ UIKit_AddDisplay(UIScreen *screen, int w, int h)
...
@@ -173,8 +172,9 @@ UIKit_AddDisplay(UIScreen *screen, int w, int h)
SDL_zero
(
display
);
SDL_zero
(
display
);
display
.
desktop_mode
=
mode
;
display
.
desktop_mode
=
mode
;
display
.
current_mode
=
mode
;
display
.
current_mode
=
mode
;
display
.
driverdata
=
screen
;
[
screen
retain
];
[
uiscreen
retain
];
display
.
driverdata
=
uiscreen
;
SDL_AddVideoDisplay
(
&
display
);
SDL_AddVideoDisplay
(
&
display
);
}
}
...
@@ -187,25 +187,25 @@ UIKit_VideoInit(_THIS)
...
@@ -187,25 +187,25 @@ UIKit_VideoInit(_THIS)
NSString
*
reqSysVer
=
@"3.2"
;
NSString
*
reqSysVer
=
@"3.2"
;
NSString
*
currSysVer
=
[[
UIDevice
currentDevice
]
systemVersion
];
NSString
*
currSysVer
=
[[
UIDevice
currentDevice
]
systemVersion
];
if
([
currSysVer
compare
:
reqSysVer
options
:
NSNumericSearch
]
!=
NSOrderedAscending
)
if
([
currSysVer
compare
:
reqSysVer
options
:
NSNumericSearch
]
!=
NSOrderedAscending
)
supports_multiple_displays
=
YES
;
SDL_UIKit_
supports_multiple_displays
=
YES
;
// If this is iPhoneOS < 3.2, all devices are one screen, 320x480 pixels.
// If this is iPhoneOS < 3.2, all devices are one screen, 320x480 pixels.
// The iPad added both a larger main screen and the ability to use
// The iPad added both a larger main screen and the ability to use
// external displays.
// external displays.
if
(
!
supports_multiple_displays
)
{
if
(
!
SDL_UIKit_
supports_multiple_displays
)
{
// Just give 'em the whole main screen.
// Just give 'em the whole main screen.
UIScreen
*
screen
=
[
UIScreen
mainScreen
];
UIScreen
*
ui
screen
=
[
UIScreen
mainScreen
];
const
CGRect
rect
=
[
screen
bounds
];
const
CGRect
rect
=
[
ui
screen
bounds
];
UIKit_AddDisplay
(
screen
,
(
int
)
rect
.
size
.
width
,
(
int
)
rect
.
size
.
height
);
UIKit_AddDisplay
(
ui
screen
,
(
int
)
rect
.
size
.
width
,
(
int
)
rect
.
size
.
height
);
}
else
{
}
else
{
const
NSArray
*
screens
=
[
UIScreen
screens
];
const
NSArray
*
screens
=
[
UIScreen
screens
];
const
NSUInteger
screen_count
=
[
screens
count
];
const
NSUInteger
screen_count
=
[
screens
count
];
NSUInteger
i
;
NSUInteger
i
;
for
(
i
=
0
;
i
<
screen_count
;
i
++
)
{
for
(
i
=
0
;
i
<
screen_count
;
i
++
)
{
// the main screen is the first element in the array.
// the main screen is the first element in the array.
UIScreen
*
screen
=
(
UIScreen
*
)
[
screens
objectAtIndex
:
i
];
UIScreen
*
ui
screen
=
(
UIScreen
*
)
[
screens
objectAtIndex
:
i
];
const
CGSize
size
=
[[
screen
currentMode
]
size
];
const
CGSize
size
=
[[
ui
screen
currentMode
]
size
];
UIKit_AddDisplay
(
screen
,
(
int
)
size
.
width
,
(
int
)
size
.
height
);
UIKit_AddDisplay
(
ui
screen
,
(
int
)
size
.
width
,
(
int
)
size
.
height
);
}
}
}
}
...
@@ -216,13 +216,13 @@ UIKit_VideoInit(_THIS)
...
@@ -216,13 +216,13 @@ UIKit_VideoInit(_THIS)
static
int
static
int
UIKit_SetDisplayMode
(
_THIS
,
SDL_VideoDisplay
*
display
,
SDL_DisplayMode
*
mode
)
UIKit_SetDisplayMode
(
_THIS
,
SDL_VideoDisplay
*
display
,
SDL_DisplayMode
*
mode
)
{
{
UIScreen
*
screen
=
(
UIScreen
*
)
display
->
driverdata
;
UIScreen
*
ui
screen
=
(
UIScreen
*
)
display
->
driverdata
;
if
(
!
supports_multiple_displays
)
{
if
(
!
SDL_UIKit_
supports_multiple_displays
)
{
// Not on at least iPhoneOS 3.2 (versions prior to iPad).
// Not on at least iPhoneOS 3.2 (versions prior to iPad).
SDL_assert
(
mode
->
driverdata
==
NULL
);
SDL_assert
(
mode
->
driverdata
==
NULL
);
}
else
{
}
else
{
UIScreenMode
*
uimode
=
(
UIScreenMode
*
)
mode
->
driverdata
;
UIScreenMode
*
uimode
=
(
UIScreenMode
*
)
mode
->
driverdata
;
[
screen
setCurrentMode
:
uimode
];
[
ui
screen
setCurrentMode
:
uimode
];
}
}
return
0
;
return
0
;
...
@@ -235,8 +235,8 @@ UIKit_VideoQuit(_THIS)
...
@@ -235,8 +235,8 @@ UIKit_VideoQuit(_THIS)
int
i
,
j
;
int
i
,
j
;
for
(
i
=
0
;
i
<
_this
->
num_displays
;
i
++
)
{
for
(
i
=
0
;
i
<
_this
->
num_displays
;
i
++
)
{
SDL_VideoDisplay
*
display
=
&
_this
->
displays
[
i
];
SDL_VideoDisplay
*
display
=
&
_this
->
displays
[
i
];
UIScreen
*
screen
=
(
UIScreen
*
)
display
->
driverdata
;
UIScreen
*
ui
screen
=
(
UIScreen
*
)
display
->
driverdata
;
[
((
UIScreen
*
)
display
->
driverdata
)
release
];
[
uiscreen
release
];
display
->
driverdata
=
NULL
;
display
->
driverdata
=
NULL
;
for
(
j
=
0
;
j
<
display
->
num_display_modes
;
j
++
)
{
for
(
j
=
0
;
j
<
display
->
num_display_modes
;
j
++
)
{
SDL_DisplayMode
*
mode
=
&
display
->
display_modes
[
j
];
SDL_DisplayMode
*
mode
=
&
display
->
display_modes
[
j
];
...
...
src/video/uikit/SDL_uikitwindow.h
View file @
b6ef5b01
...
@@ -36,7 +36,6 @@ extern void UIKit_DestroyWindow(_THIS, SDL_Window * window);
...
@@ -36,7 +36,6 @@ extern void UIKit_DestroyWindow(_THIS, SDL_Window * window);
struct
SDL_WindowData
struct
SDL_WindowData
{
{
SDL_Window
*
window
;
UIWindow
*
uiwindow
;
UIWindow
*
uiwindow
;
SDL_uikitopenglview
*
view
;
SDL_uikitopenglview
*
view
;
};
};
...
...
src/video/uikit/SDL_uikitwindow.m
View file @
b6ef5b01
...
@@ -23,6 +23,7 @@
...
@@ -23,6 +23,7 @@
#include
"SDL_video.h"
#include
"SDL_video.h"
#include
"SDL_mouse.h"
#include
"SDL_mouse.h"
#include
"SDL_assert.h"
#include
"../SDL_sysvideo.h"
#include
"../SDL_sysvideo.h"
#include
"../SDL_pixels_c.h"
#include
"../SDL_pixels_c.h"
#include
"../../events/SDL_events_c.h"
#include
"../../events/SDL_events_c.h"
...
@@ -38,8 +39,10 @@
...
@@ -38,8 +39,10 @@
#include
<
UIKit
/
UIKit
.
h
>
#include
<
UIKit
/
UIKit
.
h
>
#include
<
Foundation
/
Foundation
.
h
>
#include
<
Foundation
/
Foundation
.
h
>
static
int
SetupWindowData
(
_
THIS
,
SDL
_
Window
*
window
,
UIWindow
*
uiwindow
,
SDL
_
bool
created
)
{
static
int
SetupWindowData
(
_
THIS
,
SDL
_
Window
*
window
,
UIWindow
*
uiwindow
,
SDL
_
bool
created
)
{
SDL
_
VideoDisplay
*
display
=
window
->
display
;
UIScreen
*
uiscreen
=
(
UIScreen
*
)
display
->
driverdata
;
SDL
_
WindowData
*
data
;
SDL
_
WindowData
*
data
;
/*
Allocate
the
window
data
*/
/*
Allocate
the
window
data
*/
...
@@ -48,7 +51,6 @@ static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bo
...
@@ -48,7 +51,6 @@ static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bo
SDL_OutOfMemory();
SDL_OutOfMemory();
return -1;
return -1;
}
}
data->window = window;
data->uiwindow = uiwindow;
data->uiwindow = uiwindow;
data->view = nil;
data->view = nil;
...
@@ -68,12 +70,15 @@ static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bo
...
@@ -68,12 +70,15 @@ static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bo
window->flags |= SDL_WINDOW_SHOWN; /* only one window on iPod touch, always shown */
window->flags |= SDL_WINDOW_SHOWN; /* only one window on iPod touch, always shown */
window->flags |= SDL_WINDOW_INPUT_FOCUS; /* always has input focus */
window->flags |= SDL_WINDOW_INPUT_FOCUS; /* always has input focus */
/* SDL_WINDOW_BORDERLESS controls whether status bar is hidden */
// SDL_WINDOW_BORDERLESS controls whether status bar is hidden.
if (window->flags & SDL_WINDOW_BORDERLESS) {
// This is only set if the window is on the main screen. Other screens
[UIApplication sharedApplication].statusBarHidden = YES;
// just force the window to have the borderless flag.
}
if ([UIScreen mainScreen] == uiscreen) {
else {
if (window->flags & SDL_WINDOW_BORDERLESS) {
[UIApplication sharedApplication].statusBarHidden = NO;
[UIApplication sharedApplication].statusBarHidden = YES;
} else {
[UIApplication sharedApplication].statusBarHidden = NO;
}
}
}
return 0;
return 0;
...
@@ -82,41 +87,80 @@ static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bo
...
@@ -82,41 +87,80 @@ 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) {
/* We currently only handle single window applications on iPhone */
SDL_VideoDisplay *display = window->display;
if (nil != [SDLUIKitDelegate sharedAppDelegate].window) {
UIScreen *uiscreen = (UIScreen *)
display
->
driverdata
;
SDL_SetError("Window already exists, no multi-window support.");
//
SDL
currently
puts
this
window
at
the
start
of
display
'
s
linked
list
.
We
rely
on
this
.
SDL
_
assert
(
display
->
windows
==
window
)
;
/*
We
currently
only
handle
a
single
window
per
display
on
iPhone
*/
if
(
window
->
next
!=
NULL
)
{
SDL
_
SetError
(
"Only one window allowed per display."
)
;
return
-
1
;
return
-
1
;
}
}
//
Non
-
mainscreen
windows
must
be
force
to
borderless
,
as
there
'
s
no
//
status
bar
there
,
and
we
want
to
get
the
right
dimensions
later
in
//
this
function
.
if
([
UIScreen
mainScreen
]
!=
uiscreen
)
{
window
->
flags
|=
SDL
_
WINDOW
_
BORDERLESS
;
}
//
If
monitor
has
a
resolution
of
0
x0
(
hasn
'
t
been
explicitly
set
by
the
//
user
,
so
it
'
s
in
standby
)
,
try
to
force
the
display
to
a
resolution
//
that
most
closely
matches
the
desired
window
size
.
if
(
SDL
_
UIKit
_
supports
_
multiple
_
displays
)
{
const
CGSize
origsize
=
[[
uiscreen
currentMode
]
size
]
;
if
((
origsize
.
width
==
0.0
f
)
&&
(
origsize
.
height
==
0.0
f
))
{
if
(
display
->
num
_
display
_
modes
==
0
)
{
_
this
->
GetDisplayModes
(
_
this
,
display
)
;
}
int
i
;
const
SDL
_
DisplayMode
*
bestmode
=
NULL
;
for
(
i
=
display
->
num
_
display
_
modes
;
i
>=
0
;
i
--
)
{
const
SDL
_
DisplayMode
*
mode
=
&
display
->
display
_
modes
[
i
]
;
if
((
mode
->
w
>=
window
->
w
)
&&
(
mode
->
h
>=
window
->
h
))
bestmode
=
mode
;
}
if
(
bestmode
)
{
UIScreenMode
*
uimode
=
(
UIScreenMode
*
)
bestmode
->
driverdata
;
[
uiscreen
setCurrentMode
:
uimode
]
;
display
->
desktop
_
mode
=
*
bestmode
;
display
->
current
_
mode
=
*
bestmode
;
}
}
}
/*
ignore
the
size
user
requested
,
and
make
a
fullscreen
window
*/
/*
ignore
the
size
user
requested
,
and
make
a
fullscreen
window
*/
UIWindow *uiwindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
//
!!!
FIXME
:
can
we
have
a
smaller
view
?
UIWindow
*
uiwindow
=
[
UIWindow
alloc
]
;
if
(
window
->
flags
&
SDL
_
WINDOW
_
BORDERLESS
)
uiwindow
=
[
uiwindow
initWithFrame
:
[
uiscreen
bounds
]]
;
else
uiwindow
=
[
uiwindow
initWithFrame
:
[
uiscreen
applicationFrame
]]
;
if
(
SDL
_
UIKit
_
supports
_
multiple
_
displays
)
{
[
uiwindow
setScreen
:
uiscreen
]
;
}
if
(
SetupWindowData
(
_
this
,
window
,
uiwindow
,
SDL
_
TRUE
)
<
0
)
{
if
(
SetupWindowData
(
_
this
,
window
,
uiwindow
,
SDL
_
TRUE
)
<
0
)
{
[
uiwindow
release
]
;
[
uiwindow
release
]
;
return
-
1
;
return
-
1
;
}
}
// This saves the main window in the app delegate so event callbacks can do stuff on the window.
// This assumes a single window application design and needs to be fixed for multiple windows.
[SDLUIKitDelegate sharedAppDelegate].window = window;
[SDLUIKitDelegate sharedAppDelegate].uiwindow = uiwindow;
[uiwindow release]; /* release the window (the app delegate has retained it) */
return
1
;
return
1
;
}
}
void
UIKit
_
DestroyWindow
(
_
THIS
,
SDL
_
Window
*
window
)
{
void
UIKit
_
DestroyWindow
(
_
THIS
,
SDL
_
Window
*
window
)
{
/* don't worry, the delegate will automatically release the window */
SDL
_
WindowData
*
data
=
(
SDL
_
WindowData
*
)
window
->
driverdata
;
SDL
_
WindowData
*
data
=
(
SDL
_
WindowData
*
)
window
->
driverdata
;
if
(
data
)
{
if
(
data
)
{
SDL
_
free
(
window
->
driverdata
)
;
[
data
->
uiwindow
release
]
;
SDL
_
free
(
data
)
;
window
->
driverdata
=
NULL
;
}
}
/*
this
will
also
destroy
the
window
*/
[
SDLUIKitDelegate
sharedAppDelegate
]
.
window
=
NULL
;
[
SDLUIKitDelegate
sharedAppDelegate
]
.
uiwindow
=
nil
;
}
}
/*
vi
:
set
ts
=
4
sw
=
4
expandtab
:
*/
/*
vi
:
set
ts
=
4
sw
=
4
expandtab
:
*/
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment