From eae36248bce464cef22a6a6286690e1cc6857159 Mon Sep 17 00:00:00 2001 From: Rafael Roquetto Date: Tue, 5 Mar 2013 11:48:22 -0300 Subject: BlackBerry: handle window state navigator events backport of qt5 439002cddeb32766ea9806ac8b5cf9a973ed0f13 Change-Id: I2431ebd1240ba6f3c2b690b311301d222ec10865 Reviewed-by: Kevin Krammer Reviewed-by: Sean Harmer --- .../platforms/blackberry/qbbbpseventfilter.cpp | 23 ++++++++++++ .../platforms/blackberry/qbbintegration.cpp | 2 + .../blackberry/qbbnavigatoreventhandler.cpp | 9 +++++ .../blackberry/qbbnavigatoreventhandler.h | 2 + src/plugins/platforms/blackberry/qbbscreen.cpp | 43 ++++++++++++++++++---- src/plugins/platforms/blackberry/qbbscreen.h | 3 ++ 6 files changed, 75 insertions(+), 7 deletions(-) diff --git a/src/plugins/platforms/blackberry/qbbbpseventfilter.cpp b/src/plugins/platforms/blackberry/qbbbpseventfilter.cpp index 1a5c577..cd77751 100644 --- a/src/plugins/platforms/blackberry/qbbbpseventfilter.cpp +++ b/src/plugins/platforms/blackberry/qbbbpseventfilter.cpp @@ -220,6 +220,29 @@ bool QBBBpsEventFilter::handleNavigatorEvent(bps_event_t *event) mNavigatorEventHandler->handleExit(); break; + case NAVIGATOR_WINDOW_STATE: { + #if defined(QBBBPSEVENTFILTER_DEBUG) + qDebug() << Q_FUNC_INFO << "WINDOW STATE event"; + #endif + + 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: + mNavigatorEventHandler->handleWindowGroupStateChanged(id, Qt::WindowFullScreen); + break; + case NAVIGATOR_WINDOW_THUMBNAIL: + mNavigatorEventHandler->handleWindowGroupStateChanged(id, Qt::WindowMinimized); + break; + case NAVIGATOR_WINDOW_INVISIBLE: + mNavigatorEventHandler->handleWindowGroupDeactivated(id); + break; + } + + break; + } + case NAVIGATOR_WINDOW_ACTIVE: { #if defined(QBBBPSEVENTFILTER_DEBUG) qDebug() << "QBB: Navigator WINDOW ACTIVE event"; diff --git a/src/plugins/platforms/blackberry/qbbintegration.cpp b/src/plugins/platforms/blackberry/qbbintegration.cpp index 5137431..5a6e6e2 100644 --- a/src/plugins/platforms/blackberry/qbbintegration.cpp +++ b/src/plugins/platforms/blackberry/qbbintegration.cpp @@ -378,6 +378,8 @@ void QBBIntegration::createDisplay(screen_display_t display, int screenIndex) QObject::connect(mNavigatorEventHandler, SIGNAL(rotationChanged(int)), screen, SLOT(setRotation(int))); QObject::connect(mNavigatorEventHandler, SIGNAL(windowGroupActivated(QByteArray)), screen, SLOT(activateWindowGroup(QByteArray))); QObject::connect(mNavigatorEventHandler, SIGNAL(windowGroupDeactivated(QByteArray)), screen, SLOT(deactivateWindowGroup(QByteArray))); + QObject::connect(mNavigatorEventHandler, SIGNAL(windowGroupStateChanged(QByteArray,Qt::WindowState)), + screen, SLOT(windowGroupStateChanged(QByteArray,Qt::WindowState))); } void QBBIntegration::removeDisplay(QBBScreen *screen) diff --git a/src/plugins/platforms/blackberry/qbbnavigatoreventhandler.cpp b/src/plugins/platforms/blackberry/qbbnavigatoreventhandler.cpp index 0f19904..1db3ee7 100644 --- a/src/plugins/platforms/blackberry/qbbnavigatoreventhandler.cpp +++ b/src/plugins/platforms/blackberry/qbbnavigatoreventhandler.cpp @@ -116,4 +116,13 @@ void QBBNavigatorEventHandler::handleWindowGroupDeactivated(const QByteArray &id Q_EMIT windowGroupDeactivated(id); } +void QBBNavigatorEventHandler::handleWindowGroupStateChanged(const QByteArray &id, Qt::WindowState state) +{ +#if defined(QBBNAVIGATOREVENTHANDLER_DEBUG) + qDebug() << Q_FUNC_INFO << id; +#endif + + Q_EMIT windowGroupStateChanged(id, state); +} + QT_END_NAMESPACE diff --git a/src/plugins/platforms/blackberry/qbbnavigatoreventhandler.h b/src/plugins/platforms/blackberry/qbbnavigatoreventhandler.h index 86a4611..d05a591 100644 --- a/src/plugins/platforms/blackberry/qbbnavigatoreventhandler.h +++ b/src/plugins/platforms/blackberry/qbbnavigatoreventhandler.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/blackberry/qbbscreen.cpp b/src/plugins/platforms/blackberry/qbbscreen.cpp index 091c044..9edd204 100644 --- a/src/plugins/platforms/blackberry/qbbscreen.cpp +++ b/src/plugins/platforms/blackberry/qbbscreen.cpp @@ -521,6 +521,23 @@ void QBBScreen::removeOverlayWindow(screen_window_t window) updateHierarchy(); } +void QBBScreen::windowGroupStateChanged(const QByteArray &id, Qt::WindowState state) +{ +#if defined(QBBSCREEN_DEBUG) + qDebug() << Q_FUNC_INFO; +#endif + + if (!rootWindow() || id != rootWindow()->groupName()) + return; + + QWidget * const window = topMostChildWindow(); + + if (!window) + return; + + QWindowSystemInterface::handleWindowStateChanged(window, state); +} + void QBBScreen::activateWindowGroup(const QByteArray &id) { #if defined(QBBSCREEN_DEBUG) @@ -530,13 +547,12 @@ void QBBScreen::activateWindowGroup(const QByteArray &id) if (!rootWindow() || id != rootWindow()->groupName()) return; - if (!mChildren.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. - QWidget * const window = mChildren.last()->widget(); - QWindowSystemInterface::handleWindowActivated(window); - } + QWidget * const window = topMostChildWindow(); + + if (!window) + return; + + QWindowSystemInterface::handleWindowActivated(window); } void QBBScreen::deactivateWindowGroup(const QByteArray &id) @@ -551,4 +567,17 @@ void QBBScreen::deactivateWindowGroup(const QByteArray &id) QWindowSystemInterface::handleWindowActivated(0); } +QWidget * QBBScreen::topMostChildWindow() const +{ + if (!mChildren.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 mChildren.last()->widget(); + } + + return 0; +} + QT_END_NAMESPACE diff --git a/src/plugins/platforms/blackberry/qbbscreen.h b/src/plugins/platforms/blackberry/qbbscreen.h index de92836..a5a8e32 100644 --- a/src/plugins/platforms/blackberry/qbbscreen.h +++ b/src/plugins/platforms/blackberry/qbbscreen.h @@ -93,6 +93,7 @@ public Q_SLOTS: void setRotation(int rotation); void newWindowCreated(screen_window_t window); void windowClosed(screen_window_t window); + void windowGroupStateChanged(const QByteArray &id, Qt::WindowState state); void activateWindowGroup(const QByteArray &id); void deactivateWindowGroup(const QByteArray &id); @@ -106,6 +107,8 @@ private: void addOverlayWindow(screen_window_t window); void removeOverlayWindow(screen_window_t window); + QWidget *topMostChildWindow() const; + screen_context_t mContext; screen_display_t mDisplay; QSharedPointer mRootWindow; -- cgit v0.12