diff options
author | Tinja Paavoseppä <tinja.paavoseppa@qt.io> | 2024-03-27 15:31:34 +0200 |
---|---|---|
committer | Tinja Paavoseppä <tinja.paavoseppa@qt.io> | 2024-04-04 15:46:44 +0200 |
commit | d45ce587784427c4ff72d306811eb63baa53cb3a (patch) | |
tree | 2f0f09c7d091c139f928b41edb3155710d82d0b7 /src/plugins/platforms | |
parent | e9edd3db524e0c9c77925ae5bea98017a6220ecf (diff) |
Android/QtView: Set also x and y of the wrapped foreign QWindow
Previously, we have set the size of the QWindow to match the QtView.
Also set its x and y coordinate to match, just to keep the window and
the view in sync.
Pick-to: 6.7
Change-Id: I0ea89a11e4526a0a996e7b62ac126808358b6bc7
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r-- | src/plugins/platforms/android/androidwindowembedding.cpp | 11 | ||||
-rw-r--r-- | src/plugins/platforms/android/androidwindowembedding.h | 5 |
2 files changed, 9 insertions, 7 deletions
diff --git a/src/plugins/platforms/android/androidwindowembedding.cpp b/src/plugins/platforms/android/androidwindowembedding.cpp index 40c5b3c95f..20021283c5 100644 --- a/src/plugins/platforms/android/androidwindowembedding.cpp +++ b/src/plugins/platforms/android/androidwindowembedding.cpp @@ -15,13 +15,14 @@ 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, jint width, jint height) + void createRootWindow(JNIEnv *, jclass, QtJniTypes::View rootView, + jint x, jint y, 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, width, height] { + QMetaObject::invokeMethod(qApp, [rootView, x, y, width, height] { QWindow *parentWindow = QWindow::fromWinId(reinterpret_cast<WId>(rootView.object())); - parentWindow->setGeometry(0, 0, width, height); + parentWindow->setGeometry(x, y, width, height); rootView.callMethod<void>("createWindow", reinterpret_cast<jlong>(parentWindow)); }); } @@ -46,12 +47,12 @@ namespace QtAndroidWindowEmbedding { }); } - void resizeWindow(JNIEnv *, jclass, jlong windowRef, jint width, jint height) + void resizeWindow(JNIEnv *, jclass, jlong windowRef, jint x, jint y, jint width, jint height) { QWindow *window = reinterpret_cast<QWindow*>(windowRef); QWindow *parent = window->parent(); if (parent) - parent->setGeometry(0, 0, width, height); + parent->setGeometry(x, y, width, height); window->setGeometry(0, 0, width, height); } diff --git a/src/plugins/platforms/android/androidwindowembedding.h b/src/plugins/platforms/android/androidwindowembedding.h index cb0e5f90ce..b7b0e1205f 100644 --- a/src/plugins/platforms/android/androidwindowembedding.h +++ b/src/plugins/platforms/android/androidwindowembedding.h @@ -25,13 +25,14 @@ Q_DECLARE_JNI_CLASS(View, "android/view/View"); namespace QtAndroidWindowEmbedding { bool registerNatives(QJniEnvironment& env); - void createRootWindow(JNIEnv *, jclass, QtJniTypes::View rootView, jint width, jint height); + void createRootWindow(JNIEnv *, jclass, QtJniTypes::View rootView, + jint x, jint y,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) void setWindowVisible(JNIEnv *, jclass, jlong window, jboolean visible); Q_DECLARE_JNI_NATIVE_METHOD_IN_CURRENT_SCOPE(setWindowVisible) - void resizeWindow(JNIEnv *, jclass, jlong windowRef, jint width, jint height); + void resizeWindow(JNIEnv *, jclass, jlong windowRef, jint x, jint y, jint width, jint height); Q_DECLARE_JNI_NATIVE_METHOD_IN_CURRENT_SCOPE(resizeWindow) }; |