Revert "Suppress QWindowSystemInterface inclusion warnings."
[profile/ivi/qtwayland.git] / src / plugins / platforms / wayland / qwaylanddecoration.h
1 #ifndef QWAYLANDDECORATION_H
2 #define QWAYLANDDECORATION_H
3
4 #include <QtCore/QMargins>
5 #include <QtCore/QPointF>
6 #include <QtGui/QGuiApplication>
7 #include <QtGui/QCursor>
8 #include <QtGui/QImage>
9 #include <QtGui/QStaticText>
10
11 #include <wayland-client.h>
12
13 #include <QtCore/QDebug>
14
15 class QWindow;
16 class QPaintDevice;
17 class QPainter;
18 class QEvent;
19 class QWaylandWindow;
20 class QWaylandShmBackingStore;
21 class QWaylandInputDevice;
22
23 class QWaylandDecoration
24 {
25 public:
26     QWaylandDecoration(QWindow *window, QWaylandShmBackingStore *backing_store);
27     ~QWaylandDecoration();
28     void paintDecoration();
29     void handleMouse(QWaylandInputDevice *inputDevice, const QPointF &local, const QPointF &global,Qt::MouseButtons b,Qt::KeyboardModifiers mods);
30     void restoreMouseCursor();
31     bool inMouseButtonPressedState() const;
32
33     void startResize(QWaylandInputDevice *inputDevice,enum wl_shell_surface_resize resize, Qt::MouseButtons buttons);
34     void startMove(QWaylandInputDevice *inputDevice, Qt::MouseButtons buttons);
35     QMargins margins() const;
36 private:
37     void overrideCursor(Qt::CursorShape shape);
38
39     void processMouseTop(QWaylandInputDevice *inputDevice, const QPointF &local, Qt::MouseButtons b,Qt::KeyboardModifiers mods);
40     void processMouseBottom(QWaylandInputDevice *inputDevice, const QPointF &local, Qt::MouseButtons b,Qt::KeyboardModifiers mods);
41     void processMouseLeft(QWaylandInputDevice *inputDevice, const QPointF &local, Qt::MouseButtons b,Qt::KeyboardModifiers mods);
42     void processMouseRight(QWaylandInputDevice *inputDevice, const QPointF &local, Qt::MouseButtons b,Qt::KeyboardModifiers mods);
43
44     bool isLeftClicked(Qt::MouseButtons newMouseButtonState);
45     bool isLeftReleased(Qt::MouseButtons newMouseButtonState);
46
47     QWindow *m_window;
48     QWaylandWindow *m_wayland_window;
49     QWaylandShmBackingStore *m_backing_store;
50
51     QMargins m_margins;
52     bool m_hasSetCursor;
53     Qt::CursorShape m_cursorShape;
54     Qt::MouseButtons m_mouseButtons;
55
56     QStaticText m_windowTitle;
57
58     QImage m_borderImage;
59 };
60
61 inline QMargins QWaylandDecoration::margins() const
62 {
63     return m_margins;
64 }
65
66 inline void QWaylandDecoration::overrideCursor(Qt::CursorShape shape)
67 {
68     if (m_hasSetCursor) {
69         if (m_cursorShape != shape) {
70             QGuiApplication::changeOverrideCursor(QCursor(shape));
71             m_cursorShape = shape;
72         }
73     } else {
74         QGuiApplication::setOverrideCursor(QCursor(shape));
75         m_hasSetCursor = true;
76         m_cursorShape = shape;
77     }
78 }
79
80 #endif // QWAYLANDDECORATION_H