SDL icon indicating copy to clipboard operation
SDL copied to clipboard

Interface to get safeArea for notched devices (display cutouts) such as iPhone XR?

Open SDLBugzilla opened this issue 5 years ago • 5 comments

This bug report was migrated from our old Bugzilla tracker.

Reported in version: HG 2.1 Reported for operating system, platform: Windows 10, iPhone/iPod touch

Comments on the original bug report:

On 2019-04-19 17:52:22 +0000, Dan Ginsburg wrote:

Notched devices such as the iPhone X/iPhone XR require applications to not render UI over the "safeArea" such as the notch. This can be queried from the UIView usinng safeAreaInsets:

https://developer.apple.com/documentation/uikit/uiview/2891103-safeareainsets

It appears to me that Android has a similar API:

https://developer.android.com/guide/topics/display-cutout

Unity exposes this concept via a safeArea:

https://connect.unity.com/p/updating-your-gui-for-the-iphone-x-and-other-notched-devices

Has an interface been considered to add this to SDL? For now I can workaround it using platform-specific APIs but it seems this is probably a feature that SDL needs for mobile devices.

SDLBugzilla avatar Feb 11 '21 01:02 SDLBugzilla

We have SDL_GetDisplayUsableBounds() which could honor the SafeAreaInset, but my understanding is you can draw to the whole display otherwise, and this is just to tell the app not to put something critical (or touchable) where the notch is...so this might need a new API. Doesn't have to be iOS-specific, since sooner or later Android is going to do this too, I'm sure.

(Also the newest MacBook Pros also have a notch, so check if there's a macOS equivalent API now.)

icculus avatar Nov 30 '21 13:11 icculus

Here's a good overview of the issues involved: https://blog.felgo.com/cross-platform-app-development/notch-developer-guide-ios-android

slouken avatar Apr 29 '22 00:04 slouken

Here are the relevant Unity APIs: https://docs.unity3d.com/ScriptReference/Screen-safeArea.html https://docs.unity3d.com/ScriptReference/Screen-cutouts.html

slouken avatar Apr 29 '22 00:04 slouken

More detail on iOS safe area and insets: https://blog.smartnsoft.com/layout-guide-margins-insets-and-safe-area-demystified-on-ios-10-11-d6e7246d7cb8

slouken avatar Apr 29 '22 00:04 slouken

Here's how VLC handled the notch on the new MacBook Pro: https://code.videolan.org/videolan/vlc/-/issues/26291

slouken avatar Apr 29 '22 00:04 slouken