summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2020-07-30 00:43:03 +0200
committerGitHub <noreply@github.com>2020-07-30 00:43:03 +0200
commit35ff38b3d4336b757bce714477bf5ed61b0cd7f3 (patch)
tree36210f60adb2cfe01ab7cc13481985c4da9caca4
parentdd9b89580fe56cda841801946ee667f07bcf52bb (diff)
parent2e705fd620dc0e7509a14f8d1ff01914c2b89327 (diff)
Merge pull request #40761 from naithar/feature/ios-safe_area
[iOS] Safe area reimplementation
-rw-r--r--platform/iphone/display_server_iphone.mm17
1 files changed, 16 insertions, 1 deletions
diff --git a/platform/iphone/display_server_iphone.mm b/platform/iphone/display_server_iphone.mm
index aafee49594..1721da3db6 100644
--- a/platform/iphone/display_server_iphone.mm
+++ b/platform/iphone/display_server_iphone.mm
@@ -492,7 +492,22 @@ Size2i DisplayServerIPhone::screen_get_size(int p_screen) const {
}
Rect2i DisplayServerIPhone::screen_get_usable_rect(int p_screen) const {
- return Rect2i(screen_get_position(p_screen), screen_get_size(p_screen));
+ if (@available(iOS 11, *)) {
+ UIEdgeInsets insets = UIEdgeInsetsZero;
+ UIView *view = AppDelegate.viewController.godotView;
+
+ if ([view respondsToSelector:@selector(safeAreaInsets)]) {
+ insets = [view safeAreaInsets];
+ }
+
+ float scale = screen_get_scale(p_screen);
+ Size2i insets_position = Size2i(insets.left, insets.top) * scale;
+ Size2i insets_size = Size2i(insets.left + insets.right, insets.top + insets.bottom) * scale;
+
+ return Rect2i(screen_get_position(p_screen) + insets_position, screen_get_size(p_screen) - insets_size);
+ } else {
+ return Rect2i(screen_get_position(p_screen), screen_get_size(p_screen));
+ }
}
int DisplayServerIPhone::screen_get_dpi(int p_screen) const {