diff options
author | Michael BrĂ¼ning <michael.bruning@qt.io> | 2018-12-14 13:15:31 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-12-18 15:58:19 +0100 |
commit | 50fac0d1d7e82f2423e0a3e557b4a1f30be5bf33 (patch) | |
tree | b085f03fdafa4ecbcfcb5a96b68404e155879b6a /src/core/render_widget_host_view_qt.cpp | |
parent | 8124f0bc1893e0997989913044665fa1c5cf79d7 (diff) | |
parent | 4f1e0003d98116e33a847360e0e95c46daae25fc (diff) |
Merge remote-tracking branch 'origin/5.12' into dev
Conflicts:
src/core/compositor/delegated_frame_node.cpp
src/core/profile_adapter.cpp
src/core/profile_io_data_qt.cpp
src/webengine/api/qquickwebengineprofile.cpp
src/webenginewidgets/api/qwebengineprofile.cpp
Change-Id: I35ec8480e758bbcb6c5942a5401cb1b6dbdcc428
Diffstat (limited to 'src/core/render_widget_host_view_qt.cpp')
-rw-r--r-- | src/core/render_widget_host_view_qt.cpp | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp index fc42d5bde..4bb41a303 100644 --- a/src/core/render_widget_host_view_qt.cpp +++ b/src/core/render_widget_host_view_qt.cpp @@ -747,25 +747,29 @@ void RenderWidgetHostViewQt::OnUpdateTextInputStateCalled(content::TextInputMana Q_UNUSED(updated_view); Q_UNUSED(did_update_state); - ui::TextInputType type = getTextInputType(); - m_delegate->inputMethodStateChanged(type != ui::TEXT_INPUT_TYPE_NONE, type == ui::TEXT_INPUT_TYPE_PASSWORD); - m_delegate->setInputMethodHints(toQtInputMethodHints(type)); - const content::TextInputState *state = text_input_manager_->GetTextInputState(); - if (!state) + if (!state) { + m_delegate->inputMethodStateChanged(false /*editorVisible*/, false /*passwordInput*/); + m_delegate->setInputMethodHints(Qt::ImhNone); return; + } - // 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. - if (GetSelectedText().empty()) - m_cursorPosition = state->selection_start; + ui::TextInputType type = getTextInputType(); + m_delegate->setInputMethodHints(toQtInputMethodHints(getTextInputType()) | Qt::ImhNoPredictiveText | Qt::ImhNoTextHandles | Qt::ImhNoEditMenu); m_surroundingText = QString::fromStdString(state->value); - // Remove IME composition text from the surrounding text if (state->composition_start != -1 && state->composition_end != -1) m_surroundingText.remove(state->composition_start, state->composition_end - state->composition_start); + // 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. + m_cursorPosition = state->selection_start; + m_delegate->inputMethodStateChanged(type != ui::TEXT_INPUT_TYPE_NONE, type == ui::TEXT_INPUT_TYPE_PASSWORD); + } + if (m_imState & ImStateFlags::TextInputStateUpdated) { m_imState = ImStateFlags::TextInputStateUpdated; return; @@ -822,9 +826,10 @@ void RenderWidgetHostViewQt::selectionChanged() { // Reset input manager state m_imState = 0; + ui::TextInputType type = getTextInputType(); // Handle text selection out of an input field - if (getTextInputType() == ui::TEXT_INPUT_TYPE_NONE) { + if (type == ui::TEXT_INPUT_TYPE_NONE) { if (GetSelectedText().empty() && m_emptyPreviousSelection) return; @@ -844,12 +849,13 @@ void RenderWidgetHostViewQt::selectionChanged() // if the selection is cleared because TextInputState changes before the TextSelection change. Q_ASSERT(text_input_manager_->GetTextInputState()); m_cursorPosition = text_input_manager_->GetTextInputState()->selection_start; + m_delegate->inputMethodStateChanged(true /*editorVisible*/, type == ui::TEXT_INPUT_TYPE_PASSWORD); m_anchorPositionWithinSelection = m_cursorPosition; m_cursorPositionWithinSelection = m_cursorPosition; if (!m_emptyPreviousSelection) { - m_emptyPreviousSelection = GetSelectedText().empty(); + m_emptyPreviousSelection = true; m_adapterClient->selectionChanged(); } @@ -884,6 +890,7 @@ void RenderWidgetHostViewQt::selectionChanged() m_cursorPosition = newCursorPositionWithinSelection; m_emptyPreviousSelection = selection->selected_text().empty(); + m_delegate->inputMethodStateChanged(true /*editorVisible*/, type == ui::TEXT_INPUT_TYPE_PASSWORD); m_adapterClient->selectionChanged(); } @@ -1106,7 +1113,7 @@ QVariant RenderWidgetHostViewQt::inputMethodQuery(Qt::InputMethodQuery query) // TODO: Implement this return QVariant(); // No limit. case Qt::ImHints: - return int(toQtInputMethodHints(getTextInputType())); + return int(toQtInputMethodHints(getTextInputType()) | Qt::ImhNoPredictiveText | Qt::ImhNoTextHandles | Qt::ImhNoEditMenu); default: return QVariant(); } |