summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/qnx
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/platforms/qnx')
-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
-rw-r--r--src/plugins/platforms/qnx/qqnxscreen.cpp2
-rw-r--r--src/plugins/platforms/qnx/qqnxvirtualkeyboard.cpp165
-rw-r--r--src/plugins/platforms/qnx/qqnxvirtualkeyboard.h17
8 files changed, 148 insertions, 163 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
diff --git a/src/plugins/platforms/qnx/qqnxscreen.cpp b/src/plugins/platforms/qnx/qqnxscreen.cpp
index e0e3d6d57d..cd77c3088a 100644
--- a/src/plugins/platforms/qnx/qqnxscreen.cpp
+++ b/src/plugins/platforms/qnx/qqnxscreen.cpp
@@ -207,7 +207,7 @@ void QQnxScreen::setRotation(int rotation)
m_rootWindow->setRotation(rotation);
// Swap dimensions if we've rotated 90 or 270 from initial orientation
- if (isOrthogonal(m_currentRotation, rotation)) {
+ if (isOrthogonal(m_initialRotation, rotation)) {
m_currentGeometry = QRect(0, 0, m_initialGeometry.height(), m_initialGeometry.width());
m_currentPhysicalSize = QSize(m_initialPhysicalSize.height(), m_initialPhysicalSize.width());
} else {
diff --git a/src/plugins/platforms/qnx/qqnxvirtualkeyboard.cpp b/src/plugins/platforms/qnx/qqnxvirtualkeyboard.cpp
index 9d7fe92660..20c89d3e32 100644
--- a/src/plugins/platforms/qnx/qqnxvirtualkeyboard.cpp
+++ b/src/plugins/platforms/qnx/qqnxvirtualkeyboard.cpp
@@ -46,6 +46,8 @@
#include <QtGui/QPlatformWindow>
#include <QtCore/QDebug>
+#include <QtCore/QSocketNotifier>
+#include <QtCore/private/qcore_unix_p.h>
#include <errno.h>
#include <fcntl.h>
@@ -65,17 +67,17 @@ static QQnxVirtualKeyboard *s_instance = 0;
// Huge hack for keyboard shadow (see QNX PR 88400). Should be removed ASAP.
#define KEYBOARD_SHADOW_HEIGHT 8
-QQnxVirtualKeyboard::QQnxVirtualKeyboard() :
- m_encoder(NULL),
- m_decoder(NULL),
- m_buffer(NULL),
- m_height(0),
- m_fd(-1),
- m_keyboardMode(Default),
- m_visible(false),
- m_locale(QLatin1String("en_US"))
+QQnxVirtualKeyboard::QQnxVirtualKeyboard()
+ : m_encoder(0),
+ m_decoder(0),
+ m_buffer(0),
+ m_height(0),
+ m_fd(-1),
+ m_keyboardMode(Default),
+ m_visible(false),
+ m_locale(QLatin1String("en_US")),
+ m_readNotifier(0)
{
- connect();
}
QQnxVirtualKeyboard::~QQnxVirtualKeyboard()
@@ -88,12 +90,24 @@ QQnxVirtualKeyboard& QQnxVirtualKeyboard::instance()
{
if (!s_instance) {
s_instance = new QQnxVirtualKeyboard();
- s_instance->start();
+
+ // 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(s_instance, "start", Qt::QueuedConnection);
}
return *s_instance;
}
+void QQnxVirtualKeyboard::start()
+{
+#ifdef QQNXVIRTUALKEYBOARD_DEBUG
+ qDebug() << "QQNX: starting keyboard event processing";
+#endif
+ if (!connect())
+ return;
+}
+
/* static */
void QQnxVirtualKeyboard::destroy()
{
@@ -105,35 +119,28 @@ void QQnxVirtualKeyboard::destroy()
void QQnxVirtualKeyboard::close()
{
- if (m_fd) {
- // any reads will fail after we close the fd, which is basically what we want.
- ::close(m_fd);
- }
-
- // Wait for the thread to die (should be immediate), then continue the cleanup.
- wait();
+ delete m_readNotifier;
+ m_readNotifier = 0;
- if (m_fd) {
+ if (m_fd != -1) {
+ ::close(m_fd);
m_fd = -1;
}
-
- if (m_decoder)
- {
+ if (m_decoder) {
pps_decoder_cleanup(m_decoder);
delete m_decoder;
- m_decoder = NULL;
+ m_decoder = 0;
}
- if (m_encoder)
- {
+ if (m_encoder) {
pps_encoder_cleanup(m_encoder);
delete m_encoder;
- m_encoder = NULL;
+ m_encoder = 0;
}
delete [] m_buffer;
- m_buffer = NULL;
+ m_buffer = 0;
}
bool QQnxVirtualKeyboard::connect()
@@ -165,7 +172,8 @@ bool QQnxVirtualKeyboard::connect()
if (!queryPPSInfo())
return false;
- start();
+ m_readNotifier = new QSocketNotifier(m_fd, QSocketNotifier::Read);
+ QObject::connect(m_readNotifier, SIGNAL(activated(int)), this, SLOT(ppsDataReady()));
return true;
}
@@ -192,74 +200,63 @@ void QQnxVirtualKeyboard::notifyClientActiveStateChange(bool active)
hideKeyboard();
}
-void QQnxVirtualKeyboard::run()
-{
- ppsDataReady();
-}
-
void QQnxVirtualKeyboard::ppsDataReady()
{
- while (1) {
- ssize_t nread = read(m_fd, m_buffer, ms_bufferSize - 1);
+ ssize_t nread = qt_safe_read(m_fd, m_buffer, ms_bufferSize - 1);
#ifdef QQNXVIRTUALKEYBOARD_DEBUG
- qDebug() << "QQNX: keyboardMessage size: " << nread;
+ qDebug() << "QQNX: keyboardMessage size: " << nread;
#endif
- if (nread < 0)
- break;
+ if (nread < 0){
+ connect(); // reconnect
+ return;
+ }
- // nread is the real space necessary, not the amount read.
- if (static_cast<size_t>(nread) > ms_bufferSize - 1) {
- qCritical("QQnxVirtualKeyboard: Keyboard buffer size too short; need %u.", nread + 1);
- break;
- }
+ // nread is the real space necessary, not the amount read.
+ if (static_cast<size_t>(nread) > ms_bufferSize - 1) {
+ qCritical("QQnxVirtualKeyboard: Keyboard buffer size too short; need %u.", nread + 1);
+ connect(); // reconnect
+ return;
+ }
- m_buffer[nread] = 0;
- pps_decoder_parse_pps_str(m_decoder, m_buffer);
- pps_decoder_push(m_decoder, NULL);
+ m_buffer[nread] = 0;
+ pps_decoder_parse_pps_str(m_decoder, m_buffer);
+ pps_decoder_push(m_decoder, NULL);
#ifdef QQNXVIRTUALKEYBOARD_DEBUG
- pps_decoder_dump_tree(m_decoder, stderr);
+ pps_decoder_dump_tree(m_decoder, stderr);
#endif
- const char *value;
- if (pps_decoder_get_string(m_decoder, "error", &value) == PPS_DECODER_OK) {
- qCritical("QQnxVirtualKeyboard: Keyboard PPS decoder error: %s", value ? value : "[null]");
- continue;
- }
-
- if (pps_decoder_get_string(m_decoder, "msg", &value) == PPS_DECODER_OK) {
- if (strcmp(value, "show") == 0) {
- const bool oldVisible = m_visible;
- m_visible = true;
- handleKeyboardStateChangeMessage(true);
- if (oldVisible != m_visible)
- emit visibilityChanged(m_visible);
- } else if (strcmp(value, "hide") == 0) {
- const bool oldVisible = m_visible;
- m_visible = false;
- handleKeyboardStateChangeMessage(false);
- if (oldVisible != m_visible)
- emit visibilityChanged(m_visible);
- } else if (strcmp(value, "info") == 0)
- handleKeyboardInfoMessage();
- else if (strcmp(value, "connect") == 0) { }
- else
- qCritical("QQnxVirtualKeyboard: Unexpected keyboard PPS msg value: %s", value ? value : "[null]");
- } else if (pps_decoder_get_string(m_decoder, "res", &value) == PPS_DECODER_OK) {
- if (strcmp(value, "info") == 0)
- handleKeyboardInfoMessage();
- else
- qCritical("QQnxVirtualKeyboard: Unexpected keyboard PPS res value: %s", value ? value : "[null]");
- } else
- qCritical("QQnxVirtualKeyboard: Unexpected keyboard PPS message type");
+ const char *value;
+ if (pps_decoder_get_string(m_decoder, "error", &value) == PPS_DECODER_OK) {
+ qCritical("QQnxVirtualKeyboard: Keyboard PPS decoder error: %s", value ? value : "[null]");
+ return;
}
-#ifdef QQNXVIRTUALKEYBOARD_DEBUG
- qDebug() << "QQNX: exiting keyboard thread";
-#endif
-
- if (m_decoder)
- pps_decoder_cleanup(m_decoder);
+ if (pps_decoder_get_string(m_decoder, "msg", &value) == PPS_DECODER_OK) {
+ if (strcmp(value, "show") == 0) {
+ const bool oldVisible = m_visible;
+ m_visible = true;
+ handleKeyboardStateChangeMessage(true);
+ if (oldVisible != m_visible)
+ emit visibilityChanged(m_visible);
+ } else if (strcmp(value, "hide") == 0) {
+ const bool oldVisible = m_visible;
+ m_visible = false;
+ handleKeyboardStateChangeMessage(false);
+ if (oldVisible != m_visible)
+ emit visibilityChanged(m_visible);
+ } else if (strcmp(value, "info") == 0)
+ handleKeyboardInfoMessage();
+ else if (strcmp(value, "connect") == 0) { }
+ else
+ qCritical("QQnxVirtualKeyboard: Unexpected keyboard PPS msg value: %s", value ? value : "[null]");
+ } else if (pps_decoder_get_string(m_decoder, "res", &value) == PPS_DECODER_OK) {
+ if (strcmp(value, "info") == 0)
+ handleKeyboardInfoMessage();
+ else
+ qCritical("QQnxVirtualKeyboard: Unexpected keyboard PPS res value: %s", value ? value : "[null]");
+ } else
+ qCritical("QQnxVirtualKeyboard: Unexpected keyboard PPS message type");
}
void QQnxVirtualKeyboard::handleKeyboardInfoMessage()
diff --git a/src/plugins/platforms/qnx/qqnxvirtualkeyboard.h b/src/plugins/platforms/qnx/qqnxvirtualkeyboard.h
index 21b2e8736c..73a296fb9f 100644
--- a/src/plugins/platforms/qnx/qqnxvirtualkeyboard.h
+++ b/src/plugins/platforms/qnx/qqnxvirtualkeyboard.h
@@ -42,7 +42,7 @@
#ifndef VIRTUALKEYBOARD_H_
#define VIRTUALKEYBOARD_H_
-#include <QtCore/QThread>
+#include <QtCore/QObject>
#include <QtCore/QLocale>
#include <QtGui/QPlatformScreen>
#include <QtGui/QWindowSystemInterface>
@@ -52,10 +52,12 @@
#include <string>
#include <sys/pps.h>
+class QSocketNotifier;
+
QT_BEGIN_NAMESPACE
/* Shamelessly copied from the browser - this should be rewritten once we have a proper PPS wrapper class */
-class QQnxVirtualKeyboard : public QThread
+class QQnxVirtualKeyboard : public QObject
{
Q_OBJECT
public:
@@ -83,10 +85,16 @@ public:
bool isVisible() const { return m_visible; }
QLocale locale() const { return m_locale; }
+public Q_SLOTS:
+ void start();
+
Q_SIGNALS:
void localeChanged(const QLocale &locale);
void visibilityChanged(bool visible);
+private Q_SLOTS:
+ void ppsDataReady();
+
private:
QQnxVirtualKeyboard();
virtual ~QQnxVirtualKeyboard();
@@ -94,7 +102,6 @@ private:
// Will be called internally if needed.
bool connect();
void close();
- void ppsDataReady();
bool queryPPSInfo();
void handleKeyboardInfoMessage();
void handleKeyboardStateChangeMessage(bool visible);
@@ -110,9 +117,6 @@ private:
void addPhoneModeOptions();
void addPinModeOptions();
- // QThread overrides
- virtual void run();
-
pps_encoder_t *m_encoder;
pps_decoder_t *m_decoder;
char *m_buffer;
@@ -121,6 +125,7 @@ private:
KeyboardMode m_keyboardMode;
bool m_visible;
QLocale m_locale;
+ QSocketNotifier *m_readNotifier;
// Path to keyboardManager in PPS.
static const char *ms_PPSPath;