1 | // Copyright (C) 2021 The Qt Company Ltd. |
---|---|
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
3 | |
4 | #ifndef QWAYLANDQTSHELLCHROME_H |
5 | #define QWAYLANDQTSHELLCHROME_H |
6 | |
7 | #include <QtQuick/qquickitem.h> |
8 | #include <QtWaylandCompositor/qwaylandquickshellsurfaceitem.h> |
9 | |
10 | QT_BEGIN_NAMESPACE |
11 | |
12 | class QWaylandQtShellChromePrivate; |
13 | class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandQtShellChrome : public QQuickItem |
14 | { |
15 | Q_OBJECT |
16 | Q_DECLARE_PRIVATE(QWaylandQtShellChrome) |
17 | Q_PROPERTY(bool hasDecorations READ hasDecorations NOTIFY windowMetaInfoChanged) |
18 | Q_PROPERTY(uint windowState READ currentWindowState NOTIFY currentWindowStateChanged) |
19 | Q_PROPERTY(uint windowFlags READ currentWindowFlags NOTIFY currentWindowFlagsChanged) |
20 | Q_PROPERTY(QWaylandQuickShellSurfaceItem *shellSurfaceItem READ shellSurfaceItem WRITE setShellSurfaceItem NOTIFY shellSurfaceItemChanged) |
21 | Q_PROPERTY(QRect maximizedRect READ maximizedRect WRITE setMaximizedRect NOTIFY maximizedRectChanged) |
22 | |
23 | Q_PROPERTY(int frameMarginLeft READ frameMarginLeft WRITE setFrameMarginLeft NOTIFY frameMarginChanged) |
24 | Q_PROPERTY(int frameMarginRight READ frameMarginRight WRITE setFrameMarginRight NOTIFY frameMarginChanged) |
25 | Q_PROPERTY(int frameMarginTop READ frameMarginTop WRITE setFrameMarginTop NOTIFY frameMarginChanged) |
26 | Q_PROPERTY(int frameMarginBottom READ frameMarginBottom WRITE setFrameMarginBottom NOTIFY frameMarginChanged) |
27 | |
28 | Q_PROPERTY(QQuickItem *titleBar READ titleBar WRITE setTitleBar NOTIFY titleBarChanged); |
29 | Q_PROPERTY(QQuickItem *leftResizeHandle READ leftResizeHandle WRITE setLeftResizeHandle NOTIFY leftResizeHandleChanged); |
30 | Q_PROPERTY(QQuickItem *rightResizeHandle READ rightResizeHandle WRITE setRightResizeHandle NOTIFY rightResizeHandleChanged); |
31 | Q_PROPERTY(QQuickItem *topResizeHandle READ topResizeHandle WRITE setTopResizeHandle NOTIFY topResizeHandleChanged); |
32 | Q_PROPERTY(QQuickItem *bottomResizeHandle READ bottomResizeHandle WRITE setBottomResizeHandle NOTIFY bottomResizeHandleChanged); |
33 | Q_PROPERTY(QQuickItem *topLeftResizeHandle READ topLeftResizeHandle WRITE setTopLeftResizeHandle NOTIFY topLeftResizeHandleChanged); |
34 | Q_PROPERTY(QQuickItem *topRightResizeHandle READ topRightResizeHandle WRITE setTopRightResizeHandle NOTIFY topRightResizeHandleChanged); |
35 | Q_PROPERTY(QQuickItem *bottomLeftResizeHandle READ bottomLeftResizeHandle WRITE setBottomLeftResizeHandle NOTIFY bottomLeftResizeHandleChanged); |
36 | Q_PROPERTY(QQuickItem *bottomRightResizeHandle READ bottomRightResizeHandle WRITE setBottomRightResizeHandle NOTIFY bottomRightResizeHandleChanged); |
37 | public: |
38 | QWaylandQtShellChrome(QQuickItem *parent = nullptr); |
39 | ~QWaylandQtShellChrome() override; |
40 | |
41 | bool hasTitleBar() const; |
42 | bool hasDecorations() const; |
43 | uint currentWindowState() const; |
44 | uint currentWindowFlags() const; |
45 | |
46 | void setMaximizedRect(const QRect &rect); |
47 | QRect maximizedRect() const; |
48 | |
49 | void setShellSurfaceItem(QWaylandQuickShellSurfaceItem *shellSurfaceItem); |
50 | QWaylandQuickShellSurfaceItem *shellSurfaceItem() const; |
51 | |
52 | void setTitleBar(QQuickItem *item); |
53 | QQuickItem *titleBar() const; |
54 | |
55 | void setLeftResizeHandle(QQuickItem *item); |
56 | QQuickItem *leftResizeHandle() const; |
57 | |
58 | void setRightResizeHandle(QQuickItem *item); |
59 | QQuickItem *rightResizeHandle() const; |
60 | |
61 | void setTopResizeHandle(QQuickItem *item); |
62 | QQuickItem *topResizeHandle() const; |
63 | |
64 | void setBottomResizeHandle(QQuickItem *item); |
65 | QQuickItem *bottomResizeHandle() const; |
66 | |
67 | void setTopLeftResizeHandle(QQuickItem *item); |
68 | QQuickItem *topLeftResizeHandle() const; |
69 | |
70 | void setBottomLeftResizeHandle(QQuickItem *item); |
71 | QQuickItem *bottomLeftResizeHandle() const; |
72 | |
73 | void setTopRightResizeHandle(QQuickItem *item); |
74 | QQuickItem *topRightResizeHandle() const; |
75 | |
76 | void setBottomRightResizeHandle(QQuickItem *item); |
77 | QQuickItem *bottomRightResizeHandle() const; |
78 | |
79 | int frameMarginLeft() const; |
80 | void setFrameMarginLeft(int left); |
81 | |
82 | int frameMarginRight() const; |
83 | void setFrameMarginRight(int right); |
84 | |
85 | int frameMarginTop() const; |
86 | void setFrameMarginTop(int top); |
87 | |
88 | int frameMarginBottom() const; |
89 | void setFrameMarginBottom(int bottom); |
90 | |
91 | Q_SIGNALS: |
92 | void currentWindowStateChanged(); |
93 | void currentWindowFlagsChanged(); |
94 | void windowMetaInfoChanged(); |
95 | void shellSurfaceItemChanged(); |
96 | void maximizedRectChanged(); |
97 | |
98 | void titleBarChanged(); |
99 | void leftResizeHandleChanged(); |
100 | void rightResizeHandleChanged(); |
101 | void topResizeHandleChanged(); |
102 | void bottomResizeHandleChanged(); |
103 | void topLeftResizeHandleChanged(); |
104 | void bottomLeftResizeHandleChanged(); |
105 | void topRightResizeHandleChanged(); |
106 | void bottomRightResizeHandleChanged(); |
107 | |
108 | void activated(); |
109 | void deactivated(); |
110 | |
111 | void clientDestroyed(); |
112 | void frameMarginChanged(); |
113 | |
114 | public Q_SLOTS: |
115 | void raise(); |
116 | void lower(); |
117 | void toggleMaximized(); |
118 | void toggleMinimized(); |
119 | void toggleFullScreen(); |
120 | void activate(); |
121 | void deactivate(); |
122 | |
123 | private Q_SLOTS: |
124 | void activateOnGrab(QPointingDevice::GrabTransition transition); |
125 | void updateSurface(); |
126 | void updateShellSurface(); |
127 | void updateWindowFlags(); |
128 | void updateWindowState(); |
129 | void updateGeometry(); |
130 | void updateDecorations(); |
131 | void updateActiveState(); |
132 | void updateAutomaticPosition(); |
133 | void stopGrab(); |
134 | void leftResize(); |
135 | void rightResize(); |
136 | void topResize(); |
137 | void bottomResize(); |
138 | void topLeftResize(); |
139 | void topRightResize(); |
140 | void bottomLeftResize(); |
141 | void bottomRightResize(); |
142 | void titleBarMove(); |
143 | |
144 | protected: |
145 | QWaylandQtShellChrome(QWaylandQtShellChromePrivate &dd, QQuickItem *parent); |
146 | |
147 | private: |
148 | void setWindowState(uint nextState); |
149 | void init(); |
150 | QRect maxContentRect() const; |
151 | }; |
152 | |
153 | QT_END_NAMESPACE |
154 | |
155 | #endif // QWAYLANDQTSHELLSURFACEITEM_H |
156 |