From 00b96399e6d3bcd7a1081721cafeb15da3ab9781 Mon Sep 17 00:00:00 2001 From: Fabian Bumberger Date: Wed, 29 Jan 2014 17:56:00 +0100 Subject: [QNX] Don't deactivate windows focus When the focus changes, screen sends a focus deactivated change for the focus window. Depending on the order, this might deactivate the window focus completely. This for example leads to problems with QComboBox. Change-Id: Ia57f061a765c1f971d86d941b17f573ce9221ae1 Reviewed-by: Kevin Krammer Reviewed-by: Bernd Weimer Reviewed-by: Rafael Roquetto --- .../platforms/qnx/qqnxscreeneventhandler.cpp | 26 +++++++++++++++++----- src/plugins/platforms/qnx/qqnxscreeneventhandler.h | 4 ++++ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp b/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp index 8757e391ef..178ea121e6 100644 --- a/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp +++ b/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp @@ -72,6 +72,7 @@ QQnxScreenEventHandler::QQnxScreenEventHandler(QQnxIntegration *integration) #if defined(QQNX_SCREENEVENTTHREAD) , m_eventThread(0) #endif + , m_focusLostTimer(-1) { // Create a touch device m_touchDevice = new QTouchDevice; @@ -617,13 +618,26 @@ void QQnxScreenEventHandler::handleKeyboardFocusPropertyEvent(screen_window_t wi qFatal("QQnx: failed to query keyboard focus property, errno=%d", errno); QWindow *focusWindow = QQnxIntegration::window(window); - if (focus) { + + if (m_focusLostTimer != -1) { + killTimer(m_focusLostTimer); + m_focusLostTimer = -1; + } + + if (focus && focusWindow != QGuiApplication::focusWindow()) QWindowSystemInterface::handleWindowActivated(focusWindow); - } else if (focusWindow == QGuiApplication::focusWindow()) { - // Deactivate only if the window was the focus window. - // Screen might send a keyboard focus event for a newly created - // window on the secondary screen, with focus 0. - QWindowSystemInterface::handleWindowActivated(0); + else if (!focus && focusWindow == QGuiApplication::focusWindow()) + m_focusLostTimer = startTimer(50); +} + +void QQnxScreenEventHandler::timerEvent(QTimerEvent *event) +{ + if (event->timerId() == m_focusLostTimer) { + killTimer(m_focusLostTimer); + m_focusLostTimer = -1; + event->accept(); + } else { + QObject::timerEvent(event); } } diff --git a/src/plugins/platforms/qnx/qqnxscreeneventhandler.h b/src/plugins/platforms/qnx/qqnxscreeneventhandler.h index a7bcd449ee..bab6420cb8 100644 --- a/src/plugins/platforms/qnx/qqnxscreeneventhandler.h +++ b/src/plugins/platforms/qnx/qqnxscreeneventhandler.h @@ -76,6 +76,9 @@ Q_SIGNALS: void newWindowCreated(void *window); void windowClosed(void *window); +protected: + void timerEvent(QTimerEvent *event); + #if defined(QQNX_SCREENEVENTTHREAD) private Q_SLOTS: void processEventsFromScreenThread(); @@ -107,6 +110,7 @@ private: #if defined(QQNX_SCREENEVENTTHREAD) QQnxScreenEventThread *m_eventThread; #endif + int m_focusLostTimer; }; QT_END_NAMESPACE -- cgit v1.2.3