diff --git a/Common/System/System.h b/Common/System/System.h index a5d87e4796..7c7b3c4c1b 100644 --- a/Common/System/System.h +++ b/Common/System/System.h @@ -229,6 +229,7 @@ enum class SystemNotification { TEST_JAVA_EXCEPTION, KEEP_SCREEN_AWAKE, ACTIVITY, + UI_STATE_CHANGED, }; // I guess it's not super great architecturally to centralize this, since it's not general - but same with a lot of diff --git a/Core/System.cpp b/Core/System.cpp index 27e9006e7d..01cd8fb066 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -128,6 +128,7 @@ void UpdateUIState(GlobalUIState newState) { if (globalUIState != newState && globalUIState != UISTATE_EXIT) { globalUIState = newState; System_Notify(SystemNotification::DISASSEMBLY); + System_Notify(SystemNotification::UI_STATE_CHANGED); System_SetKeepScreenBright(globalUIState == UISTATE_INGAME); } } diff --git a/ios/ViewController.mm b/ios/ViewController.mm index 48afd931e3..224b22cc65 100644 --- a/ios/ViewController.mm +++ b/ios/ViewController.mm @@ -392,7 +392,22 @@ void GLRenderLoop(IOSGLESContext *graphicsContext) { // Enables tapping for edge area. -(UIRectEdge)preferredScreenEdgesDeferringSystemGestures { - return UIRectEdgeAll; + if (GetUIState() == UISTATE_INGAME) { + // In-game, we need all the control we can get. Though, we could possibly + // allow the top edge? + INFO_LOG(SYSTEM, "Defer system gestures on all edges"); + return UIRectEdgeAll; + } else { + INFO_LOG(SYSTEM, "Allow system gestures on the bottom"); + // Allow task switching gestures to take precedence, without causing + // scroll events in the UI. + return UIRectEdgeTop | UIRectEdgeLeft | UIRectEdgeRight; + } +} + +- (void)uiStateChanged +{ + [self setNeedsUpdateOfScreenEdgesDeferringSystemGestures]; } - (UIView *)getView { diff --git a/ios/ViewControllerCommon.h b/ios/ViewControllerCommon.h index cfbe5e7daf..1e955b66ce 100644 --- a/ios/ViewControllerCommon.h +++ b/ios/ViewControllerCommon.h @@ -20,6 +20,8 @@ - (void)didBecomeActive; - (void)willResignActive; +- (void)uiStateChanged; + @end extern id sharedViewController; diff --git a/ios/ViewControllerMetal.mm b/ios/ViewControllerMetal.mm index 1fd177a8f3..43038c8e61 100644 --- a/ios/ViewControllerMetal.mm +++ b/ios/ViewControllerMetal.mm @@ -477,7 +477,22 @@ extern float g_safeInsetBottom; // Enables tapping for edge area. -(UIRectEdge)preferredScreenEdgesDeferringSystemGestures { - return UIRectEdgeAll; + if (GetUIState() == UISTATE_INGAME) { + // In-game, we need all the control we can get. Though, we could possibly + // allow the top edge? + INFO_LOG(SYSTEM, "Defer system gestures on all edges"); + return UIRectEdgeAll; + } else { + INFO_LOG(SYSTEM, "Allow system gestures on the bottom"); + // Allow task switching gestures to take precedence, without causing + // scroll events in the UI. + return UIRectEdgeTop | UIRectEdgeLeft | UIRectEdgeRight; + } +} + +- (void)uiStateChanged +{ + [self setNeedsUpdateOfScreenEdgesDeferringSystemGestures]; } - (void)bindDefaultFBO diff --git a/ios/main.mm b/ios/main.mm index 48690865b2..f0de32c996 100644 --- a/ios/main.mm +++ b/ios/main.mm @@ -386,7 +386,15 @@ bool System_GetPropertyBool(SystemProperty prop) { void System_Notify(SystemNotification notification) { switch (notification) { - default: break; + case SystemNotification::UI_STATE_CHANGED: + dispatch_async(dispatch_get_main_queue(), ^{ + if (sharedViewController) { + [sharedViewController uiStateChanged]; + } + }); + break; + default: + break; } }