KWayland

outputdevice_interface.h
1 /*
2  SPDX-FileCopyrightText: 2014 Martin Gräßlin <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5 */
6 #ifndef WAYLAND_SERVER_OUTPUTDEVICE_INTERFACE_H
7 #define WAYLAND_SERVER_OUTPUTDEVICE_INTERFACE_H
8 
9 #include <QObject>
10 #include <QPoint>
11 #include <QSize>
12 #include <QVector>
13 
14 #include "global.h"
15 #include <KWayland/Server/kwaylandserver_export.h>
16 
17 struct wl_resource;
18 
19 namespace KWayland
20 {
21 namespace Server
22 {
23 class Display;
24 
25 /** @class OutputDeviceInterface
26  *
27  * Represents an output device, the difference to Output is that this output can be disabled,
28  * so not currently used to display content.
29  *
30  * @see OutputManagementInterface
31  * @since 5.5
32  */
33 class KWAYLANDSERVER_EXPORT OutputDeviceInterface : public Global
34 {
35  Q_OBJECT
36  Q_PROPERTY(QSize physicalSize READ physicalSize WRITE setPhysicalSize NOTIFY physicalSizeChanged)
37  Q_PROPERTY(QPoint globalPosition READ globalPosition WRITE setGlobalPosition NOTIFY globalPositionChanged)
38  Q_PROPERTY(QString manufacturer READ manufacturer WRITE setManufacturer NOTIFY manufacturerChanged)
39  Q_PROPERTY(QString model READ model WRITE setModel NOTIFY modelChanged)
40  Q_PROPERTY(QString serialNumber READ serialNumber WRITE setSerialNumber NOTIFY serialNumberChanged)
41  Q_PROPERTY(QString eisaId READ eisaId WRITE setEisaId NOTIFY eisaIdChanged)
42  Q_PROPERTY(QSize pixelSize READ pixelSize NOTIFY pixelSizeChanged)
43  Q_PROPERTY(int refreshRate READ refreshRate NOTIFY refreshRateChanged)
44  Q_PROPERTY(qreal scale READ scaleF WRITE setScaleF NOTIFY scaleFChanged)
45  Q_PROPERTY(QByteArray edid READ edid WRITE setEdid NOTIFY edidChanged)
46  Q_PROPERTY(OutputDeviceInterface::Enablement enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
47  Q_PROPERTY(QByteArray uuid READ uuid WRITE setUuid NOTIFY uuidChanged)
48 public:
49  enum class SubPixel {
50  Unknown,
51  None,
52  HorizontalRGB,
53  HorizontalBGR,
54  VerticalRGB,
55  VerticalBGR,
56  };
57  enum class Transform {
58  Normal,
59  Rotated90,
60  Rotated180,
61  Rotated270,
62  Flipped,
63  Flipped90,
64  Flipped180,
65  Flipped270,
66  };
67  enum class Enablement {
68  Disabled = 0,
69  Enabled = 1,
70  };
71  enum class ModeFlag {
72  Current = 1,
73  Preferred = 2,
74  };
75  Q_DECLARE_FLAGS(ModeFlags, ModeFlag)
76  struct Mode {
77  QSize size = QSize();
78  int refreshRate = 60000;
79  ModeFlags flags;
80  int id = -1;
81  };
82  struct ColorCurves {
83  QVector<quint16> red, green, blue;
84  bool operator==(const ColorCurves &cc) const;
85  bool operator!=(const ColorCurves &cc) const;
86  };
87  ~OutputDeviceInterface() override;
88 
89  QSize physicalSize() const;
90  QPoint globalPosition() const;
91  QString manufacturer() const;
92  QString model() const;
93  QString serialNumber() const;
94  QString eisaId() const;
95  QSize pixelSize() const;
96  int refreshRate() const;
97 #if KWAYLANDSERVER_ENABLE_DEPRECATED_SINCE(5, 50)
98  /// @deprecated Since 5.50, use scaleF()
99  KWAYLANDSERVER_DEPRECATED_VERSION(5, 50, "Use OutputDeviceInterface::scaleF()")
100  int scale() const;
101 #endif
102  /// @since 5.50
103  qreal scaleF() const;
104  SubPixel subPixel() const;
105  Transform transform() const;
106  ColorCurves colorCurves() const;
107  QList<Mode> modes() const;
108  int currentModeId() const;
109 
110  QByteArray edid() const;
111  OutputDeviceInterface::Enablement enabled() const;
112  QByteArray uuid() const;
113 
114  void setPhysicalSize(const QSize &size);
115  void setGlobalPosition(const QPoint &pos);
116  void setManufacturer(const QString &manufacturer);
117  void setModel(const QString &model);
118  void setSerialNumber(const QString &serialNumber);
119  void setEisaId(const QString &eisaId);
120 #if KWAYLANDSERVER_ENABLE_DEPRECATED_SINCE(5, 50)
121  /// @deprecated Since 5.50, use setScale(qreal)
122  KWAYLANDSERVER_DEPRECATED_VERSION(5, 50, "Use OutputDeviceInterface::setScale(qreal)")
123  void setScale(int scale);
124 #endif
125  /// @since 5.50
126  void setScaleF(qreal scale);
127  void setSubPixel(SubPixel subPixel);
128  void setTransform(Transform transform);
129  void setColorCurves(const ColorCurves &colorCurves);
130 
131  /**
132  * Add an additional mode to this output device. This is only allowed before create() is called
133  * on the object.
134  *
135  * @param mode must have a valid size and non-negative id.
136  */
137  void addMode(Mode &mode);
138  void setCurrentMode(const int modeId);
139 
140  void setEdid(const QByteArray &edid);
141  void setEnabled(OutputDeviceInterface::Enablement enabled);
142  void setUuid(const QByteArray &uuid);
143 
144  static OutputDeviceInterface *get(wl_resource *native);
145  static QList<OutputDeviceInterface *> list();
146 
147 Q_SIGNALS:
148  void physicalSizeChanged(const QSize &);
149  void globalPositionChanged(const QPoint &);
150  void manufacturerChanged(const QString &);
151  void modelChanged(const QString &);
152  void serialNumberChanged(const QString &);
153  void eisaIdChanged(const QString &);
154  void pixelSizeChanged(const QSize &);
155  void refreshRateChanged(int);
156 #if KWAYLANDSERVER_ENABLE_DEPRECATED_SINCE(5, 50)
157  /// @deprecated Since 5.50, use scaleFChanged(qreal)
158  KWAYLANDSERVER_DEPRECATED_VERSION(5, 50, "Use OutputDeviceInterface::scaleFChanged(qreal)")
159  void scaleChanged(int);
160 #endif
161  /// @since 5.50
162  void scaleFChanged(qreal);
163  void subPixelChanged(SubPixel);
164  void transformChanged(Transform);
165  void colorCurvesChanged(ColorCurves);
166  void modesChanged();
167  void currentModeChanged();
168 
169  void edidChanged();
170  void enabledChanged();
171  void uuidChanged();
172 
173 private:
174  friend class Display;
175  explicit OutputDeviceInterface(Display *display, QObject *parent = nullptr);
176  class Private;
177  Private *d_func() const;
178 };
179 
180 Q_DECLARE_OPERATORS_FOR_FLAGS(OutputDeviceInterface::ModeFlags)
181 
182 }
183 }
184 
185 Q_DECLARE_METATYPE(KWayland::Server::OutputDeviceInterface::Enablement)
186 Q_DECLARE_METATYPE(KWayland::Server::OutputDeviceInterface::SubPixel)
187 Q_DECLARE_METATYPE(KWayland::Server::OutputDeviceInterface::Transform)
188 Q_DECLARE_METATYPE(KWayland::Server::OutputDeviceInterface::ColorCurves)
189 
190 #endif
Class holding the Wayland server display loop.
Definition: display.h:86
Base class for all Globals.
Definition: global.h:46
virtual QVariant get(ScriptableExtension *callerPrincipal, quint64 objId, const QString &propName)
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Jan 30 2023 03:56:24 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.