#DEFINES += QQNXBUFFER_DEBUG
#DEFINES += QQNXBPSEVENTFILTER_DEBUG
#DEFINES += QQNXCLIPBOARD_DEBUG
-#DEFINES += QQNXEVENTTHREAD_DEBUG
+#DEFINES += QQNXSCREENEVENTTHREAD_DEBUG
#DEFINES += QQNXGLBACKINGSTORE_DEBUG
#DEFINES += QQNXGLCONTEXT_DEBUG
#DEFINES += QQNXINPUTCONTEXT_DEBUG
SOURCES = main.cpp \
qqnxbuffer.cpp \
- qqnxeventthread.cpp \
+ qqnxscreeneventthread.cpp \
qqnxintegration.cpp \
qqnxscreen.cpp \
qqnxwindow.cpp \
HEADERS = main.h \
qqnxbuffer.h \
- qqnxeventthread.h \
+ qqnxscreeneventthread.h \
qqnxkeytranslator.h \
qqnxintegration.h \
qqnxscreen.h \
****************************************************************************/
#include "qqnxbpseventfilter.h"
+#include "qqnxscreen.h"
+#include "qqnxscreeneventhandler.h"
#include <QAbstractEventDispatcher>
#include <QDebug>
#include <bps/event.h>
+#include <bps/screen.h>
QT_BEGIN_NAMESPACE
static QQnxBpsEventFilter *s_instance = 0;
-QQnxBpsEventFilter::QQnxBpsEventFilter(QObject *parent)
+QQnxBpsEventFilter::QQnxBpsEventFilter(QQnxScreenEventHandler *screenEventHandler, QObject *parent)
: QObject(parent)
+ , m_screenEventHandler(screenEventHandler)
{
Q_ASSERT(s_instance == 0);
Q_UNUSED(previousEventFilter);
}
+void QQnxBpsEventFilter::registerForScreenEvents(QQnxScreen *screen)
+{
+ if (screen_request_events(screen->nativeContext()) != BPS_SUCCESS)
+ qWarning("QQNX: failed to register for screen events on screen %p", screen->nativeContext());
+}
+
+void QQnxBpsEventFilter::unregisterForScreenEvents(QQnxScreen *screen)
+{
+ if (screen_stop_events(screen->nativeContext()) != BPS_SUCCESS)
+ qWarning("QQNX: failed to unregister for screen events on screen %p", screen->nativeContext());
+}
+
bool QQnxBpsEventFilter::dispatcherEventFilter(void *message)
{
#if defined(QQNXBPSEVENTFILTER_DEBUG)
bool QQnxBpsEventFilter::bpsEventFilter(bps_event_t *event)
{
+ const int eventDomain = bps_event_get_domain(event);
+
#if defined(QQNXBPSEVENTFILTER_DEBUG)
- qDebug() << Q_FUNC_INFO << "event=" << event << "domain=" << bps_event_get_domain(event);
-#else
- Q_UNUSED(event);
+ qDebug() << Q_FUNC_INFO << "event=" << event << "domain=" << eventDomain;
#endif
+ if (eventDomain == screen_get_domain()) {
+ screen_event_t screenEvent = screen_event_get_event(event);
+ return m_screenEventHandler->handleEvent(screenEvent);
+ }
+
return false;
}
QT_BEGIN_NAMESPACE
class QAbstractEventDispatcher;
+class QQnxScreen;
+class QQnxScreenEventHandler;
class QQnxBpsEventFilter : public QObject
{
Q_OBJECT
public:
- explicit QQnxBpsEventFilter(QObject *parent = 0);
+ explicit QQnxBpsEventFilter(QQnxScreenEventHandler *screenEventHandler, QObject *parent = 0);
~QQnxBpsEventFilter();
void installOnEventDispatcher(QAbstractEventDispatcher *dispatcher);
+ void registerForScreenEvents(QQnxScreen *screen);
+ void unregisterForScreenEvents(QQnxScreen *screen);
+
private:
static bool dispatcherEventFilter(void *message);
bool bpsEventFilter(bps_event_t *event);
+
+private:
+ QQnxScreenEventHandler *m_screenEventHandler;
};
QT_END_NAMESPACE
****************************************************************************/
#include "qqnxintegration.h"
-#include "qqnxeventthread.h"
+#include "qqnxscreeneventthread.h"
#include "qqnxnativeinterface.h"
#include "qqnxrasterbackingstore.h"
#include "qqnxscreen.h"
QQnxIntegration::QQnxIntegration()
: QPlatformIntegration()
- , m_eventThread(0)
+ , m_screenEventThread(0)
, m_navigatorEventHandler(new QQnxNavigatorEventHandler())
, m_virtualKeyboard(0)
#if defined(QQNX_PPS)
#endif
// Create/start event thread
- m_eventThread = new QQnxEventThread(m_screenContext, m_screenEventHandler);
- m_eventThread->start();
+ // Not on BlackBerry, it has specialised event dispatcher which also handles screen events
+#if !defined(Q_OS_BLACKBERRY)
+ m_screenEventThread = new QQnxScreenEventThread(m_screenContext, m_screenEventHandler);
+ m_screenEventThread->start();
+#endif
#if defined(QQNX_PPS)
// Create/start the keyboard class.
m_services = new QQnxServices(m_navigator);
#if defined(Q_OS_BLACKBERRY)
- m_bpsEventFilter = new QQnxBpsEventFilter;
+ m_bpsEventFilter = new QQnxBpsEventFilter(m_screenEventHandler);
+ Q_FOREACH (QQnxScreen *screen, m_screens)
+ m_bpsEventFilter->registerForScreenEvents(screen);
+
m_bpsEventFilter->installOnEventDispatcher(m_eventDispatcher);
#endif
#endif
delete m_navigatorEventHandler;
- // Stop/destroy event thread
- delete m_eventThread;
+#if !defined(Q_OS_BLACKBERRY)
+ // Stop/destroy screen event thread
+ delete m_screenEventThread;
+#else
+ Q_FOREACH (QQnxScreen *screen, m_screens)
+ m_bpsEventFilter->unregisterForScreenEvents(screen);
+
+ delete m_bpsEventFilter;
+#endif
+
delete m_screenEventHandler;
// Destroy all displays
// 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
QT_BEGIN_NAMESPACE
class QQnxBpsEventFilter;
-class QQnxEventThread;
+class QQnxScreenEventThread;
class QQnxNativeInterface;
class QQnxWindow;
class QQnxScreen;
static void removeWindow(screen_window_t qnxWindow);
screen_context_t m_screenContext;
- QQnxEventThread *m_eventThread;
+ QQnxScreenEventThread *m_screenEventThread;
QQnxNavigatorEventHandler *m_navigatorEventHandler;
QQnxAbstractVirtualKeyboard *m_virtualKeyboard;
#if defined(QQNX_PPS)
**
****************************************************************************/
-#include "qqnxeventthread.h"
+#include "qqnxscreeneventthread.h"
#include "qqnxscreeneventhandler.h"
#include <QtCore/QDebug>
#include <cctype>
-QQnxEventThread::QQnxEventThread(screen_context_t context,
- QQnxScreenEventHandler *screenEventHandler)
+QQnxScreenEventThread::QQnxScreenEventThread(screen_context_t context, QQnxScreenEventHandler *screenEventHandler)
: QThread(),
m_screenContext(context),
m_screenEventHandler(screenEventHandler),
{
}
-QQnxEventThread::~QQnxEventThread()
+QQnxScreenEventThread::~QQnxScreenEventThread()
{
// block until thread terminates
shutdown();
}
-void QQnxEventThread::injectKeyboardEvent(int flags, int sym, int mod, int scan, int cap)
+void QQnxScreenEventThread::injectKeyboardEvent(int flags, int sym, int mod, int scan, int cap)
{
QQnxScreenEventHandler::injectKeyboardEvent(flags, sym, mod, scan, cap);
}
-void QQnxEventThread::run()
+void QQnxScreenEventThread::run()
{
screen_event_t event;
errno = 0;
int result = screen_create_event(&event);
if (result)
- qFatal("QQNX: failed to create event, errno=%d", errno);
+ qFatal("QQNX: failed to create screen event, errno=%d", errno);
-#if defined(QQNXEVENTTHREAD_DEBUG)
- qDebug() << "QQNX: event loop started";
+#if defined(QQNXSCREENEVENTTHREAD_DEBUG)
+ qDebug() << "QQNX: screen event thread started";
#endif
// loop indefinitely
errno = 0;
result = screen_get_event(m_screenContext, event, -1);
if (result)
- qFatal("QQNX: failed to get event, errno=%d", errno);
+ qFatal("QQNX: failed to get screen event, errno=%d", errno);
// process received event
// get the event type
int qnxType;
result = screen_get_event_property_iv(event, SCREEN_PROPERTY_TYPE, &qnxType);
if (result)
- qFatal("QQNX: failed to query event type, errno=%d", errno);
+ qFatal("QQNX: failed to query screen event type, errno=%d", errno);
if (qnxType == SCREEN_EVENT_USER) {
// treat all user events as shutdown requests
- #if defined(QQNXEVENTTHREAD_DEBUG)
- qDebug() << "QQNX: QNX user event";
+ #if defined(QQNXSCREENEVENTTHREAD_DEBUG)
+ qDebug() << "QQNX: QNX user screen event";
#endif
m_quit = true;
} else {
}
}
-#if defined(QQNXEVENTTHREAD_DEBUG)
- qDebug() << "QQNX: event loop stopped";
+#if defined(QQNXSCREENEVENTTHREAD_DEBUG)
+ qDebug() << "QQNX: screen event thread stopped";
#endif
// cleanup
screen_destroy_event(event);
}
-void QQnxEventThread::shutdown()
+void QQnxScreenEventThread::shutdown()
{
screen_event_t event;
errno = 0;
int result = screen_create_event(&event);
if (result)
- qFatal("QQNX: failed to create event, errno=%d", errno);
+ qFatal("QQNX: failed to create screen event, errno=%d", errno);
// set the event type as user
errno = 0;
int type = SCREEN_EVENT_USER;
result = screen_set_event_property_iv(event, SCREEN_PROPERTY_TYPE, &type);
if (result)
- qFatal("QQNX: failed to set event type, errno=%d", errno);
+ qFatal("QQNX: failed to set screen event type, errno=%d", errno);
// NOTE: ignore SCREEN_PROPERTY_USER_DATA; treat all user events as shutdown events
errno = 0;
result = screen_send_event(m_screenContext, event, getpid());
if (result)
- qFatal("QQNX: failed to set event type, errno=%d", errno);
+ qFatal("QQNX: failed to set screen event type, errno=%d", errno);
// cleanup
screen_destroy_event(event);
-#if defined(QQNXEVENTTHREAD_DEBUG)
- qDebug() << "QQNX: event loop shutdown begin";
+#if defined(QQNXSCREENEVENTTHREAD_DEBUG)
+ qDebug() << "QQNX: screen event thread shutdown begin";
#endif
// block until thread terminates
wait();
-#if defined(QQNXEVENTTHREAD_DEBUG)
- qDebug() << "QQNX: event loop shutdown end";
+#if defined(QQNXSCREENEVENTTHREAD_DEBUG)
+ qDebug() << "QQNX: screen event thread shutdown end";
#endif
}
**
****************************************************************************/
-#ifndef QQNXEVENTTHREAD_H
-#define QQNXEVENTTHREAD_H
+#ifndef QQNXSCREENEVENTTHREAD_H
+#define QQNXSCREENEVENTTHREAD_H
#include <QtCore/QThread>
class QQnxScreenEventHandler;
-class QQnxEventThread : public QThread
+class QQnxScreenEventThread : public QThread
{
public:
- QQnxEventThread(screen_context_t context, QQnxScreenEventHandler *screenEventHandler);
- virtual ~QQnxEventThread();
+ QQnxScreenEventThread(screen_context_t context, QQnxScreenEventHandler *screenEventHandler);
+ ~QQnxScreenEventThread();
static void injectKeyboardEvent(int flags, int sym, int mod, int scan, int cap);
QT_END_NAMESPACE
-#endif // QQNXEVENTTHREAD_H
+#endif // QQNXSCREENEVENTTHREAD_H