From 0b6ffd7c5e07595071ff9abc6aeb9a5c94c2133a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 12 Oct 2026 18:56:07 +0200 Subject: [PATCH] Android: Don't leave room for system bars we hid Before Android 11, decorFitsSystemWindows(false) sets LAYOUT_STABLE, and the system bar insets then keep the space of hidden bars. So in landscape, where the status bar is always hidden, the UI had an empty band at the top (seen on a Galaxy S8 and a Pocophone F1). Count only the bars we show, and reapply the insets after changing that. Co-Authored-By: Claude Opus 5.5 --- .../src/org/ppsspp/ppsspp/PpssppActivity.java | 40 +++++++++++++------ 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/android/src/org/ppsspp/ppsspp/PpssppActivity.java b/android/src/org/ppsspp/ppsspp/PpssppActivity.java index 91fdc64c38..24492aef11 100644 --- a/android/src/org/ppsspp/ppsspp/PpssppActivity.java +++ b/android/src/org/ppsspp/ppsspp/PpssppActivity.java @@ -91,6 +91,10 @@ public class PpssppActivity extends AppCompatActivity implements SensorEventList // The surface we hand to the native render loop thread, for both OpenGL and Vulkan. private NativeSurfaceView mSurfaceView; + // Which bars updateSystemUiVisibility hid. Before Android 11, the insets don't tell us: decorFitsSystemWindows(false) + // sets LAYOUT_STABLE, so they keep the space of hidden bars. + private boolean statusBarsHidden = false; + private boolean navigationBarsHidden = false; private Surface mSurface; // For accelerometer sensing. @@ -635,19 +639,22 @@ public class PpssppActivity extends AppCompatActivity implements SensorEventList WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE ); - if (orientation == Configuration.ORIENTATION_LANDSCAPE) { - if (useImmersive()) { - controller.hide(WindowInsetsCompat.Type.statusBars() | WindowInsetsCompat.Type.navigationBars()); - } else { - controller.hide(WindowInsetsCompat.Type.statusBars()); // we always hide the status bar in landscape. - controller.show(WindowInsetsCompat.Type.navigationBars()); - } + // We always hide the status bar in landscape. + statusBarsHidden = useImmersive() || orientation == Configuration.ORIENTATION_LANDSCAPE; + navigationBarsHidden = useImmersive(); + if (statusBarsHidden) { + controller.hide(WindowInsetsCompat.Type.statusBars()); } else { - if (useImmersive()) { - controller.hide(WindowInsetsCompat.Type.statusBars() | WindowInsetsCompat.Type.navigationBars()); - } else { - controller.show(WindowInsetsCompat.Type.statusBars() | WindowInsetsCompat.Type.navigationBars()); - } + controller.show(WindowInsetsCompat.Type.statusBars()); + } + if (navigationBarsHidden) { + controller.hide(WindowInsetsCompat.Type.navigationBars()); + } else { + controller.show(WindowInsetsCompat.Type.navigationBars()); + } + // With LAYOUT_STABLE the insets may not change, so the listener wouldn't pick up what we hid. + if (mSurfaceView != null) { + ViewCompat.requestApplyInsets(mSurfaceView); } surfaceManager.updateDisplayMeasurements(); @@ -905,7 +912,14 @@ public class PpssppActivity extends AppCompatActivity implements SensorEventList } DisplayCutoutCompat cutout = insetCompat.getDisplayCutout(); boolean hasCameraCutout = cutout != null && !cutout.getBoundingRects().isEmpty(); - Insets insets = insetCompat.getInsets(WindowInsetsCompat.Type.systemBars() | WindowInsetsCompat.Type.displayCutout()); + int types = WindowInsetsCompat.Type.captionBar() | WindowInsetsCompat.Type.displayCutout(); + if (!statusBarsHidden) { + types |= WindowInsetsCompat.Type.statusBars(); + } + if (!navigationBarsHidden) { + types |= WindowInsetsCompat.Type.navigationBars(); + } + Insets insets = insetCompat.getInsets(types); int left = insets.left; int right = insets.right; int top = insets.top;