v3.2.4: adjusted iOS safe inset sizes

This commit is contained in:
Evan Debenham
2025-09-07 16:44:56 -04:00
committed by Evan Debenham
parent b142589b04
commit 88a59ff342

View File

@@ -62,25 +62,22 @@ public class IOSPlatformSupport extends PlatformSupport {
public RectF getSafeInsets(int level) { public RectF getSafeInsets(int level) {
RectF insets = super.getSafeInsets(INSET_ALL); RectF insets = super.getSafeInsets(INSET_ALL);
//magic number BS for larger status bar caused by dynamic island
boolean hasDynamicIsland = insets.top / Gdx.graphics.getBackBufferScale() >= 51;
//iOS gives us ALL insets by default, and so we need to filter from there: //iOS gives us ALL insets by default, and so we need to filter from there:
//ignore the home indicator if we're in fullscreen //ignore the home indicator if we're in fullscreen
if (!supportsFullScreen() || SPDSettings.fullscreen()){ if (!supportsFullScreen() || SPDSettings.fullscreen()){
insets.bottom = 0; insets.bottom = 0;
} else {
//otherwise bottom inset is pretty big, halve it
insets.bottom /= 2;
} }
//only cutouts can be on top/left/right, which are never blocking //only cutouts can be on top/left/right, which are never blocking
if (level == INSET_BLK){ if (level == INSET_BLK){
insets.left = insets.top = insets.right = 0; insets.left = insets.top = insets.right = 0;
} else if (level == INSET_LRG){ } else if (level == INSET_LRG && hasDynamicIsland){
//Dynamic Island counts as a 'small cutout', we have to use status bar height to get it =I //Dynamic Island counts as a 'small cutout'
double statusBarHeight = insets.top / Gdx.graphics.getBackBufferScale(); insets.left = insets.top = insets.right = 0;
if (statusBarHeight >= 51){ //magic number BS for larger status bar caused by island
insets.left = insets.top = insets.right = 0;
}
} }
//if we are in landscape, the display cutout is only actually on one side, so cancel the other //if we are in landscape, the display cutout is only actually on one side, so cancel the other
@@ -92,6 +89,12 @@ public class IOSPlatformSupport extends PlatformSupport {
} }
} }
//finally iOS is very conservative with these insets, we can shrink them a bit.
insets.top /= hasDynamicIsland ? 1.2f : 1.4f;
insets.left /= hasDynamicIsland ? 1.2f : 1.4f;
insets.right /= hasDynamicIsland ? 1.2f : 1.4f;
insets.bottom /= 2; //home bar inset is especially big for no reason
return insets; return insets;
} }