summaryrefslogtreecommitdiffstats
path: root/src/core/render_widget_host_view_qt.cpp
diff options
context:
space:
mode:
authorAnu Aliyas <anu.aliyas@qt.io>2023-12-12 16:35:44 +0100
committerAnu Aliyas <anu.aliyas@qt.io>2024-01-09 03:56:52 +0100
commitc9550388b9ab1d82454d0c59eaaf7e640d83d750 (patch)
treeb4c54969fa2cfd1fd28a3262e05bc9cb65e2cf61 /src/core/render_widget_host_view_qt.cpp
parentf20aa1951ee19f3d8dee0939a0272d2eb8a969a6 (diff)
Fix cursor position during composition
During input composition, the cursor is set to the starting position of the string being edited and refrain from updating it throughout the composition process. Once the string is committed, it is set to the last position of the committed string. The modified code is designed to exhibit the same behavior as the widget and quickwidget. Fixes: QTBUG-118746 Pick-to: 6.5 6.6 6.7 Change-Id: I9adb7a9bea9493457a1d9d4b32338cdba30920a1 Reviewed-by: Peter Varga <pvarga@inf.u-szeged.hu>
Diffstat (limited to 'src/core/render_widget_host_view_qt.cpp')
-rw-r--r--src/core/render_widget_host_view_qt.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp
index e8a0e6c7c..888043fda 100644
--- a/src/core/render_widget_host_view_qt.cpp
+++ b/src/core/render_widget_host_view_qt.cpp
@@ -685,9 +685,11 @@ void RenderWidgetHostViewQt::OnUpdateTextInputStateCalled(content::TextInputMana
// In case of text selection, the update is expected in RenderWidgetHostViewQt::selectionChanged().
if (GetSelectedText().empty()) {
- // At this point it is unknown whether the text input state has been updated due to a text selection.
- // Keep the cursor position updated for cursor movements too.
- delegateClient()->setCursorPosition(state->selection.start());
+ if (state->composition.has_value()) {
+ delegateClient()->setCursorPosition(state->composition->start());
+ } else {
+ delegateClient()->setCursorPosition(state->selection.start());
+ }
m_delegate->inputMethodStateChanged(type != ui::TEXT_INPUT_TYPE_NONE, type == ui::TEXT_INPUT_TYPE_PASSWORD);
}