Don't crash when sending touch events.
[profile/ivi/qtwayland.git] / examples / qwindow-compositor / qwindowcompositor.h
1 #ifndef QWINDOWCOMPOSITOR_H
2 #define QWINDOWCOMPOSITOR_H
3
4 #include "waylandcompositor.h"
5 #include "waylandsurface.h"
6 #include "textureblitter.h"
7 #include "qopenglwindow.h"
8
9 #include <QtGui/private/qopengltexturecache_p.h>
10 #include <QObject>
11 #include <QOpenGLFunctions>
12
13 class QWindowCompositor : public QObject, public WaylandCompositor, protected QOpenGLFunctions
14 {
15     Q_OBJECT
16 public:
17     QWindowCompositor(QOpenGLWindow *window);
18 private slots:
19     void surfaceDestroyed(QObject *object);
20     void surfaceMapped();
21     void surfaceDamaged(const QRect &rect);
22
23     void render();
24 protected:
25     void surfaceDamaged(WaylandSurface *surface, const QRect &rect);
26     void surfaceCreated(WaylandSurface *surface);
27
28     WaylandSurface* surfaceAt(const QPoint &point, QPoint *local = 0);
29
30     GLuint composeSurface(WaylandSurface *surface);
31     void paintChildren(WaylandSurface *surface, WaylandSurface *window);
32
33
34     bool eventFilter(QObject *obj, QEvent *event);
35     QPointF toSurface(WaylandSurface *surface, const QPointF &pos) const;
36
37     void changeCursor(const QImage &image, int hotspotX, int hotspotY);
38
39 private:
40     QOpenGLWindow *m_window;
41     QImage m_backgroundImage;
42     GLuint m_backgroundTexture;
43     QList<WaylandSurface *> m_surfaces;
44     TextureBlitter *m_textureBlitter;
45     QOpenGLTextureCache *m_textureCache;
46     GLuint m_surface_fbo;
47     QTimer m_renderScheduler;
48
49     //Dragging windows around
50     WaylandSurface *m_draggingWindow;
51     bool m_dragKeyIsPressed;
52     QPoint m_drag_diff;
53
54 };
55
56 #endif // QWINDOWCOMPOSITOR_H