summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJani Heikkinen <[email protected]>2025-06-03 04:37:33 +0000
committerVolker Hilsheimer <[email protected]>2025-06-03 10:47:14 +0000
commit05f8abc61dd2429d7041a87d5bfc7bffbb105f12 (patch)
tree855dfbef998ee58d6e4101dfedc388a58bd4828c
parent95229bb7d039bb9e16a2ffd126d7ff1e25b37d32 (diff)
Revert "Android: consider DecorView insets at app startup"HEADdev
This reverts commit e96a4b84e136d065054600c07bf5fae17f3049ce. Reason for revert: QTBUG-137306 Pick-to: 6.10 6.9 Change-Id: Id5718737f3f426de49ad109d214af1c920e5ae22 Reviewed-by: Volker Hilsheimer <[email protected]>
-rw-r--r--src/android/jar/src/org/qtproject/qt/android/QtWindow.java58
-rw-r--r--src/plugins/platforms/android/qandroidplatformwindow.cpp5
2 files changed, 14 insertions, 49 deletions
diff --git a/src/android/jar/src/org/qtproject/qt/android/QtWindow.java b/src/android/jar/src/org/qtproject/qt/android/QtWindow.java
index e4f489a39da..a0c10321f82 100644
--- a/src/android/jar/src/org/qtproject/qt/android/QtWindow.java
+++ b/src/android/jar/src/org/qtproject/qt/android/QtWindow.java
@@ -75,57 +75,27 @@ class QtWindow extends QtLayout implements QtSurfaceInterface {
});
m_gestureDetector.setIsLongpressEnabled(true);
});
- }
-
- @UsedFromNativeCode
- void registerSafeAreaMarginsListner(boolean isTopLevel, boolean isSameWindowAndScreenSize)
- {
- if (!(getContext() instanceof QtActivityBase))
- return;
-
- setOnApplyWindowInsetsListener((view, insets) -> {
- Insets safeInsets = getSafeInsets(view, insets);
- safeAreaMarginsChanged(safeInsets, getId());
- return getConsumedInsets(insets);
- });
- // NOTE: if the window size fits the screen geometry (i.e. edge-to-edge case),
- // assume this window is the main window and initialize its safe margins with
- // the insets of the decor view.
- if (isTopLevel && isSameWindowAndScreenSize) {
- QtNative.runAction(() -> {
- // NOTE: The callback onApplyWindowInsetsListener() is not being triggered during
- // startup, so this is a Workaround to get the safe area margins at startup.
- // Initially, set the root view insets to the current window, then if the insets
- // change later, we can rely on setOnApplyWindowInsetsListener() being called.
- View decorView = ((Activity) getContext()).getWindow().getDecorView();
- WindowInsets rootInsets = decorView.getRootWindowInsets();
- Insets rootSafeInsets = getSafeInsets(decorView, rootInsets);
- safeAreaMarginsChanged(rootSafeInsets, getId());
+ if (getContext() instanceof QtActivityBase) {
+ setOnApplyWindowInsetsListener((view, insets) -> {
+ Insets safeInsets;
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
+ int types = WindowInsets.Type.displayCutout() | WindowInsets.Type.systemBars();
+ safeInsets = insets.getInsets(types);
+ } else {
+ safeInsets = getSafeInsetsPreAndroidR(view, insets);
+ }
+ QtNative.runAction(() -> safeAreaMarginsChanged(safeInsets, getId()));
+ return insets;
});
- }
-
- QtNative.runAction(() -> requestApplyInsets());
- }
- @SuppressWarnings("deprecation")
- WindowInsets getConsumedInsets(WindowInsets insets)
- {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R)
- return WindowInsets.CONSUMED;
- else
- return insets.consumeSystemWindowInsets();
+ QtNative.runAction(() -> requestApplyInsets());
+ }
}
@SuppressWarnings("deprecation")
- Insets getSafeInsets(View view, WindowInsets insets)
+ Insets getSafeInsetsPreAndroidR(View view, WindowInsets insets)
{
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
- int types = WindowInsets.Type.displayCutout() | WindowInsets.Type.systemBars();
- return insets.getInsets(types);
- }
-
- // Android R and older
int left = 0;
int top = 0;
int right = 0;
diff --git a/src/plugins/platforms/android/qandroidplatformwindow.cpp b/src/plugins/platforms/android/qandroidplatformwindow.cpp
index 194a08ee09f..cb252d1f084 100644
--- a/src/plugins/platforms/android/qandroidplatformwindow.cpp
+++ b/src/plugins/platforms/android/qandroidplatformwindow.cpp
@@ -96,11 +96,6 @@ void QAndroidPlatformWindow::initialize()
}
qCDebug(lcQpaWindow) << "Window" << m_nativeViewId << "using surface container type"
<< static_cast<int>(m_surfaceContainerType);
-
- const bool isSameWindowAndScreenSize = geometry().size() == screen()->geometry().size();
- m_nativeQtWindow.callMethod("registerSafeAreaMarginsListner",
- window->isTopLevel(), isSameWindowAndScreenSize);
-
}
QAndroidPlatformWindow::~QAndroidPlatformWindow()