@@ -15,6 +15,8 @@ import android.graphics.Rect
1515import android.view.KeyEvent
1616import android.view.MotionEvent
1717import android.view.View
18+ import androidx.core.view.ViewCompat
19+ import androidx.core.view.WindowInsetsCompat
1820import com.facebook.common.logging.FLog
1921import com.facebook.react.ReactRootView
2022import com.facebook.react.bridge.ReactContext
@@ -27,6 +29,7 @@ import com.facebook.react.uimanager.JSKeyDispatcher
2729import com.facebook.react.uimanager.JSPointerDispatcher
2830import com.facebook.react.uimanager.JSTouchDispatcher
2931import com.facebook.react.uimanager.common.UIManagerType
32+ import com.facebook.react.views.view.isEdgeToEdgeFeatureFlagOn
3033import com.facebook.systrace.Systrace
3134import java.util.Objects
3235import kotlin.math.max
@@ -56,6 +59,21 @@ public class ReactSurfaceView(context: Context?, internal val surface: ReactSurf
5659 getWindowVisibleDisplayFrame(visibleWindowFrame)
5760 locationOnScreen[0 ] - = visibleWindowFrame.left
5861 locationOnScreen[1 ] - = visibleWindowFrame.top
62+
63+ if (isEdgeToEdgeFeatureFlagOn) {
64+ // In edge-to-edge mode the viewport spans the full window, so add the top system bar
65+ // insets back to convert the content-area offset above into a window-relative offset.
66+ ViewCompat .getRootWindowInsets(this )?.apply {
67+ val insets =
68+ getInsets(
69+ WindowInsetsCompat .Type .statusBars() or WindowInsetsCompat .Type .displayCutout()
70+ )
71+
72+ locationOnScreen[0 ] + = insets.left
73+ locationOnScreen[1 ] + = insets.top
74+ }
75+ }
76+
5977 return Point (locationOnScreen[0 ], locationOnScreen[1 ])
6078 }
6179
0 commit comments