KWaylandServer

outputdevice_v2_interface.h
1 /*
2  SPDX-FileCopyrightText: 2014 Martin Gräßlin <[email protected]>
3  SPDX-FileCopyrightText: 2021 Méven Car <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
6 */
7 #pragma once
8 
9 #include <KWaylandServer/kwaylandserver_export.h>
10 
11 #include <QObject>
12 #include <QPoint>
13 #include <QSize>
14 #include <QUuid>
15 #include <QVector>
16 
17 struct wl_resource;
18 
19 namespace KWaylandServer
20 {
21 
22 class Display;
23 class OutputDeviceV2InterfacePrivate;
24 class OutputDeviceModeV2Interface;
25 class OutputDeviceModeV2InterfacePrivate;
26 
27 
28 /** @class OutputDeviceV2Interface
29  *
30  * Represents an output device, the difference to Output is that this output can be disabled,
31  * so not currently used to display content.
32  *
33  * @see OutputManagementV2Interface
34  */
35 class KWAYLANDSERVER_EXPORT OutputDeviceV2Interface : public QObject
36 {
37  Q_OBJECT
38  Q_PROPERTY(QSize physicalSize READ physicalSize WRITE setPhysicalSize NOTIFY physicalSizeChanged)
39  Q_PROPERTY(QPoint globalPosition READ globalPosition WRITE setGlobalPosition NOTIFY globalPositionChanged)
40  Q_PROPERTY(QString manufacturer READ manufacturer WRITE setManufacturer NOTIFY manufacturerChanged)
41  Q_PROPERTY(QString model READ model WRITE setModel NOTIFY modelChanged)
42  Q_PROPERTY(QString serialNumber READ serialNumber WRITE setSerialNumber NOTIFY serialNumberChanged)
43  Q_PROPERTY(QString eisaId READ eisaId WRITE setEisaId NOTIFY eisaIdChanged)
44  Q_PROPERTY(qreal scale READ scale WRITE setScale NOTIFY scaleChanged)
45  Q_PROPERTY(QByteArray edid READ edid WRITE setEdid NOTIFY edidChanged)
46  Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
47  Q_PROPERTY(QUuid uuid READ uuid WRITE setUuid NOTIFY uuidChanged)
48  Q_PROPERTY(Capabilities capabilities READ capabilities WRITE setCapabilities NOTIFY capabilitiesChanged)
49  Q_PROPERTY(uint32_t overscan READ overscan WRITE setOverscan NOTIFY overscanChanged)
50  Q_PROPERTY(VrrPolicy vrrPolicy READ vrrPolicy WRITE setVrrPolicy NOTIFY vrrPolicyChanged)
51  Q_PROPERTY(RgbRange rgbRange READ rgbRange WRITE setRgbRange NOTIFY rgbRangeChanged)
52 public:
53  enum class SubPixel {
54  Unknown,
55  None,
56  HorizontalRGB,
57  HorizontalBGR,
58  VerticalRGB,
59  VerticalBGR,
60  };
61  Q_ENUM(SubPixel)
62  enum class Transform {
63  Normal,
64  Rotated90,
65  Rotated180,
66  Rotated270,
67  Flipped,
68  Flipped90,
69  Flipped180,
70  Flipped270,
71  };
72  Q_ENUM(Transform)
73  enum class Capability {
74  Overscan = 0x1,
75  Vrr = 0x2,
76  RgbRange = 0x4,
77  };
78  Q_ENUM(Capability)
79  Q_DECLARE_FLAGS(Capabilities, Capability)
80  enum class VrrPolicy {
81  Never = 0,
82  Always = 1,
83  Automatic = 2
84  };
85  Q_ENUM(VrrPolicy)
86  enum class RgbRange {
87  Automatic = 0,
88  Full = 1,
89  Limited = 2,
90  };
91  Q_ENUM(RgbRange)
92 
93  explicit OutputDeviceV2Interface(Display *display, QObject *parent = nullptr);
94  ~OutputDeviceV2Interface() override;
95 
96  void remove();
97 
98  QSize physicalSize() const;
99  QPoint globalPosition() const;
100  QString manufacturer() const;
101  QString model() const;
102  QString serialNumber() const;
103  QString eisaId() const;
104  QSize pixelSize() const;
105  int refreshRate() const;
106 
107  qreal scale() const;
108  SubPixel subPixel() const;
109  Transform transform() const;
110 
111  QByteArray edid() const;
112  bool enabled() const;
113  QUuid uuid() const;
114 
115  Capabilities capabilities() const;
116  uint32_t overscan() const;
117  VrrPolicy vrrPolicy() const;
118  RgbRange rgbRange() const;
119 
120  void setPhysicalSize(const QSize &size);
121  void setGlobalPosition(const QPoint &pos);
122  void setManufacturer(const QString &manufacturer);
123  void setModel(const QString &model);
124  void setSerialNumber(const QString &serialNumber);
125  void setEisaId(const QString &eisaId);
126 
127  void setScale(qreal scale);
128  void setSubPixel(SubPixel subPixel);
129  void setTransform(Transform transform);
130 
131  void setModes(const QList<KWaylandServer::OutputDeviceModeV2Interface *> &modes);
132  void setCurrentMode(KWaylandServer::OutputDeviceModeV2Interface *mode);
133 
134  /**
135  * Makes the mode with the specified @a size and @a refreshRate current.
136  * Returns @c false if no mode with the given attributes exists; otherwise returns @c true.
137  */
138  bool setCurrentMode(const QSize &size, int refreshRate);
139 
140  void setEdid(const QByteArray &edid);
141  void setEnabled(bool enabled);
142  void setUuid(const QUuid &uuid);
143 
144  void setCapabilities(Capabilities cap);
145  void setOverscan(uint32_t overscan);
146  void setVrrPolicy(VrrPolicy policy);
147  void setRgbRange(RgbRange rgbRange);
148 
149  static OutputDeviceV2Interface *get(wl_resource *native);
150 
151 Q_SIGNALS:
152  void physicalSizeChanged(const QSize&);
153  void globalPositionChanged(const QPoint&);
154  void manufacturerChanged(const QString&);
155  void modelChanged(const QString&);
156  void serialNumberChanged(const QString&);
157  void eisaIdChanged(const QString &);
158  void scaleChanged(qreal);
159  void subPixelChanged(SubPixel);
160  void transformChanged(Transform);
161  void modesChanged();
162  void currentModeChanged();
163 
164  void edidChanged();
165  void enabledChanged();
166  void uuidChanged();
167 
168  void capabilitiesChanged();
169  void overscanChanged();
170  void vrrPolicyChanged();
171  void rgbRangeChanged();
172 
173 private:
175 };
176 
177 /**
178  * @class OutputDeviceModeV2Interface
179  *
180  * Represents an output device mode.
181  *
182 * @see OutputDeviceV2Interface
183  */
184 class KWAYLANDSERVER_EXPORT OutputDeviceModeV2Interface : public QObject
185 {
186  Q_OBJECT
187 public:
188  enum class ModeFlag {
189  Current = 0x1,
190  Preferred = 0x2,
191  };
192  Q_ENUM(ModeFlag)
193  Q_DECLARE_FLAGS(ModeFlags, ModeFlag)
194 
195  OutputDeviceModeV2Interface(const QSize &size, int refreshRate, ModeFlags flags, QObject *parent = nullptr);
196  ~OutputDeviceModeV2Interface() override;
197 
198  QSize size() const;
199  int refreshRate() const;
201 
202  void setFlags(OutputDeviceModeV2Interface::ModeFlags newFlags);
203 
204  static OutputDeviceModeV2Interface *get(wl_resource *native);
205 
206 private:
207  friend class OutputDeviceModeV2InterfacePrivate;
209 };
210 
211 }
212 
213 Q_DECLARE_METATYPE(KWaylandServer::OutputDeviceModeV2Interface::ModeFlag)
214 Q_DECLARE_METATYPE(KWaylandServer::OutputDeviceV2Interface::SubPixel)
215 Q_DECLARE_METATYPE(KWaylandServer::OutputDeviceV2Interface::Transform)
Class holding the Wayland server display loop.
Definition: display.h:47
Represents an output device, the difference to Output is that this output can be disabled, so not currently used to display content.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Oct 16 2021 23:10:14 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.