diff options
author | Rami Potinkara <rami.potinkara@qt.io> | 2021-10-15 05:52:44 +0000 |
---|---|---|
committer | Rami Potinkara <rami.potinkara@qt.io> | 2021-10-26 20:46:24 +0000 |
commit | b1820295e1e8f04634cf9c008a2473d9e2889288 (patch) | |
tree | 1fd60951862a7479a73f225eb5a92a79c9c24b84 /src/plugins/platforms/android/qandroidinputcontext.cpp | |
parent | 323b97ccaea7b9442fa1bcb01514e0c5a4a97fdc (diff) |
Revert "Android: Place cursor correctly on screen when editing"
This reverts commit 5c6b10c3cee5737dbc041d0463220898c8120807.
It caused a regression such that the main window no longer resized or
panned when the VKB is shown, in spite of android:windowSoftInputMode
being set.
Pick-to: 6.2 5.15
Task-number: QTBUG-95300
Task-number: QTBUG-96117
Task-number: QTBUG-97503
Change-Id: If56e1113eea69a940f6760bdb2ad06a93a0759c1
Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Diffstat (limited to 'src/plugins/platforms/android/qandroidinputcontext.cpp')
-rw-r--r-- | src/plugins/platforms/android/qandroidinputcontext.cpp | 50 |
1 files changed, 6 insertions, 44 deletions
diff --git a/src/plugins/platforms/android/qandroidinputcontext.cpp b/src/plugins/platforms/android/qandroidinputcontext.cpp index 37a5191dfc..aac0ba2c89 100644 --- a/src/plugins/platforms/android/qandroidinputcontext.cpp +++ b/src/plugins/platforms/android/qandroidinputcontext.cpp @@ -60,6 +60,7 @@ #include <qthread.h> #include <qwindow.h> #include <qpa/qplatformwindow.h> + QT_BEGIN_NAMESPACE namespace { @@ -492,7 +493,7 @@ QAndroidInputContext::QAndroidInputContext() m_androidInputContext = this; QObject::connect(QGuiApplication::inputMethod(), &QInputMethod::cursorRectangleChanged, - this, &QAndroidInputContext::updateInputItemRectangle); + this, &QAndroidInputContext::updateSelectionHandles); QObject::connect(QGuiApplication::inputMethod(), &QInputMethod::anchorRectangleChanged, this, &QAndroidInputContext::updateSelectionHandles); QObject::connect(QGuiApplication::inputMethod(), &QInputMethod::inputItemClipRectangleChanged, this, [this]{ @@ -921,49 +922,10 @@ void QAndroidInputContext::showInputPanel() else m_updateCursorPosConnection = connect(qGuiApp->focusObject(), SIGNAL(cursorPositionChanged()), this, SLOT(updateCursorPosition())); - QRect rect = cursorRect(); - if (!isInputPanelVisible()) - QtAndroidInput::showSoftwareKeyboard(rect.left(), rect.top(), rect.width(), rect.height(), - screenInputItemRectangle().height(), - query->value(Qt::ImHints).toUInt(), - query->value(Qt::ImEnterKeyType).toUInt()); -} - -QRect QAndroidInputContext::cursorRect() -{ - QSharedPointer<QInputMethodQueryEvent> query = focusObjectInputMethodQuery(); - // if single line, we do not want to mess with the editor's position, as we do not - // have to follow the cursor in vertical axis - if (query.isNull() - || (query->value(Qt::ImHints).toUInt() & Qt::ImhMultiLine) != Qt::ImhMultiLine) - return {}; - - auto im = qGuiApp->inputMethod(); - if (!im) - return {}; - - const auto cursorRect= im->cursorRectangle().toRect(); - QRect finalRect(inputItemRectangle().toRect()); - const QWindow *window = qGuiApp->focusWindow(); - const double pd = window - ? QHighDpiScaling::factor(window) - : QHighDpiScaling::factor(QtAndroid::androidPlatformIntegration()->screen()); - finalRect.setY(cursorRect.y() * pd); - finalRect.setHeight(cursorRect.height() * pd); - //fiddle a bit with vert margins, so the tracking rectangle is not too tight. - finalRect += QMargins(0, cursorRect.height() / 4, 0, cursorRect.height() / 4); - return finalRect; -} - -void QAndroidInputContext::updateInputItemRectangle() -{ - QRect rect = cursorRect(); - - if (!rect.isValid()) - return; - QtAndroidInput::updateInputItemRectangle(rect.left(), rect.top(), - rect.width(), rect.height()); - updateSelectionHandles(); + QRect rect = screenInputItemRectangle(); + QtAndroidInput::showSoftwareKeyboard(rect.left(), rect.top(), rect.width(), rect.height(), + query->value(Qt::ImHints).toUInt(), + query->value(Qt::ImEnterKeyType).toUInt()); } void QAndroidInputContext::showInputPanelLater(Qt::ApplicationState state) |