Hide deprecation warnings on statusBarOrientation, statusBarHidden, statusBarStyle

This commit is contained in:
DominusExult
2026-02-15 17:19:59 +01:00
committed by Sam Lantinga
parent 5d1e390a9c
commit 016a1b87a6
6 changed files with 62 additions and 7 deletions

View File

@@ -238,7 +238,10 @@ static SDL_CameraFrameResult COREMEDIA_AcquireFrame(SDL_Camera *device, SDL_Surf
hidden.last_device_orientation = device_orientation; // update the last known-good orientation for later.
}
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
const UIInterfaceOrientation ui_orientation = [UIApplication sharedApplication].statusBarOrientation;
#pragma clang diagnostic pop
// there is probably math for this, but this is easy to slap into a table.
// rotation = rotations[uiorientation-1][devorientation-1];
@@ -468,7 +471,10 @@ static bool COREMEDIA_OpenDevice(SDL_Camera *device, const SDL_CameraSpec *spec)
hidden.last_device_orientation = uidevice.orientation;
if (!UIDeviceOrientationIsValidInterfaceOrientation(hidden.last_device_orientation)) {
// accelerometer isn't ready yet or the phone is laying flat or something. Just try to guess from how the UI is oriented at the moment.
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
switch ([UIApplication sharedApplication].statusBarOrientation) {
#pragma clang diagnostic pop
case UIInterfaceOrientationPortrait: hidden.last_device_orientation = UIDeviceOrientationPortrait; break;
case UIInterfaceOrientationPortraitUpsideDown: hidden.last_device_orientation = UIDeviceOrientationPortraitUpsideDown; break;
case UIInterfaceOrientationLandscapeLeft: hidden.last_device_orientation = UIDeviceOrientationLandscapeRight; break; // Apple docs say UI and device orientations are reversed in landscape.
@@ -589,9 +595,13 @@ static void COREMEDIA_DetectDevices(void)
devices = discoverySession.devices;
// !!! FIXME: this can use Key Value Observation to get hotplug events.
} else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
// this is deprecated but works back to macOS 10.7; 10.15 added AVCaptureDeviceDiscoverySession as a replacement.
devices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo];
// !!! FIXME: this can use AVCaptureDeviceWasConnectedNotification and AVCaptureDeviceWasDisconnectedNotification with NSNotificationCenter to get hotplug events.
#pragma clang diagnostic pop
}
for (AVCaptureDevice *device in devices) {

View File

@@ -67,7 +67,10 @@ int SDL_RunApp(int argc, char *argv[], SDL_main_func mainFunction, void *reserve
// Load a launch image using the old UILaunchImageFile-era naming rules.
static UIImage *SDL_LoadLaunchImageNamed(NSString *name, int screenh)
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
UIInterfaceOrientation curorient = [UIApplication sharedApplication].statusBarOrientation;
#pragma clang diagnostic pop
UIUserInterfaceIdiom idiom = [UIDevice currentDevice].userInterfaceIdiom;
UIImage *image = nil;
@@ -127,8 +130,11 @@ static UIImage *SDL_LoadLaunchImageNamed(NSString *name, int screenh)
[self.storyboardViewController didMoveToParentViewController:self];
#ifndef SDL_PLATFORM_VISIONOS
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
UIApplication.sharedApplication.statusBarHidden = self.prefersStatusBarHidden;
UIApplication.sharedApplication.statusBarStyle = self.preferredStatusBarStyle;
#pragma clang diagnostic pop
#endif
}
@@ -207,7 +213,10 @@ static UIImage *SDL_LoadLaunchImageNamed(NSString *name, int screenh)
#if !defined(SDL_PLATFORM_TVOS) && !defined(SDL_PLATFORM_VISIONOS)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
UIInterfaceOrientation curorient = [UIApplication sharedApplication].statusBarOrientation;
#pragma clang diagnostic pop
// We always want portrait-oriented size, to match UILaunchImageSize.
if (screenw > screenh) {

View File

@@ -62,10 +62,13 @@ static BOOL UIKit_EventPumpEnabled = YES;
[notificationCenter addObserver:self selector:@selector(applicationWillTerminate) name:UIApplicationWillTerminateNotification object:nil];
[notificationCenter addObserver:self selector:@selector(applicationDidReceiveMemoryWarning) name:UIApplicationDidReceiveMemoryWarningNotification object:nil];
#if !defined(SDL_PLATFORM_TVOS) && !defined(SDL_PLATFORM_VISIONOS)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[notificationCenter addObserver:self
selector:@selector(applicationDidChangeStatusBarOrientation)
name:UIApplicationDidChangeStatusBarOrientationNotification
object:nil];
#pragma clang diagnostic pop
#endif
} else if (!wants_observation && self.isObservingNotifications) {
self.isObservingNotifications = NO;

View File

@@ -330,7 +330,10 @@ bool UIKit_IsDisplayLandscape(UIScreen *uiscreen)
{
#ifndef SDL_PLATFORM_TVOS
if (uiscreen == [UIScreen mainScreen]) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
return UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation);
#pragma clang diagnostic pop
} else
#endif // !SDL_PLATFORM_TVOS
{
@@ -484,7 +487,10 @@ void UIKit_QuitModes(SDL_VideoDevice *_this)
#if !defined(SDL_PLATFORM_TVOS) && !defined(SDL_PLATFORM_VISIONOS)
void SDL_OnApplicationDidChangeStatusBarOrientation(void)
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
BOOL isLandscape = UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation);
#pragma clang diagnostic pop
SDL_VideoDisplay *display = SDL_GetVideoDisplay(SDL_GetPrimaryDisplay());
if (display) {
@@ -518,7 +524,10 @@ void SDL_OnApplicationDidChangeStatusBarOrientation(void)
}
}
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
switch ([UIApplication sharedApplication].statusBarOrientation) {
#pragma clang diagnostic pop
case UIInterfaceOrientationPortrait:
orientation = SDL_ORIENTATION_PORTRAIT;
break;

View File

@@ -237,7 +237,10 @@ CGRect UIKit_ComputeViewFrame(SDL_Window *window, UIScreen *screen)
* https://bugzilla.libsdl.org/show_bug.cgi?id=3505
* https://bugzilla.libsdl.org/show_bug.cgi?id=3465
* https://forums.developer.apple.com/thread/65337 */
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
UIInterfaceOrientation orient = [UIApplication sharedApplication].statusBarOrientation;
#pragma clang diagnostic pop
BOOL landscape = UIInterfaceOrientationIsLandscape(orient) ||
!(UIKit_GetSupportedOrientations(window) & (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown));
BOOL fullscreen = CGRectEqualToRect(screen.bounds, frame);

View File

@@ -163,10 +163,17 @@ bool UIKit_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Properti
}
if (data.uiscreen == [UIScreen mainScreen]) {
if (window->flags & (SDL_WINDOW_FULLSCREEN | SDL_WINDOW_BORDERLESS)) {
[UIApplication sharedApplication].statusBarHidden = YES;
if (@available(iOS 13.0, *)) {
// iOS 13+ uses view controller's prefersStatusBarHidden
} else {
[UIApplication sharedApplication].statusBarHidden = NO;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
if (window->flags & (SDL_WINDOW_FULLSCREEN | SDL_WINDOW_BORDERLESS)) {
[UIApplication sharedApplication].statusBarHidden = YES;
} else {
[UIApplication sharedApplication].statusBarHidden = NO;
}
#pragma clang diagnostic pop
}
}
#endif // !SDL_PLATFORM_TVOS
@@ -193,7 +200,14 @@ bool UIKit_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Properti
// put the window on an external display if appropriate.
#ifndef SDL_PLATFORM_VISIONOS
if (data.uiscreen != [UIScreen mainScreen]) {
[uiwindow setScreen:data.uiscreen];
if (@available(iOS 13.0, tvOS 13.0, *)) {
// iOS 13+ uses UIWindowScene to manage screen association
} else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[uiwindow setScreen:data.uiscreen];
#pragma clang diagnostic pop
}
}
#endif
@@ -277,10 +291,17 @@ static void UIKit_UpdateWindowBorder(SDL_VideoDevice *_this, SDL_Window *window)
#if !defined(SDL_PLATFORM_TVOS) && !defined(SDL_PLATFORM_VISIONOS)
if (data.uiwindow.screen == [UIScreen mainScreen]) {
if (window->flags & (SDL_WINDOW_FULLSCREEN | SDL_WINDOW_BORDERLESS)) {
[UIApplication sharedApplication].statusBarHidden = YES;
if (@available(iOS 13.0, *)) {
// iOS 13+ uses view controller's prefersStatusBarHidden
} else {
[UIApplication sharedApplication].statusBarHidden = NO;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
if (window->flags & (SDL_WINDOW_FULLSCREEN | SDL_WINDOW_BORDERLESS)) {
[UIApplication sharedApplication].statusBarHidden = YES;
} else {
[UIApplication sharedApplication].statusBarHidden = NO;
}
#pragma clang diagnostic pop
}
[viewcontroller setNeedsStatusBarAppearanceUpdate];