diff options
author | Jørgen Lind <jorgen.lind@nokia.com> | 2010-01-08 14:05:49 (GMT) |
---|---|---|
committer | Jørgen Lind <jorgen.lind@nokia.com> | 2010-01-08 14:05:49 (GMT) |
commit | a98fd80bf018e21fb1d0216bccf39de57da4950c (patch) | |
tree | 40cfa4858340ef4f3c7ef2553fd93dba91554d71 | |
parent | 9096336c767670b4f68d507a5116da433ecb40b0 (diff) | |
download | Qt-a98fd80bf018e21fb1d0216bccf39de57da4950c.zip Qt-a98fd80bf018e21fb1d0216bccf39de57da4950c.tar.gz Qt-a98fd80bf018e21fb1d0216bccf39de57da4950c.tar.bz2 |
Make minimaldfb input more efficient
Reviewed-by: Andy Nichols
-rw-r--r-- | src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp | 15 | ||||
-rw-r--r-- | src/plugins/graphicssystems/minimaldfb/qdirectfbinput.h | 5 |
2 files changed, 15 insertions, 5 deletions
diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp index e704aa7..1926367 100644 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.cpp @@ -12,7 +12,6 @@ InputSocketWaiter::InputSocketWaiter(IDirectFBEventBuffer *eventBuffer, QObject *parent) : QThread(parent), m_eventBuffer(eventBuffer),m_shouldStop(false) { - connect(qApp,SIGNAL(aboutToQuit()),SLOT(stop())); this->start(); } @@ -20,19 +19,26 @@ InputSocketWaiter::~InputSocketWaiter() { m_shouldStop = true; m_eventBuffer->WakeUp(m_eventBuffer); - m_mutex.lock(); + m_cleanupMutex.lock(); +} + +void InputSocketWaiter::continueWaitingForEvents() +{ + m_finishedProcessingEvents.wakeAll(); } void InputSocketWaiter::run() { - m_mutex.lock(); + m_cleanupMutex.lock(); while (1) { m_eventBuffer->WaitForEvent(m_eventBuffer); if (m_shouldStop) break; emit newEvent(); + QMutex waitForProcessingMutex; + m_finishedProcessingEvents.wait(&waitForProcessingMutex); } - m_mutex.unlock(); + m_cleanupMutex.unlock(); } QDirectFbInput::QDirectFbInput(QObject *parent) @@ -94,6 +100,7 @@ void QDirectFbInput::handleEvents() hasEvent = eventBuffer->HasEvent(eventBuffer); } + m_inputHandler->continueWaitingForEvents(); } void QDirectFbInput::handleMouseEvents(const DFBEvent &event) diff --git a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.h b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.h index 8f90019..74ccee2 100644 --- a/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.h +++ b/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.h @@ -3,6 +3,7 @@ #include <QThread> #include <QMutex> +#include <QWaitCondition> #include <QObject> #include <QHash> #include <QPoint> @@ -16,6 +17,7 @@ class InputSocketWaiter : public QThread public: InputSocketWaiter(IDirectFBEventBuffer *eventBuffer, QObject *parent); virtual ~InputSocketWaiter(); + void continueWaitingForEvents(); protected: void run(); signals: @@ -23,7 +25,8 @@ signals: private: IDirectFBEventBuffer *m_eventBuffer; bool m_shouldStop; - QMutex m_mutex; + QMutex m_cleanupMutex; + QWaitCondition m_finishedProcessingEvents; }; class QDirectFbInput : public QObject |