diff options
author | Rafael Roquetto <rafael.roquetto.qnx@kdab.com> | 2012-06-20 09:53:27 (GMT) |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-06-26 14:57:52 (GMT) |
commit | 3ab453efca6d0d127f5d706ef623c611819979d4 (patch) | |
tree | c69271b00d2e6e84a1dfa55e27239ff5aef39249 /src/plugins/platforms | |
parent | bec02b3f36b7e266b00bb143c459cacabda69b69 (diff) | |
download | Qt-3ab453efca6d0d127f5d706ef623c611819979d4.zip Qt-3ab453efca6d0d127f5d706ef623c611819979d4.tar.gz Qt-3ab453efca6d0d127f5d706ef623c611819979d4.tar.bz2 |
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 6fcef85..612fcab 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 a9e8523..c2d3693 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 bfd1eb8..7371bd5 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 |