From a86f5028fca38dd219514d316cab184c373877c4 Mon Sep 17 00:00:00 2001 From: Andras Becsi Date: Wed, 25 Jun 2014 18:10:17 +0200 Subject: 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 Reviewed-by: Mitch Curtis --- src/virtualkeyboard/platforminputcontext.cpp | 38 +++++++++++----------------- 1 file changed, 15 insertions(+), 23 deletions(-) (limited to 'src/virtualkeyboard/platforminputcontext.cpp') 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 -- cgit v1.2.3