[Scummvm-git-logs] scummvm master -> 4413600f2aa668ae9ab4ac062139ffa7088780a8

larsamannen noreply at scummvm.org
Wed Apr 26 06:30:05 UTC 2023


This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
924d9e63e0 IOS7: Fix detection of orientation on some devices
788411b5fe IOS7: Remove checks that @available can be used
4413600f2a IOS7: Fix missing override keyword


Commit: 924d9e63e0e0393bb66c5dcf309aa8d74713f618
    https://github.com/scummvm/scummvm/commit/924d9e63e0e0393bb66c5dcf309aa8d74713f618
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2023-04-26T08:29:59+02:00

Commit Message:
IOS7: Fix detection of orientation on some devices

The main change in to use the interface orientation and not the device
orientation. This may be different for example when locking the orientation.
This also changes the way orientation changes are detected using the
documented method. However this means dropping support for iOS 7 as this
method is only available since iOS 8, and alternative methods available in
iOS 7 have been deprecated in iOS 13.

Another change is to properly detect the interface orientation instead of
infering it from the view bounds, which was incorrect on some devices.

Changed paths:
    backends/platform/ios7/ios7_app_delegate.mm
    backends/platform/ios7/ios7_scummvm_view_controller.h
    backends/platform/ios7/ios7_scummvm_view_controller.mm
    backends/platform/ios7/ios7_video.h
    backends/platform/ios7/ios7_video.mm


diff --git a/backends/platform/ios7/ios7_app_delegate.mm b/backends/platform/ios7/ios7_app_delegate.mm
index 4a8140a383b..fe0797dade5 100644
--- a/backends/platform/ios7/ios7_app_delegate.mm
+++ b/backends/platform/ios7/ios7_app_delegate.mm
@@ -67,14 +67,6 @@
 	[_window setRootViewController:_controller];
 	[_window makeKeyAndVisible];
 
-#if TARGET_OS_IOS
-	[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
-	[[NSNotificationCenter defaultCenter] addObserver:self
-	                                         selector:@selector(didRotate:)
-	                                             name:@"UIDeviceOrientationDidChangeNotification"
-	                                           object:nil];
-#endif
-
 	// Force creation of the shared instance on the main thread
 	iOS7_buildSharedOSystemInstance();
 
@@ -98,8 +90,16 @@
 	// Make sure we have the correct orientation in case the orientation was changed while
 	// the app was inactive.
 #if TARGET_OS_IOS
-	UIDeviceOrientation screenOrientation = [[UIDevice currentDevice] orientation];
-	[_view deviceOrientationChanged:screenOrientation];
+	UIInterfaceOrientation interfaceOrientation = UIInterfaceOrientationUnknown;
+	if (@available(iOS 13.0, *)) {
+		interfaceOrientation = [[[_view window] windowScene] interfaceOrientation];
+	} else {
+		interfaceOrientation = [[UIApplication sharedApplication] statusBarOrientation];
+	}
+	if (interfaceOrientation != UIInterfaceOrientationUnknown) {
+		[_view interfaceOrientationChanged:interfaceOrientation];
+		[_controller setCurrentOrientation: interfaceOrientation];
+	}
 #endif
 }
 
@@ -124,13 +124,6 @@
 	_restoreState = YES;
 }
 
-- (void)didRotate:(NSNotification *)notification {
-#if TARGET_OS_IOS
-	UIDeviceOrientation screenOrientation = [[UIDevice currentDevice] orientation];
-	[_view deviceOrientationChanged:screenOrientation];
-#endif
-}
-
 + (iOS7AppDelegate *)iOS7AppDelegate {
 	UIApplication *app = [UIApplication sharedApplication];
 	// [UIApplication delegate] must be used from the main thread only
diff --git a/backends/platform/ios7/ios7_scummvm_view_controller.h b/backends/platform/ios7/ios7_scummvm_view_controller.h
index cc62c58ae85..9b6cf004d56 100644
--- a/backends/platform/ios7/ios7_scummvm_view_controller.h
+++ b/backends/platform/ios7/ios7_scummvm_view_controller.h
@@ -25,7 +25,15 @@
 #include <UIKit/UIKit.h>
 
 
- at interface iOS7ScummVMViewController : UIViewController
+ at interface iOS7ScummVMViewController : UIViewController {
+#if TARGET_OS_IOS
+	UIInterfaceOrientation currentOrientation;
+#endif
+}
+
+#if TARGET_OS_IOS
+-(void) setCurrentOrientation:(UIInterfaceOrientation)orientation;
+#endif
 
 @end
 
diff --git a/backends/platform/ios7/ios7_scummvm_view_controller.mm b/backends/platform/ios7/ios7_scummvm_view_controller.mm
index 0072f909b78..6d66b8c92ec 100644
--- a/backends/platform/ios7/ios7_scummvm_view_controller.mm
+++ b/backends/platform/ios7/ios7_scummvm_view_controller.mm
@@ -20,10 +20,19 @@
  */
 
 #include "backends/platform/ios7/ios7_scummvm_view_controller.h"
-
+#include "backends/platform/ios7/ios7_app_delegate.h"
+#include "backends/platform/ios7/ios7_video.h"
 
 @implementation iOS7ScummVMViewController
 
+- (id)init {
+	self = [super init];
+#if TARGET_OS_IOS
+	self->currentOrientation = UIInterfaceOrientationUnknown;
+#endif
+	return self;
+}
+
 - (BOOL)prefersStatusBarHidden {
 	return YES;
 }
@@ -37,4 +46,43 @@
 	return YES;
 }
 
