Use BPS based event dispatcher

Create a QPA specific subclass of the blackberry event dispatcher
(basically the BPS equivalent to the QUnixEventDispatcherQPA created
by createUnixEventDispatcher()).

Create an event dispatcher event filter that will receive all BPS events
and then either handle them itself or delegate to event subtype
specific handlers.

Change-Id: I112e0274156727d3aa9e5693b59d041c65be4daf
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Reviewed-by: Rafael Roquetto <rafael.roquetto@kdab.com>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
bb10
Kevin Krammer 2012-03-27 14:01:38 +02:00 committed by Qt by Nokia
parent 891345072e
commit fa94f01489
7 changed files with 354 additions and 2 deletions

View File

@ -20,6 +20,7 @@ CONFIG(blackberry) {
# Uncomment these to enable debugging output for various aspects of the plugin
#DEFINES += QQNXBUFFER_DEBUG
#DEFINES += QQNXBPSEVENTFILTER_DEBUG
#DEFINES += QQNXCLIPBOARD_DEBUG
#DEFINES += QQNXEVENTTHREAD_DEBUG
#DEFINES += QQNXGLBACKINGSTORE_DEBUG
@ -81,9 +82,13 @@ contains(QT_CONFIG, opengles2) {
}
CONFIG(blackberry) {
SOURCES += qqnxnavigatorbps.cpp
SOURCES += qqnxnavigatorbps.cpp \
qqnxeventdispatcher_blackberry.cpp \
qqnxbpseventfilter.cpp
HEADERS += qqnxnavigatorbps.h
HEADERS += qqnxnavigatorbps.h \
qqnxeventdispatcher_blackberry.h \
qqnxbpseventfilter.h
LIBS += -lbps
}

View File

@ -0,0 +1,107 @@
/***************************************************************************
**
** Copyright (C) 2012 Research In Motion
** Contact: http://www.qt-project.org/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qqnxbpseventfilter.h"
#include <QAbstractEventDispatcher>
#include <QDebug>
#include <bps/event.h>
QT_BEGIN_NAMESPACE
static QQnxBpsEventFilter *s_instance = 0;
QQnxBpsEventFilter::QQnxBpsEventFilter(QObject *parent)
: QObject(parent)
{
Q_ASSERT(s_instance == 0);
s_instance = this;
}
QQnxBpsEventFilter::~QQnxBpsEventFilter()
{
Q_ASSERT(s_instance == this);
s_instance = 0;
}
void QQnxBpsEventFilter::installOnEventDispatcher(QAbstractEventDispatcher *dispatcher)
{
#if defined(QQNXBPSEVENTFILTER_DEBUG)
qDebug() << Q_FUNC_INFO << "dispatcher=" << dispatcher;
#endif
QAbstractEventDispatcher::EventFilter previousEventFilter = dispatcher->setEventFilter(dispatcherEventFilter);
// the QPA plugin creates the event dispatcher so we are the first event
// filter assert on that just in case somebody adds another event filter
// in the QQnxIntegration constructor instead of adding a new section in here
Q_ASSERT(previousEventFilter == 0);
Q_UNUSED(previousEventFilter);
}
bool QQnxBpsEventFilter::dispatcherEventFilter(void *message)
{
#if defined(QQNXBPSEVENTFILTER_DEBUG)
qDebug() << Q_FUNC_INFO;
#endif
if (s_instance == 0)
return false;
bps_event_t *event = static_cast<bps_event_t *>(message);
return s_instance->bpsEventFilter(event);
}
bool QQnxBpsEventFilter::bpsEventFilter(bps_event_t *event)
{
#if defined(QQNXBPSEVENTFILTER_DEBUG)
qDebug() << Q_FUNC_INFO << "event=" << event << "domain=" << bps_event_get_domain(event);
#else
Q_UNUSED(event);
#endif
return false;
}
QT_END_NAMESPACE

View File

@ -0,0 +1,69 @@
/***************************************************************************
**
** Copyright (C) 2012 Research In Motion
** Contact: http://www.qt-project.org/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QQNXBPSEVENTFILTER_H
#define QQNXBPSEVENTFILTER_H
#include <QObject>
struct bps_event_t;
QT_BEGIN_NAMESPACE
class QAbstractEventDispatcher;
class QQnxBpsEventFilter : public QObject
{
Q_OBJECT
public:
explicit QQnxBpsEventFilter(QObject *parent = 0);
~QQnxBpsEventFilter();
void installOnEventDispatcher(QAbstractEventDispatcher *dispatcher);
private:
static bool dispatcherEventFilter(void *message);
bool bpsEventFilter(bps_event_t *event);
};
QT_END_NAMESPACE
#endif // QQNXBPSEVENTFILTER_H

View File

@ -0,0 +1,80 @@
/***************************************************************************
**
** Copyright (C) 2012 Research In Motion
** Contact: http://www.qt-project.org/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qqnxeventdispatcher_blackberry.h"
#include <QWindowSystemInterface>
#include <private/qguiapplication_p.h>
QT_BEGIN_NAMESPACE
QQnxEventDispatcherBlackberry::QQnxEventDispatcherBlackberry(QObject *parent)
: QEventDispatcherBlackberry(parent)
{
}
QQnxEventDispatcherBlackberry::~QQnxEventDispatcherBlackberry()
{
}
bool QQnxEventDispatcherBlackberry::processEvents(QEventLoop::ProcessEventsFlags flags)
{
bool didSendEvents = QWindowSystemInterface::sendWindowSystemEvents(this, flags);
if (QEventDispatcherBlackberry::processEvents(flags))
return true;
return didSendEvents;
}
bool QQnxEventDispatcherBlackberry::hasPendingEvents()
{
return QEventDispatcherBlackberry::hasPendingEvents() || QWindowSystemInterface::windowSystemEventsQueued();
}
void QQnxEventDispatcherBlackberry::flush()
{
if (qApp)
qApp->sendPostedEvents();
}
QT_END_NAMESPACE

View File

@ -0,0 +1,66 @@
/***************************************************************************
**
** Copyright (C) 2012 Research In Motion
** Contact: http://www.qt-project.org/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QQNXEVENTDISPATCHER_BLACKBERRY_H
#define QQNXEVENTDISPATCHER_BLACKBERRY_H
#include <qglobal.h>
#include <private/qeventdispatcher_blackberry_p.h>
QT_BEGIN_NAMESPACE
class QQnxEventDispatcherBlackberry : public QEventDispatcherBlackberry
{
Q_OBJECT
public:
explicit QQnxEventDispatcherBlackberry(QObject *parent = 0);
~QQnxEventDispatcherBlackberry();
bool processEvents(QEventLoop::ProcessEventsFlags flags);
bool hasPendingEvents();
void flush();
};
QT_END_NAMESPACE
#endif // QQNXEVENTDISPATCHER_BLACKBERRY_H

View File

@ -52,6 +52,7 @@
#include "qqnxservices.h"
#if defined(Q_OS_BLACKBERRY)
#include "qqnxbpseventfilter.h"
#include "qqnxnavigatorbps.h"
#elif defined(QQNX_PPS)
#include "qqnxnavigatorpps.h"
@ -70,7 +71,12 @@
#endif
#include "private/qgenericunixfontdatabase_p.h"
#if defined(Q_OS_BLACKBERRY)
#include "qqnxeventdispatcher_blackberry.h"
#else
#include "private/qgenericunixeventdispatcher_p.h"
#endif
#include <QtGui/QPlatformWindow>
#include <QtGui/QWindowSystemInterface>
@ -106,7 +112,12 @@ QQnxIntegration::QQnxIntegration()
#if !defined(QT_NO_OPENGL)
, m_paintUsingOpenGL(false)
#endif
#if defined(Q_OS_BLACKBERRY)
, m_eventDispatcher(new QQnxEventDispatcherBlackberry())
, m_bpsEventFilter(0)
#else
, m_eventDispatcher(createUnixEventDispatcher())
#endif
, m_nativeInterface(new QQnxNativeInterface())
, m_screenEventHandler(new QQnxScreenEventHandler())
#if !defined(QT_NO_CLIPBOARD)
@ -169,6 +180,12 @@ QQnxIntegration::QQnxIntegration()
// Create services handling class
if (m_navigator)
m_services = new QQnxServices(m_navigator);
#if defined(Q_OS_BLACKBERRY)
m_bpsEventFilter = new QQnxBpsEventFilter;
m_bpsEventFilter->installOnEventDispatcher(m_eventDispatcher);
#endif
}
QQnxIntegration::~QQnxIntegration()
@ -220,6 +237,10 @@ QQnxIntegration::~QQnxIntegration()
// Destroy navigator interface
delete m_navigator;
#if defined(Q_OS_BLACKBERRY)
delete m_bpsEventFilter;
#endif
#if defined(QQNXINTEGRATION_DEBUG)
qDebug() << "QQnx: platform plugin shutdown end";
#endif

View File

@ -50,6 +50,7 @@
QT_BEGIN_NAMESPACE
class QQnxBpsEventFilter;
class QQnxEventThread;
class QQnxNativeInterface;
class QQnxWindow;
@ -135,6 +136,9 @@ private:
bool m_paintUsingOpenGL;
#endif
QAbstractEventDispatcher *m_eventDispatcher;
#if defined(Q_OS_BLACKBERRY)
QQnxBpsEventFilter *m_bpsEventFilter;
#endif
QQnxNativeInterface *m_nativeInterface;
QList<QQnxScreen*> m_screens;
QQnxScreenEventHandler *m_screenEventHandler;