From 4add7d236bbc3088a384f76de3a3df4668f8594b Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Wed, 11 Mar 2015 15:43:43 +0100 Subject: [PATCH] iOS: ensure keyboard is visible, even when IM hints hasn't changed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When showing a QWindow, we transfer first responder status to its QUIView. If another QWindow was active with a text responder at that point, the text responder will loose first responder status in favor of the new view, and the keyboard will hide. Now, if the new window has a focus object with the same IM state as the previous focus object (in the previous window), m_imeState will not change, and QIOSIntegration::update() will assume that nothing needs to be done to show the keyboard, even if it's actually hidden. This patch will change the logic, so that we: - show the keyboard if its supposed to be visible, even if m_imeState did not change. - Only recreate the text responder if it needs a different configuration than the one we already got (not only from changes to Qt::ImEnabled) Task-number: QTBUG-40695 Change-Id: I6f6788af4cbff5c7abe4f5a29e23a7cefea6b711 Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/ios/qiosinputcontext.mm | 39 +++++++++---------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/src/plugins/platforms/ios/qiosinputcontext.mm b/src/plugins/platforms/ios/qiosinputcontext.mm index 22847b0612..a558ebe1f7 100644 --- a/src/plugins/platforms/ios/qiosinputcontext.mm +++ b/src/plugins/platforms/ios/qiosinputcontext.mm @@ -587,28 +587,27 @@ void QIOSInputContext::update(Qt::InputMethodQueries updatedProperties) qImDebug() << "fw =" << qApp->focusWindow() << "fo =" << qApp->focusObject(); Qt::InputMethodQueries changedProperties = m_imeState.update(updatedProperties); - if (changedProperties & (Qt::ImEnabled | Qt::ImHints | Qt::ImPlatformData)) { - // Changes to enablement or hints require virtual keyboard reconfigure - - qImDebug() << "changed IM properties" << changedProperties << "require keyboard reconfigure"; - - if (inputMethodAccepted()) { - qImDebug() << "replacing text responder with new text responder"; - [m_textResponder autorelease]; - m_textResponder = [[QIOSTextInputResponder alloc] initWithInputContext:this]; - [m_textResponder becomeFirstResponder]; - } else if ([UIResponder currentFirstResponder] == m_textResponder) { - qImDebug() << "IM not enabled, resigning text responder as first responder"; - [m_textResponder resignFirstResponder]; - } else { - qImDebug() << "IM not enabled. Text responder not first responder. Nothing to do"; - } - } else { - [m_textResponder notifyInputDelegate:changedProperties]; + if (m_textResponder && changedProperties & (Qt::ImHints | Qt::ImPlatformData)) { + qImDebug() << "current IM state requires new text responder"; + [m_textResponder autorelease]; + m_textResponder = 0; } - if (changedProperties & Qt::ImCursorRectangle) - scrollToCursor(); + if (inputMethodAccepted()) { + if (!m_textResponder) { + qImDebug() << "creating new text responder"; + m_textResponder = [[QIOSTextInputResponder alloc] initWithInputContext:this]; + } + if (![m_textResponder isFirstResponder]) + [m_textResponder becomeFirstResponder]; + + [m_textResponder notifyInputDelegate:changedProperties]; + + if (changedProperties & Qt::ImCursorRectangle) + scrollToCursor(); + } else if ([m_textResponder isFirstResponder]) { + [m_textResponder resignFirstResponder]; + } } bool QIOSInputContext::inputMethodAccepted() const