summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2016-06-08 15:16:12 +0200
committerAlexandru Croitor <alexandru.croitor@theqtcompany.com>2016-06-17 09:40:59 +0000
commite263573db93c4e2cbf42e6d8d3508415f1354d50 (patch)
treee17bad19bcef01fc3ac251fd633720ba9a311f56 /src
parent528088cb61eaacb63e87ea8e06f59d1536e43799 (diff)
Don't cancel an IME composition when a modifier key is pressed.
When an asian IME is used to compose a new word, and a modifier key is pressed (shift, alt, etc), WebEngine would notify Chromium to cancel the composition, thus clearing the text. But the actual IME window would still be present, and if another "letter" key was pressed, the composition would continue with the previous pre-edit text, which leads to unusual text flickering. The previous behavior was introduced in 31efe25d14 to fix a Windows double character input bug. The current change makes sure to clear the IME composition only in case the last received QInputMethodEvent pre-edit and commit strings were empty, which is not the case when pressing a modifier key for instance. Change-Id: Ic968404c90e1e0eb703fe1c2849990467bedd5e1 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/core/render_widget_host_view_qt.cpp7
-rw-r--r--src/core/render_widget_host_view_qt.h1
2 files changed, 7 insertions, 1 deletions
diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp
index 24b148ca5..bb024c557 100644
--- a/src/core/render_widget_host_view_qt.cpp
+++ b/src/core/render_widget_host_view_qt.cpp
@@ -259,6 +259,7 @@ RenderWidgetHostViewQt::RenderWidgetHostViewQt(content::RenderWidgetHost* widget
, m_didFirstVisuallyNonEmptyLayout(false)
, m_adapterClient(0)
, m_imeInProgress(false)
+ , m_receivedEmptyImeText(false)
, m_anchorPositionWithinSelection(0)
, m_cursorPositionWithinSelection(0)
, m_initPending(false)
@@ -961,7 +962,7 @@ void RenderWidgetHostViewQt::handleKeyEvent(QKeyEvent *ev)
if (IsMouseLocked() && ev->key() == Qt::Key_Escape && ev->type() == QEvent::KeyRelease)
UnlockMouse();
- if (m_imeInProgress) {
+ if (m_imeInProgress && m_receivedEmptyImeText) {
// IME composition was not finished with a valid commit string.
// We're getting the composition result in a key event.
if (ev->key() != 0) {
@@ -1039,6 +1040,7 @@ void RenderWidgetHostViewQt::handleInputMethodEvent(QInputMethodEvent *ev)
: gfx::Range::InvalidRange();
m_host->ImeConfirmComposition(toString16(commitString), replacementRange, false);
m_imeInProgress = false;
+ m_receivedEmptyImeText = false;
} else if (!preeditString.isEmpty()) {
if (!selectionRange.IsValid()) {
// We did not receive a valid selection range, hence the range is going to mark the cursor position.
@@ -1048,6 +1050,9 @@ void RenderWidgetHostViewQt::handleInputMethodEvent(QInputMethodEvent *ev)
}
m_host->ImeSetComposition(toString16(preeditString), underlines, selectionRange.start(), selectionRange.end());
m_imeInProgress = true;
+ m_receivedEmptyImeText = false;
+ } else {
+ m_receivedEmptyImeText = true;
}
}
diff --git a/src/core/render_widget_host_view_qt.h b/src/core/render_widget_host_view_qt.h
index 2e6563a67..5a0ea6f03 100644
--- a/src/core/render_widget_host_view_qt.h
+++ b/src/core/render_widget_host_view_qt.h
@@ -232,6 +232,7 @@ private:
ui::TextInputType m_currentInputType;
bool m_imeInProgress;
+ bool m_receivedEmptyImeText;
QRect m_cursorRect;
size_t m_anchorPositionWithinSelection;
size_t m_cursorPositionWithinSelection;