1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2017-2016 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> |
4 | ** Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB). |
5 | ** Contact: https://www.qt.io/licensing/ |
6 | ** |
7 | ** This file is part of the QtWaylandCompositor module of the Qt Toolkit. |
8 | ** |
9 | ** $QT_BEGIN_LICENSE:GPL$ |
10 | ** Commercial License Usage |
11 | ** Licensees holding valid commercial Qt licenses may use this file in |
12 | ** accordance with the commercial license agreement provided with the |
13 | ** Software or, alternatively, in accordance with the terms contained in |
14 | ** a written agreement between you and The Qt Company. For licensing terms |
15 | ** and conditions see https://www.qt.io/terms-conditions. For further |
16 | ** information use the contact form at https://www.qt.io/contact-us. |
17 | ** |
18 | ** GNU General Public License Usage |
19 | ** Alternatively, this file may be used under the terms of the GNU |
20 | ** General Public License version 3 or (at your option) any later version |
21 | ** approved by the KDE Free Qt Foundation. The licenses are as published by |
22 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 |
23 | ** included in the packaging of this file. Please review the following |
24 | ** information to ensure the GNU General Public License requirements will |
25 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
26 | ** |
27 | ** $QT_END_LICENSE$ |
28 | ** |
29 | ****************************************************************************/ |
30 | |
31 | #ifndef QWAYLANDOUTPUT_H |
32 | #define QWAYLANDOUTPUT_H |
33 | |
34 | #include <QtWaylandCompositor/qwaylandcompositorextension.h> |
35 | #include <QtWaylandCompositor/QWaylandOutputMode> |
36 | #include <QtCore/QObject> |
37 | |
38 | #include <QObject> |
39 | #include <QRect> |
40 | #include <QSize> |
41 | |
42 | struct wl_resource; |
43 | |
44 | QT_BEGIN_NAMESPACE |
45 | |
46 | class QWaylandOutputPrivate; |
47 | class QWaylandCompositor; |
48 | class QWindow; |
49 | class QWaylandSurface; |
50 | class QWaylandView; |
51 | class QWaylandClient; |
52 | class QWaylandOutputSpace; |
53 | |
54 | class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandOutput : public QWaylandObject |
55 | { |
56 | Q_OBJECT |
57 | Q_DECLARE_PRIVATE(QWaylandOutput) |
58 | Q_PROPERTY(QWaylandCompositor *compositor READ compositor WRITE setCompositor NOTIFY compositorChanged) |
59 | Q_PROPERTY(QWindow *window READ window WRITE setWindow NOTIFY windowChanged) |
60 | Q_PROPERTY(QString manufacturer READ manufacturer WRITE setManufacturer NOTIFY manufacturerChanged) |
61 | Q_PROPERTY(QString model READ model WRITE setModel NOTIFY modelChanged) |
62 | Q_PROPERTY(QPoint position READ position WRITE setPosition NOTIFY positionChanged) |
63 | Q_PROPERTY(QRect geometry READ geometry NOTIFY geometryChanged) |
64 | Q_PROPERTY(QRect availableGeometry READ availableGeometry WRITE setAvailableGeometry NOTIFY availableGeometryChanged) |
65 | Q_PROPERTY(QSize physicalSize READ physicalSize WRITE setPhysicalSize NOTIFY physicalSizeChanged) |
66 | Q_PROPERTY(QWaylandOutput::Subpixel subpixel READ subpixel WRITE setSubpixel NOTIFY subpixelChanged) |
67 | Q_PROPERTY(QWaylandOutput::Transform transform READ transform WRITE setTransform NOTIFY transformChanged) |
68 | Q_PROPERTY(int scaleFactor READ scaleFactor WRITE setScaleFactor NOTIFY scaleFactorChanged) |
69 | Q_PROPERTY(bool sizeFollowsWindow READ sizeFollowsWindow WRITE setSizeFollowsWindow NOTIFY sizeFollowsWindowChanged) |
70 | Q_ENUMS(Subpixel Transform) |
71 | |
72 | public: |
73 | enum Subpixel { |
74 | SubpixelUnknown = 0, |
75 | SubpixelNone, |
76 | SubpixelHorizontalRgb, |
77 | SubpixelHorizontalBgr, |
78 | SubpixelVerticalRgb, |
79 | SubpixelVerticalBgr |
80 | }; |
81 | Q_ENUM(Subpixel) |
82 | |
83 | enum Transform { |
84 | TransformNormal = 0, |
85 | Transform90, |
86 | Transform180, |
87 | Transform270, |
88 | TransformFlipped, |
89 | TransformFlipped90, |
90 | TransformFlipped180, |
91 | TransformFlipped270 |
92 | }; |
93 | Q_ENUM(Transform) |
94 | |
95 | QWaylandOutput(); |
96 | QWaylandOutput(QWaylandCompositor *compositor, QWindow *window); |
97 | ~QWaylandOutput() override; |
98 | |
99 | static QWaylandOutput *fromResource(wl_resource *resource); |
100 | struct ::wl_resource *resourceForClient(QWaylandClient *client) const; |
101 | |
102 | QWaylandCompositor *compositor() const; |
103 | void setCompositor(QWaylandCompositor *compositor); |
104 | |
105 | QWindow *window() const; |
106 | void setWindow(QWindow *window); |
107 | |
108 | QString manufacturer() const; |
109 | void setManufacturer(const QString &manufacturer); |
110 | |
111 | QString model() const; |
112 | void setModel(const QString &model); |
113 | |
114 | QPoint position() const; |
115 | void setPosition(const QPoint &pt); |
116 | |
117 | QList<QWaylandOutputMode> modes() const; |
118 | |
119 | void addMode(const QWaylandOutputMode &mode, bool preferred = false); |
120 | |
121 | QWaylandOutputMode currentMode() const; |
122 | void setCurrentMode(const QWaylandOutputMode &mode); |
123 | |
124 | QRect geometry() const; |
125 | |
126 | QRect availableGeometry() const; |
127 | void setAvailableGeometry(const QRect &availableGeometry); |
128 | |
129 | QSize physicalSize() const; |
130 | void setPhysicalSize(const QSize &size); |
131 | |
132 | Subpixel subpixel() const; |
133 | void setSubpixel(const Subpixel &subpixel); |
134 | |
135 | Transform transform() const; |
136 | void setTransform(const Transform &transform); |
137 | |
138 | int scaleFactor() const; |
139 | void setScaleFactor(int scale); |
140 | |
141 | bool sizeFollowsWindow() const; |
142 | void setSizeFollowsWindow(bool follow); |
143 | |
144 | bool physicalSizeFollowsSize() const; |
145 | void setPhysicalSizeFollowsSize(bool follow); |
146 | |
147 | void frameStarted(); |
148 | void sendFrameCallbacks(); |
149 | |
150 | void surfaceEnter(QWaylandSurface *surface); |
151 | void surfaceLeave(QWaylandSurface *surface); |
152 | |
153 | virtual void update(); |
154 | |
155 | Q_SIGNALS: |
156 | void compositorChanged(); |
157 | void windowChanged(); |
158 | void positionChanged(); |
159 | void geometryChanged(); |
160 | void modeAdded(); |
161 | void currentModeChanged(); |
162 | void availableGeometryChanged(); |
163 | void physicalSizeChanged(); |
164 | void scaleFactorChanged(); |
165 | void subpixelChanged(); |
166 | void transformChanged(); |
167 | void sizeFollowsWindowChanged(); |
168 | void physicalSizeFollowsSizeChanged(); |
169 | void manufacturerChanged(); |
170 | void modelChanged(); |
171 | void windowDestroyed(); |
172 | |
173 | protected: |
174 | bool event(QEvent *event) override; |
175 | |
176 | virtual void initialize(); |
177 | |
178 | private: |
179 | Q_PRIVATE_SLOT(d_func(), void _q_handleMaybeWindowPixelSizeChanged()) |
180 | Q_PRIVATE_SLOT(d_func(), void _q_handleWindowDestroyed()) |
181 | }; |
182 | |
183 | QT_END_NAMESPACE |
184 | |
185 | #endif // QWAYLANDOUTPUT_H |
186 | |