summaryrefslogtreecommitdiffstats
path: root/src/plugins/graphicssystems/minimaldfb/qdirectfbinput.h
blob: 31aa082de9906779453a89450ea19c56aa880ae3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifndef QDIRECTFBINPUT_H
#define QDIRECTFBINPUT_H

#include <QThread>
#include <QMutex>
#include <QWaitCondition>
#include <QObject>
#include <QHash>
#include <QPoint>
#include <QEvent>

#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();
    void addWindow(DFBWindowID id, QWidget *tlw);
    void removeWindow(QWidget *tlw);

public slots:
    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;

    QHash<DFBWindowID,QWidget *>tlwMap;

    inline QPoint globalPoint(const DFBEvent &event) const;

    InputSocketWaiter *m_inputHandler;

};

#endif // QDIRECTFBINPUT_H