summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/directfb/qdirectfbinput.cpp
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2011-12-13 11:02:33 (GMT)
committerJørgen Lind <jorgen.lind@nokia.com>2011-12-13 11:02:33 (GMT)
commitc614e71cdd4047bb49ccde2f94c9d622f5071fc3 (patch)
tree8e97a2917bc3002722d0cd9b995ceb4a652c4615 /src/plugins/platforms/directfb/qdirectfbinput.cpp
parentee387dcb715ebc21f63b524bb87a8ffaf198f8aa (diff)
downloadQt-c614e71cdd4047bb49ccde2f94c9d622f5071fc3.zip
Qt-c614e71cdd4047bb49ccde2f94c9d622f5071fc3.tar.gz
Qt-c614e71cdd4047bb49ccde2f94c9d622f5071fc3.tar.bz2
directfb: Backport the work from QtBase to Qt 4.8
This is copying the files (minus the API changes) to Qt 4.8. It fixes memory leaks, adds DirectFB based image decoding, prepares EGL integration/ Merge-request: 1492 Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>
Diffstat (limited to 'src/plugins/platforms/directfb/qdirectfbinput.cpp')
-rw-r--r--src/plugins/platforms/directfb/qdirectfbinput.cpp86
1 files changed, 44 insertions, 42 deletions
diff --git a/src/plugins/platforms/directfb/qdirectfbinput.cpp b/src/plugins/platforms/directfb/qdirectfbinput.cpp
index d35cea5..34dbc9d 100644
--- a/src/plugins/platforms/directfb/qdirectfbinput.cpp
+++ b/src/plugins/platforms/directfb/qdirectfbinput.cpp
@@ -47,65 +47,71 @@
#include <QWindowSystemInterface>
#include <QMouseEvent>
#include <QEvent>
-#include <QApplication>
#include <directfb.h>
-QDirectFbInput::QDirectFbInput(QObject *parent)
- : QObject(parent), m_shouldStop(false)
-{
- m_dfbInterface = QDirectFbConvenience::dfbInterface();
+QT_BEGIN_NAMESPACE
- DFBResult ok = m_dfbInterface->CreateEventBuffer(m_dfbInterface,&m_eventBuffer);
+QDirectFbInput::QDirectFbInput(IDirectFB *dfb, IDirectFBDisplayLayer *dfbLayer)
+ : m_dfbInterface(dfb)
+ , m_dfbDisplayLayer(dfbLayer)
+ , m_shouldStop(false)
+{
+ DFBResult ok = m_dfbInterface->CreateEventBuffer(m_dfbInterface, m_eventBuffer.outPtr());
if (ok != DFB_OK)
DirectFBError("Failed to initialise eventbuffer", ok);
-
- m_dfbInterface->GetDisplayLayer(m_dfbInterface,DLID_PRIMARY, &m_dfbDisplayLayer);
-
}
-void QDirectFbInput::runInputEventLoop()
+void QDirectFbInput::run()
{
- while (true) {
- m_eventBuffer->WaitForEvent(m_eventBuffer);
- if (m_shouldStop) {
- m_waitStop.release();
- break;
- }
- handleEvents();
+ while (!m_shouldStop) {
+ if (m_eventBuffer->WaitForEvent(m_eventBuffer.data()) == DFB_OK)
+ handleEvents();
}
}
void QDirectFbInput::stopInputEventLoop()
{
m_shouldStop = true;
- m_waitStop.acquire();
+ m_eventBuffer->WakeUp(m_eventBuffer.data());
}
-void QDirectFbInput::addWindow(DFBWindowID id, QWidget *tlw)
+void QDirectFbInput::addWindow(IDirectFBWindow *window, QWidget *platformWindow)
{
- m_tlwMap.insert(id,tlw);
- IDirectFBWindow *window;
- m_dfbDisplayLayer->GetWindow(m_dfbDisplayLayer,id,&window);
+ DFBResult res;
+ DFBWindowID id;
- window->AttachEventBuffer(window,m_eventBuffer);
+ res = window->GetID(window, &id);
+ if (res != DFB_OK) {
+ DirectFBError("QDirectFbInput::addWindow", res);
+ return;
+ }
+
+ m_tlwMap.insert(id, platformWindow);
+ window->AttachEventBuffer(window, m_eventBuffer.data());
}
-void QDirectFbInput::removeWindow(WId wId)
+void QDirectFbInput::removeWindow(IDirectFBWindow *window)
{
- IDirectFBWindow *window;
- m_dfbDisplayLayer->GetWindow(m_dfbDisplayLayer,wId, &window);
+ DFBResult res;
+ DFBWindowID id;
- window->DetachEventBuffer(window,m_eventBuffer);
- m_tlwMap.remove(wId);
+ res = window->GetID(window, &id);
+ if (res != DFB_OK) {
+ DirectFBError("QDirectFbInput::removeWindow", res);
+ return;
+ }
+
+ window->DetachEventBuffer(window, m_eventBuffer.data());
+ m_tlwMap.remove(id);
}
void QDirectFbInput::handleEvents()
{
- DFBResult hasEvent = m_eventBuffer->HasEvent(m_eventBuffer);
+ DFBResult hasEvent = m_eventBuffer->HasEvent(m_eventBuffer.data());
while(hasEvent == DFB_OK){
DFBEvent event;
- DFBResult ok = m_eventBuffer->GetEvent(m_eventBuffer,&event);
+ DFBResult ok = m_eventBuffer->GetEvent(m_eventBuffer.data(), &event);
if (ok != DFB_OK)
DirectFBError("Failed to get event",ok);
if (event.clazz == DFEC_WINDOW) {
@@ -131,7 +137,7 @@ void QDirectFbInput::handleEvents()
}
- hasEvent = m_eventBuffer->HasEvent(m_eventBuffer);
+ hasEvent = m_eventBuffer->HasEvent(m_eventBuffer.data());
}
}
@@ -141,17 +147,12 @@ void QDirectFbInput::handleMouseEvents(const DFBEvent &event)
QPoint globalPos = globalPoint(event);
Qt::MouseButtons buttons = QDirectFbConvenience::mouseButtons(event.window.buttons);
- IDirectFBDisplayLayer *layer = QDirectFbConvenience::dfbDisplayLayer();
- IDirectFBWindow *window;
- layer->GetWindow(layer,event.window.window_id,&window);
+ QDirectFBPointer<IDirectFBDisplayLayer> layer(QDirectFbConvenience::dfbDisplayLayer());
+ QDirectFBPointer<IDirectFBWindow> window;
+ layer->GetWindow(layer.data(), event.window.window_id, window.outPtr());
long timestamp = (event.window.timestamp.tv_sec*1000) + (event.window.timestamp.tv_usec/1000);
- if (event.window.type == DWET_BUTTONDOWN) {
- window->GrabPointer(window);
- } else if (event.window.type == DWET_BUTTONUP) {
- window->UngrabPointer(window);
- }
QWidget *tlw = m_tlwMap.value(event.window.window_id);
QWindowSystemInterface::handleMouseEvent(tlw, timestamp, p, globalPos, buttons);
}
@@ -199,10 +200,11 @@ void QDirectFbInput::handleEnterLeaveEvents(const DFBEvent &event)
inline QPoint QDirectFbInput::globalPoint(const DFBEvent &event) const
{
- IDirectFBWindow *window;
- m_dfbDisplayLayer->GetWindow(m_dfbDisplayLayer,event.window.window_id,&window);
+ QDirectFBPointer<IDirectFBWindow> window;
+ m_dfbDisplayLayer->GetWindow(m_dfbDisplayLayer, event.window.window_id, window.outPtr());
int x,y;
- window->GetPosition(window,&x,&y);
+ window->GetPosition(window.data(), &x, &y);
return QPoint(event.window.cx +x, event.window.cy + y);
}
+QT_END_NAMESPACE