+#if TARGET_OS_IOS
+-(void) setCurrentOrientation:(UIInterfaceOrientation)orientation {
+	if (orientation != currentOrientation) {
+		currentOrientation = orientation;
+		[[iOS7AppDelegate iPhoneView] interfaceOrientationChanged:currentOrientation];
+	}
+}
+
+- (void)viewDidAppear:(BOOL)animated {
+	[super viewDidAppear:animated];
+
+	UIInterfaceOrientation orientationBefore = UIInterfaceOrientationUnknown;
+	if (@available(iOS 13.0, *)) {
+		orientationBefore = [[[[self view] window] windowScene] interfaceOrientation];
+	} else {
+		orientationBefore = [[UIApplication sharedApplication] statusBarOrientation];
+	}
+	if (currentOrientation != UIInterfaceOrientationUnknown)
+		[[iOS7AppDelegate iPhoneView] interfaceOrientationChanged:currentOrientation];
+}
+
+- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
+	[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
+
+	[coordinator animateAlongsideTransition:nil completion:^(id<UIViewControllerTransitionCoordinatorContext> context) {
+		UIInterfaceOrientation orientationAfter = UIInterfaceOrientationUnknown;
+		if (@available(iOS 13.0, *)) {
+			orientationAfter = [[[[self view] window] windowScene] interfaceOrientation];
+		} else {
+			orientationAfter = [[UIApplication sharedApplication] statusBarOrientation];
+		}
+		if (orientationAfter != UIInterfaceOrientationUnknown && orientationAfter != currentOrientation) {
+			currentOrientation = orientationAfter;
+			[[iOS7AppDelegate iPhoneView] interfaceOrientationChanged:currentOrientation];
+		}
+	}];
+}
+#endif
+
 @end
diff --git a/backends/platform/ios7/ios7_video.h b/backends/platform/ios7/ios7_video.h
index d848f4705e3..e4dccf2fa3d 100644
--- a/backends/platform/ios7/ios7_video.h
+++ b/backends/platform/ios7/ios7_video.h
@@ -117,7 +117,7 @@ uint getSizeNextPOT(uint size);
 - (void)updateMouseCursor;
 
 #if TARGET_OS_IOS
-- (void)deviceOrientationChanged:(UIDeviceOrientation)orientation;
+- (void)interfaceOrientationChanged:(UIInterfaceOrientation)orientation;
 #endif
 
 - (void)showKeyboard;
diff --git a/backends/platform/ios7/ios7_video.mm b/backends/platform/ios7/ios7_video.mm
index cd52295aabd..1190c782c12 100644
--- a/backends/platform/ios7/ios7_video.mm
+++ b/backends/platform/ios7/ios7_video.mm
@@ -686,14 +686,23 @@ uint getSizeNextPOT(uint size) {
 		[self rebuildFrameBuffer];
 	}
 
-	BOOL isLandscape = (self.bounds.size.width > self.bounds.size.height); // UIDeviceOrientationIsLandscape([[UIDevice currentDevice] orientation]);
+#if TARGET_OS_IOS
+	UIInterfaceOrientation interfaceOrientation = UIInterfaceOrientationUnknown;
+	if (@available(iOS 13.0, *)) {
+		interfaceOrientation = [[[self window] windowScene] interfaceOrientation];
+	} else {
+		interfaceOrientation = [[UIApplication sharedApplication] statusBarOrientation];
+	}
+	BOOL isLandscape = UIInterfaceOrientationIsLandscape(interfaceOrientation);
+#else // TVOS
+	BOOL isLandscape = YES;
+#endif
 
 	int screenWidth, screenHeight;
 	if (isLandscape) {
 		screenWidth = MAX(_renderBufferWidth, _renderBufferHeight);
 		screenHeight = MIN(_renderBufferWidth, _renderBufferHeight);
-	}
-	else {
+	} else {
 		screenWidth = MIN(_renderBufferWidth, _renderBufferHeight);
 		screenHeight = MAX(_renderBufferWidth, _renderBufferHeight);
 	}
