Android: Handle ImhNoTextHandles flag from InputMethodHints

[0]Qt::InputMethodHints has a flag ImhNoTextHandles that was not
handled. This flag should be considered when QAndroidInputContext is
updating Text handles position.
What is more, this flag can be used to fix the problem with visible
text cursor out of the text object.

[0]https://doc.qt.io/qt-6/qt.html#InputMethodHint-enum

Task-number: QTBUG-115005
Pick-to: 6.5
Change-Id: Ie50b77d7afbadfebe73f10137f09da9560aea1ba
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Rami Potinkara <rami.potinkara@qt.io>
(cherry picked from commit 0f0ab90cf60a7169c365c8c9f46b7ccd379a10d1)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Bartlomiej Moskal 2023-08-01 13:06:16 +02:00 committed by Qt Cherry-pick Bot
parent 652e2c571f
commit e2752e4274
2 changed files with 14 additions and 0 deletions

View File

@ -531,12 +531,25 @@ void QAndroidInputContext::updateCursorPosition()
} }
} }
bool QAndroidInputContext::isImhNoTextHandlesSet()
{
QSharedPointer<QInputMethodQueryEvent> query = focusObjectInputMethodQuery();
if (query.isNull())
return false;
return query->value(Qt::ImHints).toUInt() & Qt::ImhNoTextHandles;
}
void QAndroidInputContext::updateSelectionHandles() void QAndroidInputContext::updateSelectionHandles()
{ {
static bool noHandles = qEnvironmentVariableIntValue("QT_QPA_NO_TEXT_HANDLES"); static bool noHandles = qEnvironmentVariableIntValue("QT_QPA_NO_TEXT_HANDLES");
if (noHandles || !m_focusObject) if (noHandles || !m_focusObject)
return; return;
if (isImhNoTextHandlesSet()) {
QtAndroidInput::updateHandles(Hidden);
return;
}
auto im = qGuiApp->inputMethod(); auto im = qGuiApp->inputMethod();
QInputMethodQueryEvent query(Qt::ImCursorPosition | Qt::ImAnchorPosition | Qt::ImEnabled QInputMethodQueryEvent query(Qt::ImCursorPosition | Qt::ImAnchorPosition | Qt::ImEnabled

View File

@ -113,6 +113,7 @@ private slots:
void showInputPanelLater(Qt::ApplicationState); void showInputPanelLater(Qt::ApplicationState);
private: private:
bool isImhNoTextHandlesSet();
void sendInputMethodEvent(QInputMethodEvent *event); void sendInputMethodEvent(QInputMethodEvent *event);
QSharedPointer<QInputMethodQueryEvent> focusObjectInputMethodQuery(Qt::InputMethodQueries queries = Qt::ImQueryAll); QSharedPointer<QInputMethodQueryEvent> focusObjectInputMethodQuery(Qt::InputMethodQueries queries = Qt::ImQueryAll);
bool focusObjectIsComposing() const; bool focusObjectIsComposing() const;