summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/plugins/platforms/directfb/qdirectfbinput.cpp97
-rw-r--r--src/plugins/platforms/directfb/qdirectfbinput.h42
-rw-r--r--src/plugins/platforms/directfb/qdirectfbintegration.cpp24
-rw-r--r--src/plugins/platforms/directfb/qdirectfbintegration.h6
-rw-r--r--src/plugins/platforms/directfb/qdirectfbwindow.cpp8
-rw-r--r--src/plugins/platforms/directfb/qdirectfbwindow.h5
6 files changed, 74 insertions, 108 deletions
diff --git a/src/plugins/platforms/directfb/qdirectfbinput.cpp b/src/plugins/platforms/directfb/qdirectfbinput.cpp
index 90c3348..7101b7b 100644
--- a/src/plugins/platforms/directfb/qdirectfbinput.cpp
+++ b/src/plugins/platforms/directfb/qdirectfbinput.cpp
@@ -10,89 +10,61 @@
#include <directfb.h>
-InputSocketWaiter::InputSocketWaiter(IDirectFBEventBuffer *eventBuffer, QObject *parent)
- : QThread(parent), m_eventBuffer(eventBuffer),m_shouldStop(false)
+QDirectFbInput::QDirectFbInput(QObject *parent)
+ : QObject(parent), m_shouldStop(false)
{
- this->start();
-}
+ m_dfbInterface = QDirectFbConvenience::dfbInterface();
-InputSocketWaiter::~InputSocketWaiter()
-{
- m_shouldStop = true;
- m_eventBuffer->WakeUp(m_eventBuffer);
- m_cleanupMutex.lock();
-}
+ DFBResult ok = m_dfbInterface->CreateEventBuffer(m_dfbInterface,&m_eventBuffer);
+ if (ok != DFB_OK)
+ DirectFBError("Failed to initialise eventbuffer", ok);
+
+ m_dfbInterface->GetDisplayLayer(m_dfbInterface,DLID_PRIMARY, &m_dfbDisplayLayer);
-void InputSocketWaiter::continueWaitingForEvents()
-{
- m_finishedProcessingEvents.wakeAll();
}
-void InputSocketWaiter::run()
+void QDirectFbInput::runInputEventLoop()
{
- m_cleanupMutex.lock();
- while (1) {
+ while (true) {
m_eventBuffer->WaitForEvent(m_eventBuffer);
- if (m_shouldStop)
+ if (m_shouldStop) {
+ m_waitStop.release();
break;
- emit newEvent();
- QMutex waitForProcessingMutex;
- waitForProcessingMutex.lock();
- m_finishedProcessingEvents.wait(&waitForProcessingMutex);
- }
- m_cleanupMutex.unlock();
-}
-
-QDirectFbInput *QDirectFbInput::instance()
-{
- static QDirectFbInput *input = 0;
- if (!input) {
- input = new QDirectFbInput();
+ }
+ handleEvents();
}
- return input;
}
-QDirectFbInput::QDirectFbInput()
- : QObject()
+void QDirectFbInput::stopInputEventLoop()
{
- dfbInterface = QDirectFbConvenience::dfbInterface();
-
- DFBResult ok = dfbInterface->CreateEventBuffer(dfbInterface,&eventBuffer);
- if (ok != DFB_OK)
- DirectFBError("Failed to initialise eventbuffer", ok);
-
- dfbInterface->GetDisplayLayer(dfbInterface,DLID_PRIMARY, &dfbDisplayLayer);
-
- m_inputHandler = new InputSocketWaiter(eventBuffer,this);
- connect(m_inputHandler,SIGNAL(newEvent()),this,SLOT(handleEvents()));
-
- connect(QApplication::instance(),SIGNAL(aboutToQuit()),SLOT(applicationEnd()));
+ m_shouldStop = true;
+ m_waitStop.acquire();
}
void QDirectFbInput::addWindow(DFBWindowID id, QWidget *tlw)
{
- tlwMap.insert(id,tlw);
+ m_tlwMap.insert(id,tlw);
IDirectFBWindow *window;
- dfbDisplayLayer->GetWindow(dfbDisplayLayer,id,&window);
+ m_dfbDisplayLayer->GetWindow(m_dfbDisplayLayer,id,&window);
- window->AttachEventBuffer(window,eventBuffer);
+ window->AttachEventBuffer(window,m_eventBuffer);
}
void QDirectFbInput::removeWindow(WId wId)
{
IDirectFBWindow *window;
- dfbDisplayLayer->GetWindow(dfbDisplayLayer,wId, &window);
+ m_dfbDisplayLayer->GetWindow(m_dfbDisplayLayer,wId, &window);
- window->DetachEventBuffer(window,eventBuffer);
- tlwMap.remove(wId);
+ window->DetachEventBuffer(window,m_eventBuffer);
+ m_tlwMap.remove(wId);
}
void QDirectFbInput::handleEvents()
{
- DFBResult hasEvent = eventBuffer->HasEvent(eventBuffer);
+ DFBResult hasEvent = m_eventBuffer->HasEvent(m_eventBuffer);
while(hasEvent == DFB_OK){
DFBEvent event;
- DFBResult ok = eventBuffer->GetEvent(eventBuffer,&event);
+ DFBResult ok = m_eventBuffer->GetEvent(m_eventBuffer,&event);
if (ok != DFB_OK)
DirectFBError("Failed to get event",ok);
if (event.clazz == DFEC_WINDOW) {
@@ -118,9 +90,8 @@ void QDirectFbInput::handleEvents()
}
- hasEvent = eventBuffer->HasEvent(eventBuffer);
+ hasEvent = m_eventBuffer->HasEvent(m_eventBuffer);
}
- m_inputHandler->continueWaitingForEvents();
}
void QDirectFbInput::handleMouseEvents(const DFBEvent &event)
@@ -140,22 +111,16 @@ void QDirectFbInput::handleMouseEvents(const DFBEvent &event)
} else if (event.window.type == DWET_BUTTONUP) {
window->UngrabPointer(window);
}
- QWidget *tlw = tlwMap.value(event.window.window_id);
+ QWidget *tlw = m_tlwMap.value(event.window.window_id);
QWindowSystemInterface::handleMouseEvent(tlw, timestamp, p, globalPos, buttons);
}
-void QDirectFbInput::applicationEnd()
-{
- delete m_inputHandler;
- m_inputHandler = 0;
-}
-
void QDirectFbInput::handleWheelEvent(const DFBEvent &event)
{
QPoint p(event.window.cx, event.window.cy);
QPoint globalPos = globalPoint(event);
long timestamp = (event.window.timestamp.tv_sec*1000) + (event.window.timestamp.tv_usec/1000);
- QWidget *tlw = tlwMap.value(event.window.window_id);
+ QWidget *tlw = m_tlwMap.value(event.window.window_id);
QWindowSystemInterface::handleWheelEvent(tlw, timestamp, p, globalPos,
event.window.step*120,
Qt::Vertical);
@@ -172,13 +137,13 @@ void QDirectFbInput::handleKeyEvents(const DFBEvent &event)
QChar character;
if (DFB_KEY_TYPE(event.window.key_symbol) == DIKT_UNICODE)
character = QChar(event.window.key_symbol);
- QWidget *tlw = tlwMap.value(event.window.window_id);
+ QWidget *tlw = m_tlwMap.value(event.window.window_id);
QWindowSystemInterface::handleKeyEvent(tlw, timestamp, type, key, modifiers, character);
}
void QDirectFbInput::handleEnterLeaveEvents(const DFBEvent &event)
{
- QWidget *tlw = tlwMap.value(event.window.window_id);
+ QWidget *tlw = m_tlwMap.value(event.window.window_id);
switch (event.window.type) {
case DWET_ENTER:
QWindowSystemInterface::handleEnterEvent(tlw);
@@ -194,7 +159,7 @@ void QDirectFbInput::handleEnterLeaveEvents(const DFBEvent &event)
inline QPoint QDirectFbInput::globalPoint(const DFBEvent &event) const
{
IDirectFBWindow *window;
- dfbDisplayLayer->GetWindow(dfbDisplayLayer,event.window.window_id,&window);
+ m_dfbDisplayLayer->GetWindow(m_dfbDisplayLayer,event.window.window_id,&window);
int x,y;
window->GetPosition(window,&x,&y);
return QPoint(event.window.cx +x, event.window.cy + y);
diff --git a/src/plugins/platforms/directfb/qdirectfbinput.h b/src/plugins/platforms/directfb/qdirectfbinput.h
index 016e7f1..0b2e7ed 100644
--- a/src/plugins/platforms/directfb/qdirectfbinput.h
+++ b/src/plugins/platforms/directfb/qdirectfbinput.h
@@ -1,9 +1,7 @@
#ifndef QDIRECTFBINPUT_H
#define QDIRECTFBINPUT_H
-#include <QThread>
-#include <QMutex>
-#include <QWaitCondition>
+#include <QSemaphore>
#include <QObject>
#include <QHash>
#include <QPoint>
@@ -13,53 +11,35 @@
#include <directfb.h>
-class InputSocketWaiter : public QThread
-{
- Q_OBJECT
-public:
- InputSocketWaiter(IDirectFBEventBuffer *eventBuffer, QObject *parent);
- virtual ~InputSocketWaiter();
- void continueWaitingForEvents();
-protected:
- void run();
-signals:
- void newEvent();
-private:
- IDirectFBEventBuffer *m_eventBuffer;
- bool m_shouldStop;
- QMutex m_cleanupMutex;
- QWaitCondition m_finishedProcessingEvents;
-};
-
class QDirectFbInput : public QObject
{
Q_OBJECT
public:
- static QDirectFbInput *instance();
+ QDirectFbInput(QObject *parent);
void addWindow(DFBWindowID id, QWidget *tlw);
void removeWindow(WId wId);
public slots:
+ void runInputEventLoop();
+ void stopInputEventLoop();
void handleEvents();
- void applicationEnd();
private:
- QDirectFbInput();
-
void handleMouseEvents(const DFBEvent &event);
void handleWheelEvent(const DFBEvent &event);
void handleKeyEvents(const DFBEvent &event);
void handleEnterLeaveEvents(const DFBEvent &event);
- IDirectFB *dfbInterface;
- IDirectFBDisplayLayer *dfbDisplayLayer;
- IDirectFBEventBuffer *eventBuffer;
+ inline QPoint globalPoint(const DFBEvent &event) const;
- QHash<DFBWindowID,QWidget *>tlwMap;
- inline QPoint globalPoint(const DFBEvent &event) const;
+ IDirectFB *m_dfbInterface;
+ IDirectFBDisplayLayer *m_dfbDisplayLayer;
+ IDirectFBEventBuffer *m_eventBuffer;
- InputSocketWaiter *m_inputHandler;
+ bool m_shouldStop;
+ QSemaphore m_waitStop;
+ QHash<DFBWindowID,QWidget *>m_tlwMap;
};
#endif // QDIRECTFBINPUT_H
diff --git a/src/plugins/platforms/directfb/qdirectfbintegration.cpp b/src/plugins/platforms/directfb/qdirectfbintegration.cpp
index 60fce7e..c47fc8d 100644
--- a/src/plugins/platforms/directfb/qdirectfbintegration.cpp
+++ b/src/plugins/platforms/directfb/qdirectfbintegration.cpp
@@ -49,9 +49,10 @@
#include <private/qwindowsurface_raster_p.h>
#include <private/qpixmap_raster_p.h>
-#include <private/qpixmap_blitter_p.h>
-#include <private/qpixmapdata_p.h>
-#include <QCoreApplication>
+#include <QtGui/private/qpixmap_blitter_p.h>
+#include <QtGui/private/qpixmapdata_p.h>
+#include <QtCore/QCoreApplication>
+#include <QtCore/QThread>
QT_BEGIN_NAMESPACE
@@ -94,8 +95,22 @@ QDirectFbIntegration::QDirectFbIntegration()
}
delete[] argv;
+
QDirectFbScreen *primaryScreen = new QDirectFbScreen(0);
mScreens.append(primaryScreen);
+
+ mInputRunner = new QThread;
+ mInput = new QDirectFbInput(0);
+ mInput->moveToThread(mInputRunner);
+ QObject::connect(mInputRunner,SIGNAL(started()),mInput,SLOT(runInputEventLoop()));
+ mInputRunner->start();
+}
+
+QDirectFbIntegration::~QDirectFbIntegration()
+{
+ mInput->stopInputEventLoop();
+ delete mInputRunner;
+ delete mInput;
}
QPixmapData *QDirectFbIntegration::createPixmapData(QPixmapData::PixelType type) const
@@ -109,7 +124,8 @@ QPixmapData *QDirectFbIntegration::createPixmapData(QPixmapData::PixelType type)
QPlatformWindow *QDirectFbIntegration::createPlatformWindow(QWidget *widget, WId winId) const
{
Q_UNUSED(winId);
- return new QDirectFbWindow(widget);
+ QDirectFbInput *input = const_cast<QDirectFbInput *>(mInput);//gah
+ return new QDirectFbWindow(widget,input);
}
QWindowSurface *QDirectFbIntegration::createWindowSurface(QWidget *widget, WId winId) const
diff --git a/src/plugins/platforms/directfb/qdirectfbintegration.h b/src/plugins/platforms/directfb/qdirectfbintegration.h
index c0e770f..27847e2 100644
--- a/src/plugins/platforms/directfb/qdirectfbintegration.h
+++ b/src/plugins/platforms/directfb/qdirectfbintegration.h
@@ -50,6 +50,7 @@
QT_BEGIN_NAMESPACE
+class QThread;
class QDirectFBCursor;
class QDirectFbScreen : public QPlatformScreen
@@ -81,6 +82,7 @@ class QDirectFbIntegration : public QPlatformIntegration
{
public:
QDirectFbIntegration();
+ ~QDirectFbIntegration();
QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId = 0) const;
@@ -89,10 +91,10 @@ public:
QList<QPlatformScreen *> screens() const { return mScreens; }
-
-
private:
QList<QPlatformScreen *> mScreens;
+ QDirectFbInput *mInput;
+ QThread *mInputRunner;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/directfb/qdirectfbwindow.cpp b/src/plugins/platforms/directfb/qdirectfbwindow.cpp
index d88953e..30e6f5a 100644
--- a/src/plugins/platforms/directfb/qdirectfbwindow.cpp
+++ b/src/plugins/platforms/directfb/qdirectfbwindow.cpp
@@ -45,8 +45,8 @@
#include <directfb.h>
-QDirectFbWindow::QDirectFbWindow(QWidget *tlw)
- : QPlatformWindow(tlw)
+QDirectFbWindow::QDirectFbWindow(QWidget *tlw, QDirectFbInput *inputhandler)
+ : QPlatformWindow(tlw), m_inputHandler(inputhandler)
{
IDirectFBDisplayLayer *layer = QDirectFbConvenience::dfbDisplayLayer();
DFBDisplayLayerConfig layerConfig;
@@ -83,12 +83,12 @@ QDirectFbWindow::QDirectFbWindow(QWidget *tlw)
DFBWindowID id;
m_dfbWindow->GetID(m_dfbWindow, &id);
- QDirectFbInput::instance()->addWindow(id,tlw);
+ m_inputHandler->addWindow(id,tlw);
}
QDirectFbWindow::~QDirectFbWindow()
{
- QDirectFbInput::instance()->removeWindow(winId());
+ m_inputHandler->removeWindow(winId());
m_dfbWindow->Destroy(m_dfbWindow);
}
diff --git a/src/plugins/platforms/directfb/qdirectfbwindow.h b/src/plugins/platforms/directfb/qdirectfbwindow.h
index d5fd408..b512afd 100644
--- a/src/plugins/platforms/directfb/qdirectfbwindow.h
+++ b/src/plugins/platforms/directfb/qdirectfbwindow.h
@@ -45,13 +45,14 @@
#include <QPlatformWindow>
#include "qdirectfbconvenience.h"
+#include "qdirectfbinput.h"
QT_BEGIN_NAMESPACE
class QDirectFbWindow : public QPlatformWindow
{
public:
- QDirectFbWindow(QWidget *tlw);
+ QDirectFbWindow(QWidget *tlw, QDirectFbInput *inputhandler);
~QDirectFbWindow();
void setGeometry(const QRect &rect);
@@ -66,6 +67,8 @@ public:
private:
IDirectFBWindow *m_dfbWindow;
+ QDirectFbInput *m_inputHandler;
+
};
QT_END_NAMESPACE