diff options
| author | Assam Boudjelthia <assam.boudjelthia@qt.io> | 2025-09-24 19:02:37 +0300 |
|---|---|---|
| committer | Assam Boudjelthia <assam.boudjelthia@qt.io> | 2025-10-13 18:24:45 +0300 |
| commit | d8bb4005cd444b5b12f594acab4d886dd7eec80f (patch) | |
| tree | 90b5ca43a4bc9a16489f2e5be60c65fde49ee9ce /src/plugins/platforms/android/qandroidplatformwindow.cpp | |
| parent | a22bdd95ffffd8286b764e51c153769832c92344 (diff) | |
Android: move system ui code to its own QtWindowInsetsController class
Most of the code dealing with system ui visibility, system bars and
insets is under QtDisplayManager which is not exactly the correct
place. Instead of that move, move the code its own class named
QtWindowInsetsController which has all those utilities.
Change-Id: I174f9cc5a1a324c65630cd7edd01c05ee6114c1c
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
Diffstat (limited to 'src/plugins/platforms/android/qandroidplatformwindow.cpp')
| -rw-r--r-- | src/plugins/platforms/android/qandroidplatformwindow.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/plugins/platforms/android/qandroidplatformwindow.cpp b/src/plugins/platforms/android/qandroidplatformwindow.cpp index 937839ace0c..96c4bfa06f1 100644 --- a/src/plugins/platforms/android/qandroidplatformwindow.cpp +++ b/src/plugins/platforms/android/qandroidplatformwindow.cpp @@ -22,6 +22,7 @@ Q_DECLARE_JNI_CLASS(QtInputInterface, "org/qtproject/qt/android/QtInputInterface Q_DECLARE_JNI_CLASS(QtInputConnectionListener, "org/qtproject/qt/android/QtInputConnection$QtInputConnectionListener") Q_DECLARE_JNI_CLASS(QtDisplayManager, "org/qtproject/qt/android/QtWindowInterface") +Q_DECLARE_JNI_CLASS(QtWindowInsetsController, "org/qtproject/qt/android/QtWindowInsetsController") QAndroidPlatformWindow::QAndroidPlatformWindow(QWindow *window) : QPlatformWindow(window), m_nativeQtWindow(nullptr), @@ -260,10 +261,17 @@ void QAndroidPlatformWindow::updateSystemUiVisibility() const int flags = window()->flags(); const bool isNonRegularWindow = flags & (Qt::Popup | Qt::Dialog | Qt::Sheet) & ~Qt::Window; if (!isNonRegularWindow) { - const bool isFullScreen = (m_windowState & Qt::WindowFullScreen); - const bool expandedToCutout = (flags & Qt::ExpandedClientAreaHint); - QtAndroid::backendRegister()->callInterface<QtJniTypes::QtWindowInterface, void>( - "setSystemUiVisibility", isFullScreen, expandedToCutout); + auto iface = qGuiApp->nativeInterface<QNativeInterface::QAndroidApplication>(); + iface->runOnAndroidMainThread([=]() { + using namespace QtJniTypes; + auto activity = iface->context().object<Activity>(); + if (m_windowState & Qt::WindowFullScreen) + QtWindowInsetsController::callStaticMethod("showFullScreen", activity); + else if (flags & Qt::ExpandedClientAreaHint) + QtWindowInsetsController::callStaticMethod("showExpanded", activity); + else + QtWindowInsetsController::callStaticMethod("showNormal", activity); + }); } } |
