From 439002cddeb32766ea9806ac8b5cf9a973ed0f13 Mon Sep 17 00:00:00 2001 From: Rafael Roquetto Date: Mon, 25 Feb 2013 19:45:02 -0300 Subject: [PATCH] BlackBerry: handle window state navigator events Change-Id: I925b1c53c5e251111469501056ee162a23e36faf Reviewed-by: Kevin Krammer Reviewed-by: Sean Harmer --- .../platforms/qnx/qqnxbpseventfilter.cpp | 20 +++++++++ src/plugins/platforms/qnx/qqnxintegration.cpp | 2 + .../qnx/qqnxnavigatoreventhandler.cpp | 6 +++ .../platforms/qnx/qqnxnavigatoreventhandler.h | 2 + src/plugins/platforms/qnx/qqnxscreen.cpp | 41 +++++++++++++++---- src/plugins/platforms/qnx/qqnxscreen.h | 3 ++ 6 files changed, 67 insertions(+), 7 deletions(-) diff --git a/src/plugins/platforms/qnx/qqnxbpseventfilter.cpp b/src/plugins/platforms/qnx/qqnxbpseventfilter.cpp index 2d19537896..542833473d 100644 --- a/src/plugins/platforms/qnx/qqnxbpseventfilter.cpp +++ b/src/plugins/platforms/qnx/qqnxbpseventfilter.cpp @@ -210,6 +210,26 @@ bool QQnxBpsEventFilter::handleNavigatorEvent(bps_event_t *event) m_navigatorEventHandler->handleExit(); break; + case NAVIGATOR_WINDOW_STATE: { + qBpsEventFilterDebug() << Q_FUNC_INFO << "WINDOW STATE event"; + const navigator_window_state_t state = navigator_event_get_window_state(event); + const QByteArray id(navigator_event_get_groupid(event)); + + switch (state) { + case NAVIGATOR_WINDOW_FULLSCREEN: + m_navigatorEventHandler->handleWindowGroupStateChanged(id, Qt::WindowFullScreen); + break; + case NAVIGATOR_WINDOW_THUMBNAIL: + m_navigatorEventHandler->handleWindowGroupStateChanged(id, Qt::WindowMinimized); + break; + case NAVIGATOR_WINDOW_INVISIBLE: + m_navigatorEventHandler->handleWindowGroupDeactivated(id); + break; + } + + break; + } + case NAVIGATOR_WINDOW_ACTIVE: { qBpsEventFilterDebug() << Q_FUNC_INFO << "WINDOW ACTIVE event"; const QByteArray id(navigator_event_get_groupid(event)); diff --git a/src/plugins/platforms/qnx/qqnxintegration.cpp b/src/plugins/platforms/qnx/qqnxintegration.cpp index f3cfdab9c6..2d5c2e54e7 100644 --- a/src/plugins/platforms/qnx/qqnxintegration.cpp +++ b/src/plugins/platforms/qnx/qqnxintegration.cpp @@ -495,6 +495,8 @@ void QQnxIntegration::createDisplay(screen_display_t display, bool isPrimary) QObject::connect(m_navigatorEventHandler, SIGNAL(rotationChanged(int)), screen, SLOT(setRotation(int))); QObject::connect(m_navigatorEventHandler, SIGNAL(windowGroupActivated(QByteArray)), screen, SLOT(activateWindowGroup(QByteArray))); QObject::connect(m_navigatorEventHandler, SIGNAL(windowGroupDeactivated(QByteArray)), screen, SLOT(deactivateWindowGroup(QByteArray))); + QObject::connect(m_navigatorEventHandler, SIGNAL(windowGroupStateChanged(QByteArray,Qt::WindowState)), + screen, SLOT(windowGroupStateChanged(QByteArray,Qt::WindowState))); } void QQnxIntegration::removeDisplay(QQnxScreen *screen) diff --git a/src/plugins/platforms/qnx/qqnxnavigatoreventhandler.cpp b/src/plugins/platforms/qnx/qqnxnavigatoreventhandler.cpp index 19fa9c5a9f..d561482b47 100644 --- a/src/plugins/platforms/qnx/qqnxnavigatoreventhandler.cpp +++ b/src/plugins/platforms/qnx/qqnxnavigatoreventhandler.cpp @@ -106,4 +106,10 @@ void QQnxNavigatorEventHandler::handleWindowGroupDeactivated(const QByteArray &i Q_EMIT windowGroupDeactivated(id); } +void QQnxNavigatorEventHandler::handleWindowGroupStateChanged(const QByteArray &id, Qt::WindowState state) +{ + qNavigatorEventHandlerDebug() << Q_FUNC_INFO << id; + Q_EMIT windowGroupStateChanged(id, state); +} + QT_END_NAMESPACE diff --git a/src/plugins/platforms/qnx/qqnxnavigatoreventhandler.h b/src/plugins/platforms/qnx/qqnxnavigatoreventhandler.h index 2068163473..cce3921a27 100644 --- a/src/plugins/platforms/qnx/qqnxnavigatoreventhandler.h +++ b/src/plugins/platforms/qnx/qqnxnavigatoreventhandler.h @@ -58,11 +58,13 @@ public: void handleExit(); void handleWindowGroupActivated(const QByteArray &id); void handleWindowGroupDeactivated(const QByteArray &id); + void handleWindowGroupStateChanged(const QByteArray &id, Qt::WindowState state); Q_SIGNALS: void rotationChanged(int angle); void windowGroupActivated(const QByteArray &id); void windowGroupDeactivated(const QByteArray &id); + void windowGroupStateChanged(const QByteArray &id, Qt::WindowState state); }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/qnx/qqnxscreen.cpp b/src/plugins/platforms/qnx/qqnxscreen.cpp index fc8b3bb167..bd60c6b71d 100644 --- a/src/plugins/platforms/qnx/qqnxscreen.cpp +++ b/src/plugins/platforms/qnx/qqnxscreen.cpp @@ -551,6 +551,21 @@ void QQnxScreen::windowClosed(void *window) removeOverlayWindow(windowHandle); } +void QQnxScreen::windowGroupStateChanged(const QByteArray &id, Qt::WindowState state) +{ + qScreenDebug() << Q_FUNC_INFO; + + if (!rootWindow() || id != rootWindow()->groupName()) + return; + + QWindow * const window = topMostChildWindow(); + + if (!window) + return; + + QWindowSystemInterface::handleWindowStateChanged(window, state); +} + void QQnxScreen::activateWindowGroup(const QByteArray &id) { qScreenDebug() << Q_FUNC_INFO; @@ -558,13 +573,12 @@ void QQnxScreen::activateWindowGroup(const QByteArray &id) if (!rootWindow() || id != rootWindow()->groupName()) return; - if (!m_childWindows.isEmpty()) { - // We're picking up the last window of the list here - // because this list is ordered by stacking order. - // Last window is effectively the one on top. - QWindow * const window = m_childWindows.last()->window(); - QWindowSystemInterface::handleWindowActivated(window); - } + QWindow * const window = topMostChildWindow(); + + if (!window) + return; + + QWindowSystemInterface::handleWindowActivated(window); } void QQnxScreen::deactivateWindowGroup(const QByteArray &id) @@ -586,4 +600,17 @@ QSharedPointer QQnxScreen::rootWindow() const return m_rootWindow; } +QWindow * QQnxScreen::topMostChildWindow() const +{ + if (!m_childWindows.isEmpty()) { + + // We're picking up the last window of the list here + // because this list is ordered by stacking order. + // Last window is effectively the one on top. + return m_childWindows.last()->window(); + } + + return 0; +} + QT_END_NAMESPACE diff --git a/src/plugins/platforms/qnx/qqnxscreen.h b/src/plugins/platforms/qnx/qqnxscreen.h index 39cd4159d1..41dc675599 100644 --- a/src/plugins/platforms/qnx/qqnxscreen.h +++ b/src/plugins/platforms/qnx/qqnxscreen.h @@ -101,6 +101,7 @@ public Q_SLOTS: void setRotation(int rotation); void newWindowCreated(void *window); void windowClosed(void *window); + void windowGroupStateChanged(const QByteArray &id, Qt::WindowState state); void activateWindowGroup(const QByteArray &id); void deactivateWindowGroup(const QByteArray &id); @@ -114,6 +115,8 @@ private: void addOverlayWindow(screen_window_t window); void removeOverlayWindow(screen_window_t window); + QWindow *topMostChildWindow() const; + screen_context_t m_screenContext; screen_display_t m_display; mutable QSharedPointer m_rootWindow;