1// Copyright (C) 2017-2016 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
2// Copyright (C) 2017 Klarälvdalens Datakonsult AB (KDAB).
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
4
5#ifndef QWAYLANDOUTPUT_H
6#define QWAYLANDOUTPUT_H
7
8#include <QtWaylandCompositor/qtwaylandqmlinclude.h>
9#include <QtWaylandCompositor/qwaylandcompositorextension.h>
10#include <QtWaylandCompositor/QWaylandOutputMode>
11#include <QtCore/QObject>
12#include <QtCore/QRect>
13#include <QtCore/QSize>
14
15struct wl_resource;
16
17QT_BEGIN_NAMESPACE
18
19class QWaylandOutputPrivate;
20class QWaylandCompositor;
21class QWindow;
22class QWaylandSurface;
23class QWaylandView;
24class QWaylandClient;
25
26class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandOutput : public QWaylandObject
27{
28 Q_OBJECT
29 Q_DECLARE_PRIVATE(QWaylandOutput)
30 Q_PROPERTY(QWaylandCompositor *compositor READ compositor WRITE setCompositor NOTIFY compositorChanged)
31 Q_PROPERTY(QWindow *window READ window WRITE setWindow NOTIFY windowChanged)
32 Q_PROPERTY(QString manufacturer READ manufacturer WRITE setManufacturer NOTIFY manufacturerChanged)
33 Q_PROPERTY(QString model READ model WRITE setModel NOTIFY modelChanged)
34 Q_PROPERTY(QPoint position READ position WRITE setPosition NOTIFY positionChanged)
35 Q_PROPERTY(QRect geometry READ geometry NOTIFY geometryChanged)
36 Q_PROPERTY(QRect availableGeometry READ availableGeometry WRITE setAvailableGeometry NOTIFY availableGeometryChanged)
37 Q_PROPERTY(QSize physicalSize READ physicalSize WRITE setPhysicalSize NOTIFY physicalSizeChanged)
38 Q_PROPERTY(QWaylandOutput::Subpixel subpixel READ subpixel WRITE setSubpixel NOTIFY subpixelChanged)
39 Q_PROPERTY(QWaylandOutput::Transform transform READ transform WRITE setTransform NOTIFY transformChanged)
40 Q_PROPERTY(int scaleFactor READ scaleFactor WRITE setScaleFactor NOTIFY scaleFactorChanged)
41 Q_PROPERTY(bool sizeFollowsWindow READ sizeFollowsWindow WRITE setSizeFollowsWindow NOTIFY sizeFollowsWindowChanged)
42
43 QML_NAMED_ELEMENT(WaylandOutputBase)
44 QML_ADDED_IN_VERSION(1, 0)
45 QML_UNCREATABLE("Cannot create instance of WaylandOutputBase, use WaylandOutput instead")
46public:
47 enum Subpixel {
48 SubpixelUnknown = 0,
49 SubpixelNone,
50 SubpixelHorizontalRgb,
51 SubpixelHorizontalBgr,
52 SubpixelVerticalRgb,
53 SubpixelVerticalBgr
54 };
55 Q_ENUM(Subpixel)
56
57 enum Transform {
58 TransformNormal = 0,
59 Transform90,
60 Transform180,
61 Transform270,
62 TransformFlipped,
63 TransformFlipped90,
64 TransformFlipped180,
65 TransformFlipped270
66 };
67 Q_ENUM(Transform)
68
69 QWaylandOutput();
70 QWaylandOutput(QWaylandCompositor *compositor, QWindow *window);
71 ~QWaylandOutput() override;
72
73 static QWaylandOutput *fromResource(wl_resource *resource);
74 struct ::wl_resource *resourceForClient(QWaylandClient *client) const;
75
76 QWaylandCompositor *compositor() const;
77 void setCompositor(QWaylandCompositor *compositor);
78
79 QWindow *window() const;
80 void setWindow(QWindow *window);
81
82 QString manufacturer() const;
83 void setManufacturer(const QString &manufacturer);
84
85 QString model() const;
86 void setModel(const QString &model);
87
88 QPoint position() const;
89 void setPosition(const QPoint &pt);
90
91 QList<QWaylandOutputMode> modes() const;
92
93 void addMode(const QWaylandOutputMode &mode, bool preferred = false);
94
95 QWaylandOutputMode currentMode() const;
96 void setCurrentMode(const QWaylandOutputMode &mode);
97
98 QRect geometry() const;
99
100 QRect availableGeometry() const;
101 void setAvailableGeometry(const QRect &availableGeometry);
102
103 QSize physicalSize() const;
104 void setPhysicalSize(const QSize &size);
105
106 Subpixel subpixel() const;
107 void setSubpixel(const Subpixel &subpixel);
108
109 Transform transform() const;
110 void setTransform(const Transform &transform);
111
112 int scaleFactor() const;
113 void setScaleFactor(int scale);
114
115 bool sizeFollowsWindow() const;
116 void setSizeFollowsWindow(bool follow);
117
118 bool physicalSizeFollowsSize() const;
119 void setPhysicalSizeFollowsSize(bool follow);
120
121 void frameStarted();
122 void sendFrameCallbacks();
123
124 void surfaceEnter(QWaylandSurface *surface);
125 void surfaceLeave(QWaylandSurface *surface);
126
127 virtual void update();
128
129Q_SIGNALS:
130 void compositorChanged();
131 void windowChanged();
132 void positionChanged();
133 void geometryChanged();
134 void modeAdded();
135 void currentModeChanged();
136 void availableGeometryChanged();
137 void physicalSizeChanged();
138 void scaleFactorChanged();
139 void subpixelChanged();
140 void transformChanged();
141 void sizeFollowsWindowChanged();
142 void physicalSizeFollowsSizeChanged();
143 void manufacturerChanged();
144 void modelChanged();
145 void windowDestroyed();
146
147protected:
148 bool event(QEvent *event) override;
149
150 virtual void initialize();
151
152private:
153 Q_PRIVATE_SLOT(d_func(), void _q_handleMaybeWindowPixelSizeChanged())
154 Q_PRIVATE_SLOT(d_func(), void _q_handleWindowDestroyed())
155};
156
157QT_END_NAMESPACE
158
159#endif // QWAYLANDOUTPUT_H
160

source code of qtwayland/src/compositor/compositor_api/qwaylandoutput.h