summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/plugins/platforms/qnx/qnx.pro6
-rw-r--r--src/plugins/platforms/qnx/qqnxintegration.cpp18
-rw-r--r--src/plugins/platforms/qnx/qqnxintegration.h4
-rw-r--r--src/plugins/platforms/qnx/qqnxnavigatoreventhandler.cpp (renamed from src/plugins/platforms/qnx/qqnxnavigatorthread.cpp)80
-rw-r--r--src/plugins/platforms/qnx/qqnxnavigatoreventhandler.h (renamed from src/plugins/platforms/qnx/qqnxnavigatorthread.h)19
5 files changed, 55 insertions, 72 deletions
diff --git a/src/plugins/platforms/qnx/qnx.pro b/src/plugins/platforms/qnx/qnx.pro
index 1bd3548b7d..cf82084de0 100644
--- a/src/plugins/platforms/qnx/qnx.pro
+++ b/src/plugins/platforms/qnx/qnx.pro
@@ -16,7 +16,7 @@ QT += opengl opengl-private platformsupport platformsupport-private widgets-priv
#DEFINES += QQNXINPUTCONTEXT_DEBUG
#DEFINES += QQNXINPUTCONTEXT_IMF_EVENT_DEBUG
#DEFINES += QQNXINTEGRATION_DEBUG
-#DEFINES += QQNXNAVIGATORTHREAD_DEBUG
+#DEFINES += QQNXNAVIGATOREVENTHANDLER_DEBUG
#DEFINES += QQNXRASTERBACKINGSTORE_DEBUG
#DEFINES += QQNXROOTWINDOW_DEBUG
#DEFINES += QQNXSCREEN_DEBUG
@@ -29,7 +29,7 @@ SOURCES = main.cpp \
qqnxglcontext.cpp \
qqnxglbackingstore.cpp \
qqnxintegration.cpp \
- qqnxnavigatorthread.cpp \
+ qqnxnavigatoreventhandler.cpp \
qqnxscreen.cpp \
qqnxwindow.cpp \
qqnxrasterbackingstore.cpp \
@@ -41,7 +41,7 @@ HEADERS = qqnxbuffer.h \
qqnxeventthread.h \
qqnxkeytranslator.h \
qqnxintegration.h \
- qqnxnavigatorthread.h \
+ qqnxnavigatoreventhandler.h \
qqnxglcontext.h \
qqnxglbackingstore.h \
qqnxscreen.h \
diff --git a/src/plugins/platforms/qnx/qqnxintegration.cpp b/src/plugins/platforms/qnx/qqnxintegration.cpp
index 2811661269..cb7f14f963 100644
--- a/src/plugins/platforms/qnx/qqnxintegration.cpp
+++ b/src/plugins/platforms/qnx/qqnxintegration.cpp
@@ -43,7 +43,7 @@
#include "qqnxeventthread.h"
#include "qqnxglbackingstore.h"
#include "qqnxglcontext.h"
-#include "qqnxnavigatorthread.h"
+#include "qqnxnavigatoreventhandler.h"
#include "qqnxrasterbackingstore.h"
#include "qqnxscreen.h"
#include "qqnxwindow.h"
@@ -77,7 +77,7 @@ QMutex QQnxIntegration::ms_windowMapperMutex;
QQnxIntegration::QQnxIntegration()
: QPlatformIntegration()
, m_eventThread(0)
- , m_navigatorThread(0)
+ , m_navigatorEventHandler(0)
, m_inputContext(0)
, m_fontDatabase(new QGenericUnixFontDatabase())
, m_paintUsingOpenGL(false)
@@ -109,9 +109,15 @@ QQnxIntegration::QQnxIntegration()
m_eventThread = new QQnxEventThread(m_screenContext, *QQnxScreen::primaryDisplay());
m_eventThread->start();
- // Create/start navigator thread
- m_navigatorThread = new QQnxNavigatorThread(*QQnxScreen::primaryDisplay());
- m_navigatorThread->start();
+ // Create/start navigator event handler
+ // Not on BlackBerry, it has specialised event dispatcher which also handles navigator events
+#ifndef Q_OS_BLACKBERRY
+ m_navigatorEventHandler = new QQnxNavigatorEventHandler(*QQnxScreen::primaryDisplay());
+
+ // 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(m_navigatorEventHandler, "start", Qt::QueuedConnection);
+#endif
// Create/start the keyboard class.
QQnxVirtualKeyboard::instance();
@@ -137,7 +143,7 @@ QQnxIntegration::~QQnxIntegration()
delete m_eventThread;
// Stop/destroy navigator thread
- delete m_navigatorThread;
+ delete m_navigatorEventHandler;
// Destroy all displays
QQnxScreen::destroyDisplays();
diff --git a/src/plugins/platforms/qnx/qqnxintegration.h b/src/plugins/platforms/qnx/qqnxintegration.h
index 51d06bd0e6..892bb6e16f 100644
--- a/src/plugins/platforms/qnx/qqnxintegration.h
+++ b/src/plugins/platforms/qnx/qqnxintegration.h
@@ -52,7 +52,7 @@ QT_BEGIN_NAMESPACE
class QQnxEventThread;
class QQnxInputContext;
-class QQnxNavigatorThread;
+class QQnxNavigatorEventHandler;
class QQnxWindow;
#ifndef QT_NO_CLIPBOARD
@@ -99,7 +99,7 @@ private:
screen_context_t m_screenContext;
QQnxEventThread *m_eventThread;
- QQnxNavigatorThread *m_navigatorThread;
+ QQnxNavigatorEventHandler *m_navigatorEventHandler;
QQnxInputContext *m_inputContext;
QPlatformFontDatabase *m_fontDatabase;
bool m_paintUsingOpenGL;
diff --git a/src/plugins/platforms/qnx/qqnxnavigatorthread.cpp b/src/plugins/platforms/qnx/qqnxnavigatoreventhandler.cpp
index def4cb7eb1..4db86cb5cf 100644
--- a/src/plugins/platforms/qnx/qqnxnavigatorthread.cpp
+++ b/src/plugins/platforms/qnx/qqnxnavigatoreventhandler.cpp
@@ -39,7 +39,7 @@
**
****************************************************************************/
-#include "qqnxnavigatorthread.h"
+#include "qqnxnavigatoreventhandler.h"
#include "qqnxscreen.h"
#include <QtGui/QGuiApplication>
@@ -61,25 +61,30 @@
static const char *navigatorControlPath = "/pps/services/navigator/control";
static const int ppsBufferSize = 4096;
-QQnxNavigatorThread::QQnxNavigatorThread(QQnxScreen& primaryScreen)
+QQnxNavigatorEventHandler::QQnxNavigatorEventHandler(QQnxScreen& primaryScreen)
: m_primaryScreen(primaryScreen),
m_fd(-1),
m_readNotifier(0)
{
}
-QQnxNavigatorThread::~QQnxNavigatorThread()
+QQnxNavigatorEventHandler::~QQnxNavigatorEventHandler()
{
- // block until thread terminates
- shutdown();
-
delete m_readNotifier;
+
+ // close connection to navigator
+ if (m_fd != -1)
+ close(m_fd);
+
+#if defined(QQNXNAVIGATOREVENTHANDLER_DEBUG)
+ qDebug() << "QQNX: navigator event handler stopped";
+#endif
}
-void QQnxNavigatorThread::run()
+void QQnxNavigatorEventHandler::start()
{
-#if defined(QQNXNAVIGATORTHREAD_DEBUG)
- qDebug() << "QQNX: navigator thread started";
+#if defined(QQNXNAVIGATOREVENTHANDLER_DEBUG)
+ qDebug() << "QQNX: navigator event handler started";
#endif
// open connection to navigator
@@ -91,39 +96,12 @@ void QQnxNavigatorThread::run()
}
m_readNotifier = new QSocketNotifier(m_fd, QSocketNotifier::Read);
- // using direct connection to get the slot called in this thread's context
- connect(m_readNotifier, SIGNAL(activated(int)), this, SLOT(readData()), Qt::DirectConnection);
-
- exec();
-
- // close connection to navigator
- close(m_fd);
-
-#if defined(QQNXNAVIGATORTHREAD_DEBUG)
- qDebug() << "QQNX: navigator thread stopped";
-#endif
-}
-
-void QQnxNavigatorThread::shutdown()
-{
-#if defined(QQNXNAVIGATORTHREAD_DEBUG)
- qDebug() << "QQNX: navigator thread shutdown begin";
-#endif
-
- // signal thread to terminate
- quit();
-
- // block until thread terminates
- wait();
-
-#if defined(QQNXNAVIGATORTHREAD_DEBUG)
- qDebug() << "QQNX: navigator thread shutdown end";
-#endif
+ connect(m_readNotifier, SIGNAL(activated(int)), this, SLOT(readData()));
}
-void QQnxNavigatorThread::parsePPS(const QByteArray &ppsData, QByteArray &msg, QByteArray &dat, QByteArray &id)
+void QQnxNavigatorEventHandler::parsePPS(const QByteArray &ppsData, QByteArray &msg, QByteArray &dat, QByteArray &id)
{
-#if defined(QQNXNAVIGATORTHREAD_DEBUG)
+#if defined(QQNXNAVIGATOREVENTHANDLER_DEBUG)
qDebug() << "PPS: data=" << ppsData;
#endif
@@ -141,7 +119,7 @@ void QQnxNavigatorThread::parsePPS(const QByteArray &ppsData, QByteArray &msg, Q
// tokenize current attribute
const QByteArray &attr = lines.at(i);
-#if defined(QQNXNAVIGATORTHREAD_DEBUG)
+#if defined(QQNXNAVIGATOREVENTHANDLER_DEBUG)
qDebug() << "PPS: attr=" << attr;
#endif
@@ -160,7 +138,7 @@ void QQnxNavigatorThread::parsePPS(const QByteArray &ppsData, QByteArray &msg, Q
QByteArray key = attr.left(firstColon);
QByteArray value = attr.mid(secondColon + 1);
-#if defined(QQNXNAVIGATORTHREAD_DEBUG)
+#if defined(QQNXNAVIGATOREVENTHANDLER_DEBUG)
qDebug() << "PPS: key=" << key;
qDebug() << "PPS: val=" << value;
#endif
@@ -178,7 +156,7 @@ void QQnxNavigatorThread::parsePPS(const QByteArray &ppsData, QByteArray &msg, Q
}
}
-void QQnxNavigatorThread::replyPPS(const QByteArray &res, const QByteArray &id, const QByteArray &dat)
+void QQnxNavigatorEventHandler::replyPPS(const QByteArray &res, const QByteArray &id, const QByteArray &dat)
{
// construct pps message
QByteArray ppsData = "res::";
@@ -191,7 +169,7 @@ void QQnxNavigatorThread::replyPPS(const QByteArray &res, const QByteArray &id,
}
ppsData += "\n";
-#if defined(QQNXNAVIGATORTHREAD_DEBUG)
+#if defined(QQNXNAVIGATOREVENTHANDLER_DEBUG)
qDebug() << "PPS reply=" << ppsData;
#endif
@@ -203,9 +181,9 @@ void QQnxNavigatorThread::replyPPS(const QByteArray &res, const QByteArray &id,
}
}
-void QQnxNavigatorThread::handleMessage(const QByteArray &msg, const QByteArray &dat, const QByteArray &id)
+void QQnxNavigatorEventHandler::handleMessage(const QByteArray &msg, const QByteArray &dat, const QByteArray &id)
{
-#if defined(QQNXNAVIGATORTHREAD_DEBUG)
+#if defined(QQNXNAVIGATOREVENTHANDLER_DEBUG)
qDebug() << "PPS: msg=" << msg << ", dat=" << dat << ", id=" << id;
#endif
@@ -213,7 +191,7 @@ void QQnxNavigatorThread::handleMessage(const QByteArray &msg, const QByteArray
if (msg == "orientationCheck") {
// reply to navigator that (any) orientation is acceptable
-#if defined(QQNXNAVIGATORTHREAD_DEBUG)
+#if defined(QQNXNAVIGATOREVENTHANDLER_DEBUG)
qDebug() << "PPS: orientation check, o=" << dat;
#endif
replyPPS(msg, id, "true");
@@ -221,7 +199,7 @@ void QQnxNavigatorThread::handleMessage(const QByteArray &msg, const QByteArray
} else if (msg == "orientation") {
// update screen geometry and reply to navigator that we're ready
-#if defined(QQNXNAVIGATORTHREAD_DEBUG)
+#if defined(QQNXNAVIGATOREVENTHANDLER_DEBUG)
qDebug() << "PPS: orientation, o=" << dat;
#endif
m_primaryScreen.setRotation( dat.toInt() );
@@ -231,7 +209,7 @@ void QQnxNavigatorThread::handleMessage(const QByteArray &msg, const QByteArray
} else if (msg == "SWIPE_DOWN") {
// simulate menu key press
-#if defined(QQNXNAVIGATORTHREAD_DEBUG)
+#if defined(QQNXNAVIGATOREVENTHANDLER_DEBUG)
qDebug() << "PPS: menu";
#endif
QWindow *w = QGuiApplication::focusWindow();
@@ -241,16 +219,16 @@ void QQnxNavigatorThread::handleMessage(const QByteArray &msg, const QByteArray
} else if (msg == "exit") {
// shutdown everything
-#if defined(QQNXNAVIGATORTHREAD_DEBUG)
+#if defined(QQNXNAVIGATOREVENTHANDLER_DEBUG)
qDebug() << "PPS: exit";
#endif
QCoreApplication::quit();
}
}
-void QQnxNavigatorThread::readData()
+void QQnxNavigatorEventHandler::readData()
{
-#if defined(QQNXNAVIGATORTHREAD_DEBUG)
+#if defined(QQNXNAVIGATOREVENTHANDLER_DEBUG)
qDebug() << "QQNX: reading navigator data";
#endif
// allocate buffer for pps data
diff --git a/src/plugins/platforms/qnx/qqnxnavigatorthread.h b/src/plugins/platforms/qnx/qqnxnavigatoreventhandler.h
index 40b217db73..2e0bd1fa14 100644
--- a/src/plugins/platforms/qnx/qqnxnavigatorthread.h
+++ b/src/plugins/platforms/qnx/qqnxnavigatoreventhandler.h
@@ -39,31 +39,30 @@
**
****************************************************************************/
-#ifndef QQNXNAVIGATORTHREAD_H
-#define QQNXNAVIGATORTHREAD_H
+#ifndef QQNXNAVIGATOREVENTHANDLER_H
+#define QQNXNAVIGATOREVENTHANDLER_H
-#include <QThread>
+#include <QObject>
QT_BEGIN_NAMESPACE
class QQnxScreen;
class QSocketNotifier;
-class QQnxNavigatorThread : public QThread
+class QQnxNavigatorEventHandler : public QObject
{
Q_OBJECT
public:
- QQnxNavigatorThread(QQnxScreen &primaryScreen);
- virtual ~QQnxNavigatorThread();
+ QQnxNavigatorEventHandler(QQnxScreen &primaryScreen);
+ virtual ~QQnxNavigatorEventHandler();
-protected:
- virtual void run();
+public Q_SLOTS:
+ void start();
private Q_SLOTS:
void readData();
private:
- void shutdown();
void parsePPS(const QByteArray &ppsData, QByteArray &msg, QByteArray &dat, QByteArray &id);
void replyPPS(const QByteArray &res, const QByteArray &id, const QByteArray &dat);
void handleMessage(const QByteArray &msg, const QByteArray &dat, const QByteArray &id);
@@ -75,4 +74,4 @@ private:
QT_END_NAMESPACE
-#endif // QQNXNAVIGATORTHREAD_H
+#endif // QQNXNAVIGATOREVENTHANDLER_H