@@ -794,9 +803,16 @@ uint getSizeNextPOT(uint size) {
 		CGRect newFrame = screenSize;
 #if TARGET_OS_IOS
 		UIEdgeInsets inset = [[[UIApplication sharedApplication] keyWindow] safeAreaInsets];
-		UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
+		UIInterfaceOrientation orientation = UIInterfaceOrientationUnknown;
+		if (@available(iOS 13.0, *)) {
+			orientation = [[[self window] windowScene] interfaceOrientation];
+		} else {
+			orientation = [[UIApplication sharedApplication] statusBarOrientation];
+		}
 		if ( orientation == UIInterfaceOrientationPortrait ) {
 			newFrame = CGRectMake(screenSize.origin.x, screenSize.origin.y + inset.top, screenSize.size.width, screenSize.size.height - inset.top);
+		} else if ( orientation == UIInterfaceOrientationPortraitUpsideDown ) {
+			newFrame = CGRectMake(screenSize.origin.x, screenSize.origin.y, screenSize.size.width, screenSize.size.height - inset.top);
 		} else if ( orientation == UIInterfaceOrientationLandscapeLeft ) {
 			newFrame = CGRectMake(screenSize.origin.x, screenSize.origin.y, screenSize.size.width - inset.right, screenSize.size.height);
 		} else if ( orientation == UIInterfaceOrientationLandscapeRight ) {
@@ -920,11 +936,9 @@ uint getSizeNextPOT(uint size) {
 }
 
 #if TARGET_OS_IOS
-- (void)deviceOrientationChanged:(UIDeviceOrientation)orientation {
+- (void)interfaceOrientationChanged:(UIInterfaceOrientation)orientation {
 	[self addEvent:InternalEvent(kInputOrientationChanged, orientation, 0)];
-
-	BOOL isLandscape = (self.bounds.size.width > self.bounds.size.height);
-	if (isLandscape) {
+	if (UIInterfaceOrientationIsLandscape(orientation)) {
 		[self hideKeyboard];
 	} else {
 		[self showKeyboard];


Commit: 788411b5fe893655ef4e0b6208f14eea234fefab
    https://github.com/scummvm/scummvm/commit/788411b5fe893655ef4e0b6208f14eea234fefab
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2023-04-26T08:29:59+02:00

Commit Message:
IOS7: Remove checks that @available can be used

This was used in the past to make sure the code can be compiled
with old compilers that do not support using @available. But we
already dropped support for those old compilers, and in many
places already used @available without checking first that it can
be used.

Changed paths:
    backends/platform/ios7/ios7_keyboard.mm
    backends/platform/ios7/ios7_video.mm


diff --git a/backends/platform/ios7/ios7_keyboard.mm b/backends/platform/ios7/ios7_keyboard.mm
index a20568eb767..40f7674158b 100644
--- a/backends/platform/ios7/ios7_keyboard.mm
+++ b/backends/platform/ios7/ios7_keyboard.mm
@@ -56,11 +56,7 @@
 	// The code only compils with the iOS 9.0+ SDK, and only works on iOS 9.0
 	// or above.
 #ifdef __IPHONE_9_0
-#if __has_builtin(__builtin_available)
 	if ( @available(iOS 9,*) ) {
-#else
-	if ( [self respondsToSelector:@selector(inputAssistantItem)] ) {
-#endif
 		UITextInputAssistantItem* item = [self inputAssistantItem];
 		if (item) {
 			item.leadingBarButtonGroups = @[];
diff --git a/backends/platform/ios7/ios7_video.mm b/backends/platform/ios7/ios7_video.mm
index 1190c782c12..25f97c15eda 100644
--- a/backends/platform/ios7/ios7_video.mm
+++ b/backends/platform/ios7/ios7_video.mm
@@ -794,11 +794,7 @@ uint getSizeNextPOT(uint size) {
 	// So for now disable this code when compiled with an older SDK, which means it is only
 	// available when running on iOS 11+ if it has been compiled on iOS 11+
 #ifdef __IPHONE_11_0
-#if __has_builtin(__builtin_available)
 	if ( @available(iOS 11, tvOS 11, *) ) {
-#else
-	if ( [[[UIApplication sharedApplication] keyWindow] respondsToSelector:@selector(safeAreaInsets)] ) {
-#endif
 		CGRect screenSize = [[UIScreen mainScreen] bounds];
 		CGRect newFrame = screenSize;
 #if TARGET_OS_IOS


Commit: 4413600f2aa668ae9ab4ac062139ffa7088780a8
    https://github.com/scummvm/scummvm/commit/4413600f2aa668ae9ab4ac062139ffa7088780a8
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2023-04-26T08:29:59+02:00

Commit Message:
IOS7: Fix missing override keyword

Changed paths:
    backends/platform/ios7/ios7_osys_main.h


diff --git a/backends/platform/ios7/ios7_osys_main.h b/backends/platform/ios7/ios7_osys_main.h
index 9b029b721fe..9959cf6fcd9 100644
--- a/backends/platform/ios7/ios7_osys_main.h
+++ b/backends/platform/ios7/ios7_osys_main.h
@@ -218,7 +218,7 @@ public:
 
 	bool isConnectionLimited() override;
 
-	virtual Common::String getDefaultLogFileName() { return Common::String("/var/mobile/.scummvm.log"); }
+	virtual Common::String getDefaultLogFileName() override { return Common::String("/var/mobile/.scummvm.log"); }
 
 protected:
 	void initVideoContext();




More information about the Scummvm-git-logs mailing list