summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Krammer <kevin.krammer.qnx@kdab.com>2012-04-26 13:48:26 (GMT)
committerQt by Nokia <qt-info@nokia.com>2012-05-03 13:50:19 (GMT)
commit3c91bc1d94445f195ff047798b4b5d3470ddd27d (patch)
treec4ded94de4ad6b698e939ed20e86989d53916c0f
parentbddffd6d6ead62dc078683fdb601b425c2f9e641 (diff)
downloadQt-3c91bc1d94445f195ff047798b4b5d3470ddd27d.zip
Qt-3c91bc1d94445f195ff047798b4b5d3470ddd27d.tar.gz
Qt-3c91bc1d94445f195ff047798b4b5d3470ddd27d.tar.bz2
Handle navigator events in BPS event filter
Backport of 050ff2730c96831aedb5897a60eafaf13ae8d93e Change-Id: Ida0566e88d5f53ea879a7fd2bda6746814b4e365 Reviewed-by: Sean Harmer <sean.harmer@kdab.com> Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
-rw-r--r--src/plugins/platforms/blackberry/qbbbpseventfilter.cpp71
-rw-r--r--src/plugins/platforms/blackberry/qbbbpseventfilter.h7
-rw-r--r--src/plugins/platforms/blackberry/qbbintegration.cpp7
3 files changed, 81 insertions, 4 deletions
diff --git a/src/plugins/platforms/blackberry/qbbbpseventfilter.cpp b/src/plugins/platforms/blackberry/qbbbpseventfilter.cpp
index 5240a90..7d1701b 100644
--- a/src/plugins/platforms/blackberry/qbbbpseventfilter.cpp
+++ b/src/plugins/platforms/blackberry/qbbbpseventfilter.cpp
@@ -40,6 +40,7 @@
//#define QBBBPSEVENTFILTER_DEBUG
#include "qbbbpseventfilter.h"
+#include "qbbnavigatoreventhandler.h"
#include "qbbscreen.h"
#include "qbbscreeneventhandler.h"
@@ -47,14 +48,17 @@
#include <QDebug>
#include <bps/event.h>
+#include <bps/navigator.h>
#include <bps/screen.h>
QT_BEGIN_NAMESPACE
static QBBBpsEventFilter *sInstance;
-QBBBpsEventFilter::QBBBpsEventFilter(QBBScreenEventHandler *screenEventHandler, QObject *parent)
+QBBBpsEventFilter::QBBBpsEventFilter(QBBNavigatorEventHandler *navigatorEventHandler,
+ QBBScreenEventHandler *screenEventHandler, QObject *parent)
: QObject(parent)
+ , mNavigatorEventHandler(navigatorEventHandler)
, mScreenEventHandler(screenEventHandler)
{
Q_ASSERT(sInstance == 0);
@@ -74,6 +78,8 @@ void QBBBpsEventFilter::installOnEventDispatcher(QAbstractEventDispatcher *dispa
#if defined(QBBBPSEVENTFILTER_DEBUG)
qDebug() << Q_FUNC_INFO << "dispatcher=" << dispatcher;
#endif
+ if (navigator_request_events(0) != BPS_SUCCESS)
+ qWarning("QBB: failed to register for navigator events");
QAbstractEventDispatcher::EventFilter previousEventFilter = dispatcher->setEventFilter(dispatcherEventFilter);
@@ -122,7 +128,70 @@ bool QBBBpsEventFilter::bpsEventFilter(bps_event_t *event)
return mScreenEventHandler->handleEvent(screenEvent);
}
+ if (eventDomain == navigator_get_domain())
+ return handleNavigatorEvent(event);
+
return false;
}
+bool QBBBpsEventFilter::handleNavigatorEvent(bps_event_t *event)
+{
+ switch (bps_event_get_code(event)) {
+ case NAVIGATOR_ORIENTATION_CHECK: {
+ const int angle = navigator_event_get_orientation_angle(event);
+
+ #if defined(QBBBPSEVENTFILTER_DEBUG)
+ qDebug() << "QBB: Navigator ORIENTATION CHECK event. angle=" << angle;
+ #endif
+
+ const bool result = mNavigatorEventHandler->handleOrientationCheck(angle);
+
+ #if defined(QBBBPSEVENTFILTER_DEBUG)
+ qDebug() << "QBB: Navigator ORIENTATION CHECK event. result=" << result;
+ #endif
+
+ // reply to navigator whether orientation is acceptable
+ navigator_orientation_check_response(event, result);
+ break;
+ }
+
+ case NAVIGATOR_ORIENTATION: {
+ const int angle = navigator_event_get_orientation_angle(event);
+
+ #if defined(QBBBPSEVENTFILTER_DEBUG)
+ qDebug() << "QBB: Navigator ORIENTATION event. angle=" << angle;
+ #endif
+
+ mNavigatorEventHandler->handleOrientationChange(angle);
+
+ navigator_done_orientation(event);
+ break;
+ }
+
+ case NAVIGATOR_SWIPE_DOWN:
+ #if defined(QBBBPSEVENTFILTER_DEBUG)
+ qDebug() << "QBB: Navigator SWIPE DOWN event";
+ #endif
+
+ mNavigatorEventHandler->handleSwipeDown();
+ break;
+
+ case NAVIGATOR_EXIT:
+ #if defined(QBBBPSEVENTFILTER_DEBUG)
+ qDebug() << "QBB: Navigator EXIT event";
+ #endif
+
+ mNavigatorEventHandler->handleExit();
+ break;
+
+ default:
+ #if defined(QBBBPSEVENTFILTER_DEBUG)
+ qDebug() << "QBB: Unhandled navigator event. code=" << bps_event_get_code(event);
+ #endif
+ return false;
+ }
+
+ return true;
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/blackberry/qbbbpseventfilter.h b/src/plugins/platforms/blackberry/qbbbpseventfilter.h
index e11478c..67e6e76 100644
--- a/src/plugins/platforms/blackberry/qbbbpseventfilter.h
+++ b/src/plugins/platforms/blackberry/qbbbpseventfilter.h
@@ -47,6 +47,7 @@ struct bps_event_t;
QT_BEGIN_NAMESPACE
class QAbstractEventDispatcher;
+class QBBNavigatorEventHandler;
class QBBScreen;
class QBBScreenEventHandler;
@@ -54,7 +55,8 @@ class QBBBpsEventFilter : public QObject
{
Q_OBJECT
public:
- explicit QBBBpsEventFilter(QBBScreenEventHandler *screenEventHandler, QObject *parent = 0);
+ QBBBpsEventFilter(QBBNavigatorEventHandler *navigatorEventHandler,
+ QBBScreenEventHandler *screenEventHandler, QObject *parent = 0);
~QBBBpsEventFilter();
void installOnEventDispatcher(QAbstractEventDispatcher *dispatcher);
@@ -66,7 +68,10 @@ private:
static bool dispatcherEventFilter(void *message);
bool bpsEventFilter(bps_event_t *event);
+ bool handleNavigatorEvent(bps_event_t *event);
+
private:
+ QBBNavigatorEventHandler *mNavigatorEventHandler;
QBBScreenEventHandler *mScreenEventHandler;
};
diff --git a/src/plugins/platforms/blackberry/qbbintegration.cpp b/src/plugins/platforms/blackberry/qbbintegration.cpp
index aba8514..4767dcd 100644
--- a/src/plugins/platforms/blackberry/qbbintegration.cpp
+++ b/src/plugins/platforms/blackberry/qbbintegration.cpp
@@ -107,11 +107,14 @@ QBBIntegration::QBBIntegration() :
}
// Create/start navigator event notifier
+ // Not on BlackBerry, it has specialised event dispatcher which also handles navigator events
+#if !defined(Q_OS_BLACKBERRY)
mNavigatorEventNotifier = new QBBNavigatorEventNotifier(mNavigatorEventHandler);
// delay invocation of start() to the time the event loop is up and running
// needed to have the QThread internals of the main thread properly initialized
QMetaObject::invokeMethod(mNavigatorEventNotifier, "start", Qt::QueuedConnection);
+#endif
// Create displays for all possible screens (which may not be attached)
createDisplays();
@@ -131,7 +134,7 @@ QBBIntegration::QBBIntegration() :
#if defined(Q_OS_BLACKBERRY)
bps_initialize();
- mBpsEventFilter = new QBBBpsEventFilter(mScreenEventHandler);
+ mBpsEventFilter = new QBBBpsEventFilter(mNavigatorEventHandler, mScreenEventHandler);
Q_FOREACH (QPlatformScreen *platformScreen, mScreens) {
QBBScreen *screen = static_cast<QBBScreen*>(platformScreen);
mBpsEventFilter->registerForScreenEvents(screen);
@@ -177,7 +180,6 @@ QBBIntegration::~QBBIntegration()
// stop/destroy navigator event handling classes
delete mNavigatorEventNotifier;
- delete mNavigatorEventHandler;
#if defined(Q_OS_BLACKBERRY)
Q_FOREACH (QPlatformScreen *platformScreen, mScreens) {
@@ -188,6 +190,7 @@ QBBIntegration::~QBBIntegration()
delete mBpsEventFilter;
#endif
+ delete mNavigatorEventHandler;
delete mScreenEventHandler;
// destroy all displays