summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms
diff options
context:
space:
mode:
authorTinja Paavoseppä <tinja.paavoseppa@qt.io>2024-03-27 13:42:05 +0200
committerTinja Paavoseppä <tinja.paavoseppa@qt.io>2024-04-04 15:46:44 +0200
commite9edd3db524e0c9c77925ae5bea98017a6220ecf (patch)
tree09b732eaf52a888f05405d3314a991ca1d34e2fb /src/plugins/platforms
parentc4a98a729898b7bf2244675f8ba91933f9ae8b93 (diff)
Android/Embedding QML: Resize also parent window
The parent window created from the QtView had an empty size. Also set its size when creating the window, and when resizing the QtView. Replace parent window show() call with showNormal() to avoid switching it to a fullscreen window. As a drive-by, use setGeometry() instead of setting the width and height separately to trigger only one geometry update for the platform window. Pick-to: 6.7 Change-Id: I91e350c1748a9e76879faa8bfcab7575f6155f02 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r--src/plugins/platforms/android/androidwindowembedding.cpp13
-rw-r--r--src/plugins/platforms/android/androidwindowembedding.h2
2 files changed, 9 insertions, 6 deletions
diff --git a/src/plugins/platforms/android/androidwindowembedding.cpp b/src/plugins/platforms/android/androidwindowembedding.cpp
index e72bb326cc..40c5b3c95f 100644
--- a/src/plugins/platforms/android/androidwindowembedding.cpp
+++ b/src/plugins/platforms/android/androidwindowembedding.cpp
@@ -15,12 +15,13 @@ Q_DECLARE_JNI_CLASS(QtView, "org/qtproject/qt/android/QtView");
Q_DECLARE_JNI_CLASS(QtEmbeddedDelegate, "org/qtproject/qt/android/QtEmbeddedDelegate");
namespace QtAndroidWindowEmbedding {
- void createRootWindow(JNIEnv *, jclass, QtJniTypes::View rootView)
+ void createRootWindow(JNIEnv *, jclass, QtJniTypes::View rootView, jint width, jint height)
{
// QWindow should be constructed on the Qt thread rather than directly in the caller thread
// To avoid hitting checkReceiverThread assert in QCoreApplication::doNotify
- QMetaObject::invokeMethod(qApp, [rootView] {
+ QMetaObject::invokeMethod(qApp, [rootView, width, height] {
QWindow *parentWindow = QWindow::fromWinId(reinterpret_cast<WId>(rootView.object()));
+ parentWindow->setGeometry(0, 0, width, height);
rootView.callMethod<void>("createWindow", reinterpret_cast<jlong>(parentWindow));
});
}
@@ -38,7 +39,7 @@ namespace QtAndroidWindowEmbedding {
if (visible) {
window->showNormal();
if (!window->parent()->isVisible())
- window->parent()->show();
+ window->parent()->showNormal();
} else {
window->hide();
}
@@ -48,8 +49,10 @@ namespace QtAndroidWindowEmbedding {
void resizeWindow(JNIEnv *, jclass, jlong windowRef, jint width, jint height)
{
QWindow *window = reinterpret_cast<QWindow*>(windowRef);
- window->setWidth(width);
- window->setHeight(height);
+ QWindow *parent = window->parent();
+ if (parent)
+ parent->setGeometry(0, 0, width, height);
+ window->setGeometry(0, 0, width, height);
}
bool registerNatives(QJniEnvironment& env) {
diff --git a/src/plugins/platforms/android/androidwindowembedding.h b/src/plugins/platforms/android/androidwindowembedding.h
index 4f3261a30b..cb0e5f90ce 100644
--- a/src/plugins/platforms/android/androidwindowembedding.h
+++ b/src/plugins/platforms/android/androidwindowembedding.h
@@ -25,7 +25,7 @@ Q_DECLARE_JNI_CLASS(View, "android/view/View");
namespace QtAndroidWindowEmbedding
{
bool registerNatives(QJniEnvironment& env);
- void createRootWindow(JNIEnv *, jclass, QtJniTypes::View rootView);
+ void createRootWindow(JNIEnv *, jclass, QtJniTypes::View rootView, jint width, jint height);
Q_DECLARE_JNI_NATIVE_METHOD_IN_CURRENT_SCOPE(createRootWindow)
void deleteWindow(JNIEnv *, jclass, jlong window);
Q_DECLARE_JNI_NATIVE_METHOD_IN_CURRENT_SCOPE(deleteWindow)