diff options
author | Andras Becsi <andras.becsi@digia.com> | 2014-06-25 18:10:17 +0200 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@digia.com> | 2014-06-26 15:45:50 +0300 |
commit | a86f5028fca38dd219514d316cab184c373877c4 (patch) | |
tree | b94c9b1f57aa9247063394f103b37ad624d24201 /src/virtualkeyboard/platforminputcontext.cpp | |
parent | 4a39ee5ab4e5fde3955af7c29995eb840a2f1ee1 (diff) |
Decouple the input method state change from setFocusObject
This fixes issues with QtWebEngine where input fields in web pages
ended up losing input method focus because the IM state update relied
on the PlatformInputContext::setFocusObject call, which for a WebView
only happens once the WebView gains active focus. Consequently if the
user did not click the input field on the web page first, the WebView
reported not to accept input method events and the VKB remained stuck
in this state even if the user clicked the input field since the focus
object did not change.
This patch also updates the IM state in PlatformInputContext::update
which is called by QInputMethod::update every time the IM is triggered
thus we will never miss input method events in the above described
scenario.
Change-Id: I7680b1ef81b2a8b75f4558cf21214754e549e5dd
Reviewed-by: Andras Becsi <andras.becsi@digia.com>
Reviewed-by: Mitch Curtis <mitch.curtis@digia.com>
Diffstat (limited to 'src/virtualkeyboard/platforminputcontext.cpp')
-rw-r--r-- | src/virtualkeyboard/platforminputcontext.cpp | 38 |
1 files changed, 15 insertions, 23 deletions
diff --git a/src/virtualkeyboard/platforminputcontext.cpp b/src/virtualkeyboard/platforminputcontext.cpp index 9fae0641..2254b9c8 100644 --- a/src/virtualkeyboard/platforminputcontext.cpp +++ b/src/virtualkeyboard/platforminputcontext.cpp @@ -69,8 +69,19 @@ void PlatformInputContext::commit() void PlatformInputContext::update(Qt::InputMethodQueries queries) { VIRTUALKEYBOARD_DEBUG() << "PlatformInputContext::update():" << queries; - if (m_declarativeContext) - m_declarativeContext->update(queries); + bool enabled = inputMethodQuery(Qt::ImEnabled).toBool(); + if (enabled && !m_inputPanelCreated) { + m_inputPanel->createView(); + m_inputPanelCreated = true; + } + + if (m_declarativeContext) { + m_declarativeContext->setFocus(enabled); + if (enabled) + m_declarativeContext->update(queries); + else + hideInputPanel(); + } } void PlatformInputContext::invokeAction(QInputMethod::Action action, int cursorPosition) @@ -95,13 +106,7 @@ bool PlatformInputContext::isAnimating() const void PlatformInputContext::showInputPanel() { - if (!m_inputPanelCreated) { - m_inputPanel->createView(); - m_inputPanelCreated = true; - if (m_declarativeContext) - m_declarativeContext->update(Qt::ImQueryAll); - } - if (m_inputPanel->isVisible()) + if (!m_inputPanelCreated || m_inputPanel->isVisible()) return; m_inputPanel->show(); emitInputPanelVisibleChanged(); @@ -160,20 +165,7 @@ void PlatformInputContext::setFocusObject(QObject *object) m_focusObject = object; emit focusObjectChanged(); } - - bool enabled = inputMethodQuery(Qt::ImEnabled).toBool(); - if (enabled && !m_inputPanelCreated) { - m_inputPanel->createView(); - m_inputPanelCreated = true; - } - - if (m_declarativeContext) { - m_declarativeContext->setFocus(enabled); - if (enabled) - m_declarativeContext->update(Qt::ImQueryAll); - else - hideInputPanel(); - } + update(Qt::ImQueryAll); } DeclarativeInputContext *PlatformInputContext::declarativeInputContext() const |