@@ -342,6 +342,8 @@ class Godot private constructor(val context: Context) {
342342 */
343343 @JvmOverloads
344344 fun enableEdgeToEdge (enabled : Boolean , override : Boolean = false) {
345+ // Note: If modifying edge-to-edge or immersive mode logic, ensure to test with GodotIO.getDisplaySafeArea()
346+ // to confirm there are no regressions in safe area calculation.
345347 val window = getActivity()?.window ? : return
346348
347349 if (! isEdgeToEdge.compareAndSet(! enabled, enabled) && ! override ) {
@@ -354,27 +356,36 @@ class Godot private constructor(val context: Context) {
354356 ViewCompat .setOnApplyWindowInsetsListener(rootView, null )
355357 rootView.setPadding(0 , 0 , 0 , 0 )
356358 } else {
357- val insetType = WindowInsetsCompat .Type .systemBars() or WindowInsetsCompat .Type .displayCutout()
358359 if (rootView.rootWindowInsets != null ) {
359360 val windowInsets = WindowInsetsCompat .toWindowInsetsCompat(rootView.rootWindowInsets)
360- val insets = windowInsets.getInsets(insetType )
361+ val insets = windowInsets.getInsets(getInsetType() )
361362 rootView.setPadding(insets.left, insets.top, insets.right, insets.bottom)
362363 }
363364
364365 ViewCompat .setOnApplyWindowInsetsListener(rootView) { v: View , insets: WindowInsetsCompat ->
365- val windowInsets = insets.getInsets(insetType )
366+ val windowInsets = insets.getInsets(getInsetType() )
366367 v.setPadding(windowInsets.left, windowInsets.top, windowInsets.right, windowInsets.bottom)
367368 WindowInsetsCompat .CONSUMED
368369 }
369370 }
370371 }
371372
373+ private fun getInsetType (): Int {
374+ return if (! useImmersive.get() || isEditorBuild()) {
375+ WindowInsetsCompat .Type .systemBars() or WindowInsetsCompat .Type .displayCutout()
376+ } else {
377+ WindowInsetsCompat .Type .systemBars()
378+ }
379+ }
380+
372381 /* *
373382 * Toggle immersive mode.
374383 * Must be called from the UI thread.
375384 */
376385 @JvmOverloads
377386 fun enableImmersiveMode (enabled : Boolean , override : Boolean = false) {
387+ // Note: If modifying edge-to-edge or immersive mode logic, ensure to test with GodotIO.getDisplaySafeArea()
388+ // to confirm there are no regressions in safe area calculation.
378389 val activity = getActivity() ? : return
379390 val window = activity.window ? : return
380391
0 commit comments