iOS: Use modern replacements for deprecated functions, when available.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h
index 94ba285..d1f5658 100644
--- a/src/video/SDL_sysvideo.h
+++ b/src/video/SDL_sysvideo.h
@@ -419,12 +419,12 @@ extern SDL_bool SDL_ShouldAllowTopmost(void);
extern float SDL_ComputeDiagonalDPI(int hpix, int vpix, float hinches, float vinches);
-extern void SDL_OnApplicationWillTerminate();
-extern void SDL_OnApplicationDidReceiveMemoryWarning();
-extern void SDL_OnApplicationWillResignActive();
-extern void SDL_OnApplicationDidEnterBackground();
-extern void SDL_OnApplicationWillEnterForeground();
-extern void SDL_OnApplicationDidBecomeActive();
+extern void SDL_OnApplicationWillTerminate(void);
+extern void SDL_OnApplicationDidReceiveMemoryWarning(void);
+extern void SDL_OnApplicationWillResignActive(void);
+extern void SDL_OnApplicationDidEnterBackground(void);
+extern void SDL_OnApplicationWillEnterForeground(void);
+extern void SDL_OnApplicationDidBecomeActive(void);
#endif /* SDL_sysvideo_h_ */
diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
index 7b1bffd..ab3a8ef 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -3863,17 +3863,17 @@ SDL_ComputeDiagonalDPI(int hpix, int vpix, float hinches, float vinches)
/*
* Functions used by iOS application delegates
*/
-void SDL_OnApplicationWillTerminate()
+void SDL_OnApplicationWillTerminate(void)
{
SDL_SendAppEvent(SDL_APP_TERMINATING);
}
-void SDL_OnApplicationDidReceiveMemoryWarning()
+void SDL_OnApplicationDidReceiveMemoryWarning(void)
{
SDL_SendAppEvent(SDL_APP_LOWMEMORY);
}
-void SDL_OnApplicationWillResignActive()
+void SDL_OnApplicationWillResignActive(void)
{
if (_this) {
SDL_Window *window;
@@ -3885,17 +3885,17 @@ void SDL_OnApplicationWillResignActive()
SDL_SendAppEvent(SDL_APP_WILLENTERBACKGROUND);
}
-void SDL_OnApplicationDidEnterBackground()
+void SDL_OnApplicationDidEnterBackground(void)
{
SDL_SendAppEvent(SDL_APP_DIDENTERBACKGROUND);
}
-void SDL_OnApplicationWillEnterForeground()
+void SDL_OnApplicationWillEnterForeground(void)
{
SDL_SendAppEvent(SDL_APP_WILLENTERFOREGROUND);
}
-void SDL_OnApplicationDidBecomeActive()
+void SDL_OnApplicationDidBecomeActive(void)
{
SDL_SendAppEvent(SDL_APP_DIDENTERFOREGROUND);
diff --git a/src/video/uikit/SDL_uikitappdelegate.m b/src/video/uikit/SDL_uikitappdelegate.m
index 17dc4d9..b2badaa 100644
--- a/src/video/uikit/SDL_uikitappdelegate.m
+++ b/src/video/uikit/SDL_uikitappdelegate.m
@@ -513,23 +513,24 @@ SDL_LoadLaunchImageNamed(NSString *name, int screenh)
SDL_SendDropComplete(NULL);
}
-#if TARGET_OS_TV
-/* TODO: Use this on iOS 9+ as well? */
+#if TARGET_OS_TV || (defined(__IPHONE_9_0) && __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_9_0)
+
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
/* TODO: Handle options */
[self sendDropFileForURL:url];
return YES;
}
-#endif /* TARGET_OS_TV */
-#if !TARGET_OS_TV
+#else
+
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
[self sendDropFileForURL:url];
return YES;
}
-#endif /* !TARGET_OS_TV */
+
+#endif
@end
diff --git a/src/video/uikit/SDL_uikitmodes.m b/src/video/uikit/SDL_uikitmodes.m
index 12a4083..0798166 100644
--- a/src/video/uikit/SDL_uikitmodes.m
+++ b/src/video/uikit/SDL_uikitmodes.m
@@ -273,6 +273,7 @@ UIKit_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect)
@autoreleasepool {
int displayIndex = (int) (display - _this->displays);
SDL_DisplayData *data = (__bridge SDL_DisplayData *) display->driverdata;
+ CGRect frame = data.uiscreen.bounds;
/* the default function iterates displays to make a fake offset,
as if all the displays were side-by-side, which is fine for iOS. */
@@ -280,9 +281,7 @@ UIKit_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect)
return -1;
}
- CGRect frame = data.uiscreen.bounds;
-
-#if !TARGET_OS_TV
+#if !TARGET_OS_TV && __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_7_0
if (!UIKit_IsSystemVersionAtLeast(7.0)) {
frame = [data.uiscreen applicationFrame];
}
diff --git a/src/video/uikit/SDL_uikitviewcontroller.m b/src/video/uikit/SDL_uikitviewcontroller.m
index a8e36ef..a4be1ed 100644
--- a/src/video/uikit/SDL_uikitviewcontroller.m
+++ b/src/video/uikit/SDL_uikitviewcontroller.m
@@ -114,7 +114,22 @@ SDL_AppleTVControllerUIHintChanged(void *userdata, const char *name, const char
- (void)startAnimation
{
displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(doLoop:)];
- [displayLink setFrameInterval:animationInterval];
+
+#ifdef __IPHONE_10_3
+ SDL_WindowData *data = (__bridge SDL_WindowData *) window->driverdata;
+
+ if ([displayLink respondsToSelector:@selector(preferredFramesPerSecond)]
+ && data != nil && data.uiwindow != nil
+ && [data.uiwindow.screen respondsToSelector:@selector(maximumFramesPerSecond)]) {
+ displayLink.preferredFramesPerSecond = data.uiwindow.screen.maximumFramesPerSecond / animationInterval;
+ } else
+#endif
+ {
+#if __IPHONE_OS_VERSION_MIN_REQUIRED < 100300
+ [displayLink setFrameInterval:animationInterval];
+#endif
+ }
+
[displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
}
@@ -155,10 +170,12 @@ SDL_AppleTVControllerUIHintChanged(void *userdata, const char *name, const char
return UIKit_GetSupportedOrientations(window);
}
+#if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_7_0
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orient
{
return ([self supportedInterfaceOrientations] & (1 << orient)) != 0;
}
+#endif
- (BOOL)prefersStatusBarHidden
{