iOS: ensure keyboard is visible, even when IM hints hasn't changed

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ø <tor.arne.vestbo@theqtcompany.com>
bb10
Richard Moe Gustavsen 2015-03-11 15:43:43 +01:00
parent fe59121d24
commit 4add7d236b
1 changed files with 19 additions and 20 deletions

View File

@ -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