diff options
author | Rafael Roquetto <rafael.roquetto.qnx@kdab.com> | 2012-06-20 11:53:27 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-06-26 16:57:52 +0200 |
commit | 3ab453efca6d0d127f5d706ef623c611819979d4 (patch) | |
tree | c69271b00d2e6e84a1dfa55e27239ff5aef39249 /src/plugins/platforms | |
parent | bec02b3f36b7e266b00bb143c459cacabda69b69 (diff) | |
download | qt4-tools-3ab453efca6d0d127f5d706ef623c611819979d4.tar.gz |
Enable MT screen event handling on Blackberry
Consuming incoming screen events through the BPS event
dispatcher on its current incarnation has proven to be
very inefficient since it cannot put up with the screen
event throughput. This patch enables the screen event
thread also for Q_OS_BLACKBERRY platforms, in addition
to stock QNX. This behavior can still be configurated
through the project file, though.
Task-number: QTBUG-26177
akin to qt5/qtbase: 9e66ee2d59d28d61e06e5c57485f1a331b82f269
Change-Id: I307b805f125d0eb213b21b3ef4476c4df5d6a853
Reviewed-by: Kevin Krammer <kevin.krammer@kdab.com>
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r-- | src/plugins/platforms/blackberry/blackberry.pro | 8 | ||||
-rw-r--r-- | src/plugins/platforms/blackberry/qbbbpseventfilter.cpp | 15 | ||||
-rw-r--r-- | src/plugins/platforms/blackberry/qbbintegration.cpp | 27 |
3 files changed, 38 insertions, 12 deletions
diff --git a/src/plugins/platforms/blackberry/blackberry.pro b/src/plugins/platforms/blackberry/blackberry.pro index 6fcef859d1..612fcab6f4 100644 --- a/src/plugins/platforms/blackberry/blackberry.pro +++ b/src/plugins/platforms/blackberry/blackberry.pro @@ -4,6 +4,14 @@ include(../../qpluginbase.pri) QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms QT += opengl +blackberry { + # Comment this to enable screen event + # handling through the event dispatcher. + DEFINES += QBB_SCREENEVENTTHREAD +} else { + DEFINES += QBB_SCREENEVENTTHREAD +} + SOURCES = main.cpp \ qbbbuffer.cpp \ qbbscreeneventthread.cpp \ diff --git a/src/plugins/platforms/blackberry/qbbbpseventfilter.cpp b/src/plugins/platforms/blackberry/qbbbpseventfilter.cpp index a9e8523d00..c2d36938af 100644 --- a/src/plugins/platforms/blackberry/qbbbpseventfilter.cpp +++ b/src/plugins/platforms/blackberry/qbbbpseventfilter.cpp @@ -96,12 +96,22 @@ void QBBBpsEventFilter::installOnEventDispatcher(QAbstractEventDispatcher *dispa void QBBBpsEventFilter::registerForScreenEvents(QBBScreen *screen) { + if (!mScreenEventHandler) { + qWarning("QBB: trying to register for screen events, but no handler provided"); + return; + } + if (screen_request_events(screen->nativeContext()) != BPS_SUCCESS) qWarning("QBB: failed to register for screen events on screen %p", screen->nativeContext()); } void QBBBpsEventFilter::unregisterForScreenEvents(QBBScreen *screen) { + if (!mScreenEventHandler) { + qWarning("QBB: trying to unregister for screen events, but no handler provided"); + return; + } + if (screen_stop_events(screen->nativeContext()) != BPS_SUCCESS) qWarning("QBB: failed to unregister for screen events on screen %p", screen->nativeContext()); } @@ -127,6 +137,11 @@ bool QBBBpsEventFilter::bpsEventFilter(bps_event_t *event) #endif if (eventDomain == screen_get_domain()) { + if (!mScreenEventHandler) { + qWarning("QBB: registered for screen events, but no handler provided"); + return false; + } + screen_event_t screenEvent = screen_event_get_event(event); return mScreenEventHandler->handleEvent(screenEvent); } diff --git a/src/plugins/platforms/blackberry/qbbintegration.cpp b/src/plugins/platforms/blackberry/qbbintegration.cpp index bfd1eb86b9..7371bd517d 100644 --- a/src/plugins/platforms/blackberry/qbbintegration.cpp +++ b/src/plugins/platforms/blackberry/qbbintegration.cpp @@ -121,8 +121,7 @@ QBBIntegration::QBBIntegration() : createDisplays(); // create/start event thread - // Not on BlackBerry, it has specialised event dispatcher which also handles screen events -#if !defined(Q_OS_BLACKBERRY) +#if defined(QBB_SCREENEVENTTHREAD) mScreenEventThread = new QBBScreenEventThread(mContext, mScreenEventHandler); mScreenEventThread->start(); #endif @@ -138,10 +137,14 @@ QBBIntegration::QBBIntegration() : QBBVirtualKeyboardBps *virtualKeyboardBps = new QBBVirtualKeyboardBps; - mBpsEventFilter = new QBBBpsEventFilter(mNavigatorEventHandler, mScreenEventHandler, virtualKeyboardBps); - Q_FOREACH (QPlatformScreen *platformScreen, mScreens) { - QBBScreen *screen = static_cast<QBBScreen*>(platformScreen); - mBpsEventFilter->registerForScreenEvents(screen); + mBpsEventFilter = new QBBBpsEventFilter(mNavigatorEventHandler, + (mScreenEventThread ? 0 : mScreenEventHandler), virtualKeyboardBps); + + if (!mScreenEventThread) { + Q_FOREACH (QPlatformScreen *platformScreen, mScreens) { + QBBScreen *screen = static_cast<QBBScreen*>(platformScreen); + mBpsEventFilter->registerForScreenEvents(screen); + } } mBpsEventFilter->installOnEventDispatcher(QAbstractEventDispatcher::instance()); @@ -178,20 +181,20 @@ QBBIntegration::~QBBIntegration() delete mLocaleThread; #endif -#if !defined(Q_OS_BLACKBERRY) +#if defined(QBB_SCREENEVENTTHREAD) // stop/destroy event thread delete mScreenEventThread; +#elif defined(Q_OS_BLACKBERRY) + Q_FOREACH (QPlatformScreen *platformScreen, mScreens) { + QBBScreen *screen = static_cast<QBBScreen*>(platformScreen); + mBpsEventFilter->unregisterForScreenEvents(screen); + } #endif // stop/destroy navigator event handling classes delete mNavigatorEventNotifier; #if defined(Q_OS_BLACKBERRY) - Q_FOREACH (QPlatformScreen *platformScreen, mScreens) { - QBBScreen *screen = static_cast<QBBScreen*>(platformScreen); - mBpsEventFilter->unregisterForScreenEvents(screen); - } - delete mBpsEventFilter; #endif |