summaryrefslogtreecommitdiffstats
path: root/src/android
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2022-03-21 17:35:29 +0100
committerIvan Solovev <ivan.solovev@qt.io>2022-03-29 13:56:14 +0100
commitd85c6527b514e36ab06bdf4228113d458e16cae0 (patch)
treedcd1395a41878b8c7181d160f3e948817b658c0d /src/android
parent3033d896746aa931cc3dfcf09f24e73bbed4571a (diff)
Android: fix fullscreen handling
Commit a35a7fcb5a713956e97bc87ccbd273737c7418df introduced the usage of insets to correctly take into account the default Android status bars and other reserved regions. However in practice that does not work as expected - the bottom inset is always reported to be non-zero, even when fullscreen mode is enabled. To fix the issue, FLAG_FULLSCREEN is explicitly checked before applying the insets. Fixes: QTBUG-99624 Pick-to: 6.3 6.2 Change-Id: I8b25f0b06447cd452c42ef072493e3137e25f38b Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Diffstat (limited to 'src/android')
-rw-r--r--src/android/jar/src/org/qtproject/qt/android/QtLayout.java25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/android/jar/src/org/qtproject/qt/android/QtLayout.java b/src/android/jar/src/org/qtproject/qt/android/QtLayout.java
index 7cb694dacf..6c52a00422 100644
--- a/src/android/jar/src/org/qtproject/qt/android/QtLayout.java
+++ b/src/android/jar/src/org/qtproject/qt/android/QtLayout.java
@@ -49,6 +49,7 @@ import android.view.Display;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowInsets;
+import android.view.WindowManager;
public class QtLayout extends ViewGroup
{
@@ -112,11 +113,25 @@ public class QtLayout extends ViewGroup
}
boolean isFullScreenView = h == realMetrics.heightPixels;
-
- int insetLeft = isFullScreenView ? insets.getSystemWindowInsetLeft() : 0;
- int insetTop = isFullScreenView ? insets.getSystemWindowInsetTop() : 0;
- int insetRight = isFullScreenView ? insets.getSystemWindowInsetRight() : 0;
- int insetBottom = isFullScreenView ? insets.getSystemWindowInsetBottom() : 0;
+ // The code uses insets for fullscreen mode only. However in practice
+ // the insets can be reported incorrectly. Both on Android 6 and Android 11
+ // a non-zero bottom inset is reported even when the
+ // WindowManager.LayoutParams.FLAG_FULLSCREEN flag is set.
+ // To avoid that, add an extra check for the fullscreen mode.
+ // The insets-related logic is not removed for the case when
+ // isFullScreenView == true, but hasFlagFullscreen == false, although
+ // I can't get such case in my tests.
+ final int windowFlags = ((Activity)getContext()).getWindow().getAttributes().flags;
+ final boolean hasFlagFullscreen =
+ (windowFlags & WindowManager.LayoutParams.FLAG_FULLSCREEN) != 0;
+ int insetLeft =
+ (isFullScreenView && !hasFlagFullscreen) ? insets.getSystemWindowInsetLeft() : 0;
+ int insetTop =
+ (isFullScreenView && !hasFlagFullscreen) ? insets.getSystemWindowInsetTop() : 0;
+ int insetRight =
+ (isFullScreenView && !hasFlagFullscreen) ? insets.getSystemWindowInsetRight() : 0;
+ int insetBottom =
+ (isFullScreenView && !hasFlagFullscreen) ? insets.getSystemWindowInsetBottom() : 0;
int usableAreaWidth = w - insetLeft - insetRight;
int usableAreaHeight = h - insetTop - insetBottom;