From 1faba97683ec42155acd7ed51d14f65bb240bc75 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Mon, 13 Oct 2014 13:09:06 +0200 Subject: [PATCH] Delay showing keyboard until application is active Android starts asking lots of questions when the software keyboard pops up, so let's wait until the application is initialized. This works around a deadlock on startup. Task-number: QTBUG-41369 Change-Id: I1c79e32d08c7cc11748ec55efbff3bc25e40f4b2 Reviewed-by: Christian Stromme --- .../platforms/android/qandroidinputcontext.cpp | 12 ++++++++++++ src/plugins/platforms/android/qandroidinputcontext.h | 3 +++ 2 files changed, 15 insertions(+) diff --git a/src/plugins/platforms/android/qandroidinputcontext.cpp b/src/plugins/platforms/android/qandroidinputcontext.cpp index ca9d1e69c9..e3d488b958 100644 --- a/src/plugins/platforms/android/qandroidinputcontext.cpp +++ b/src/plugins/platforms/android/qandroidinputcontext.cpp @@ -519,6 +519,10 @@ bool QAndroidInputContext::isAnimating() const void QAndroidInputContext::showInputPanel() { + if (QGuiApplication::applicationState() != Qt::ApplicationActive) { + connect(qGuiApp, SIGNAL(applicationStateChanged(Qt::ApplicationState)), this, SLOT(showInputPanelLater(Qt::ApplicationState))); + return; + } QSharedPointer query = focusObjectInputMethodQueryThreadSafe(); if (query.isNull()) return; @@ -541,6 +545,14 @@ void QAndroidInputContext::showInputPanel() query->value(Qt::ImHints).toUInt()); } +void QAndroidInputContext::showInputPanelLater(Qt::ApplicationState state) +{ + if (state != Qt::ApplicationActive) + return; + disconnect(qGuiApp, SIGNAL(applicationStateChanged(Qt::ApplicationState)), this, SLOT(showInputPanelLater(Qt::ApplicationState))); + showInputPanel(); +} + void QAndroidInputContext::hideInputPanel() { QtAndroidInput::hideSoftwareKeyboard(); diff --git a/src/plugins/platforms/android/qandroidinputcontext.h b/src/plugins/platforms/android/qandroidinputcontext.h index 670a051139..2ebb155d2a 100644 --- a/src/plugins/platforms/android/qandroidinputcontext.h +++ b/src/plugins/platforms/android/qandroidinputcontext.h @@ -112,6 +112,9 @@ public: public slots: void updateCursorPosition(); +private slots: + void showInputPanelLater(Qt::ApplicationState); + private: void sendInputMethodEventThreadSafe(QInputMethodEvent *event); Q_INVOKABLE void sendInputMethodEventUnsafe(QInputMethodEvent *event);