summaryrefslogtreecommitdiffstats
path: root/examples/qwindow-compositor/qwindowcompositor.h
blob: a061ea880d4a3ef3950a3354553a8c4958d12e12 (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
#ifndef QWINDOWCOMPOSITOR_H
#define QWINDOWCOMPOSITOR_H

#include "waylandcompositor.h"
#include "waylandsurface.h"
#include "textureblitter.h"
#include "qopenglwindow.h"

#include <QtGui/private/qopengltexturecache_p.h>

#include <QObject>

class QWindowCompositor : public QObject, public WaylandCompositor
{
    Q_OBJECT
public:
    QWindowCompositor(QOpenGLWindow *window);
private slots:
    void surfaceDestroyed(QObject *object);
    void surfaceMapped();
    void surfaceDamaged(const QRect &rect);

    void render();
protected:
    void surfaceDamaged(WaylandSurface *surface, const QRect &rect);
    void surfaceCreated(WaylandSurface *surface);

    WaylandSurface* surfaceAt(const QPoint &point, QPoint *local = 0);

    GLuint composeSurface(WaylandSurface *surface);
    void paintChildren(WaylandSurface *surface, WaylandSurface *window);


    bool eventFilter(QObject *obj, QEvent *event);
    QPointF toSurface(WaylandSurface *surface, const QPointF &pos) const;

private:
    QOpenGLWindow *m_window;
    QImage m_backgroundImage;
    GLuint m_backgroundTexture;
    QList<WaylandSurface *> m_surfaces;
    TextureBlitter *m_textureBlitter;
    QOpenGLTextureCache *m_textureCache;
    GLuint m_surface_fbo;
    QTimer m_renderScheduler;

    //Dragging windows around
    WaylandSurface *m_draggingWindow;
    bool m_dragKeyIsPressed;
    QPoint m_drag_diff;

};

#endif // QWINDOWCOMPOSITOR_H