KWaylandServer

output_interface.h
1 /*
2  SPDX-FileCopyrightText: 2014 Martin Gräßlin <[email protected]>
3  SPDX-FileCopyrightText: 2021 Vlad Zahorodnii <[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 
15 struct wl_resource;
16 
17 namespace KWaylandServer
18 {
19 class ClientConnection;
20 class Display;
21 class OutputInterfacePrivate;
22 
23 /**
24  * The OutputInterface class represents a screen. This class corresponds to the Wayland
25  * interface @c wl_output.
26  */
27 class KWAYLANDSERVER_EXPORT OutputInterface : public QObject
28 {
29  Q_OBJECT
30  Q_PROPERTY(QSize physicalSize READ physicalSize WRITE setPhysicalSize NOTIFY physicalSizeChanged)
31  Q_PROPERTY(QPoint globalPosition READ globalPosition WRITE setGlobalPosition NOTIFY globalPositionChanged)
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(QSize pixelSize READ pixelSize NOTIFY pixelSizeChanged)
35  Q_PROPERTY(int refreshRate READ refreshRate NOTIFY refreshRateChanged)
36  Q_PROPERTY(int scale READ scale WRITE setScale NOTIFY scaleChanged)
37 public:
38  enum class SubPixel {
39  Unknown,
40  None,
41  HorizontalRGB,
42  HorizontalBGR,
43  VerticalRGB,
44  VerticalBGR,
45  };
46  enum class Transform {
47  Normal,
48  Rotated90,
49  Rotated180,
50  Rotated270,
51  Flipped,
52  Flipped90,
53  Flipped180,
54  Flipped270,
55  };
56  struct Mode {
57  QSize size = QSize();
58  int refreshRate = 60000;
59  };
60  enum class DpmsMode {
61  On,
62  Standby,
63  Suspend,
64  Off,
65  };
66 
67  explicit OutputInterface(Display *display, QObject *parent = nullptr);
68  ~OutputInterface() override;
69 
70  void remove();
71 
72  QSize physicalSize() const;
73  QPoint globalPosition() const;
74  QString manufacturer() const;
75  QString model() const;
76  QSize pixelSize() const;
77  int refreshRate() const;
78  int scale() const;
79  SubPixel subPixel() const;
80  Transform transform() const;
81  Mode mode() const;
82  bool isDpmsSupported() const;
83  DpmsMode dpmsMode() const;
84 
85  void setPhysicalSize(const QSize &size);
86  void setGlobalPosition(const QPoint &pos);
87  void setManufacturer(const QString &manufacturer);
88  void setModel(const QString &model);
89  void setScale(int scale);
90  void setSubPixel(SubPixel subPixel);
91  void setTransform(Transform transform);
92  void setMode(const Mode &mode);
93  void setMode(const QSize &size, int refreshRate = 60000);
94 
95  /**
96  * Sets whether Dpms is supported for this output.
97  * Default is @c false.
98  */
99  void setDpmsSupported(bool supported);
100  /**
101  * Sets the currently used dpms mode.
102  * Default is @c DpmsMode::On.
103  */
104  void setDpmsMode(DpmsMode mode);
105 
106  /**
107  * @returns all wl_resources bound for the @p client
108  */
109  QVector<wl_resource *> clientResources(ClientConnection *client) const;
110 
111  /**
112  * Returns @c true if the output is on; otherwise returns false.
113  */
114  bool isEnabled() const;
115 
116  /**
117  * Submit changes to all clients.
118  */
119  void done();
120 
121  static OutputInterface *get(wl_resource *native);
122 
123 Q_SIGNALS:
124  void physicalSizeChanged(const QSize &);
125  void globalPositionChanged(const QPoint &);
126  void manufacturerChanged(const QString &);
127  void modelChanged(const QString &);
128  void pixelSizeChanged(const QSize &);
129  void refreshRateChanged(int);
130  void scaleChanged(int);
131  void subPixelChanged(SubPixel);
132  void transformChanged(Transform);
133  void modeChanged();
134  void dpmsModeChanged();
135  void dpmsSupportedChanged();
136  void removed();
137 
138  /**
139  * Change of dpms @p mode is requested.
140  * A server is free to ignore this request.
141  */
142  void dpmsModeRequested(KWaylandServer::OutputInterface::DpmsMode mode);
143 
144  /**
145  * Emitted when a client binds to a given output
146  * @internal
147  */
148  void bound(ClientConnection *client, wl_resource *boundResource);
149 
150 private:
152 };
153 
154 } // namespace KWaylandServer
155 
156 Q_DECLARE_METATYPE(KWaylandServer::OutputInterface::SubPixel)
157 Q_DECLARE_METATYPE(KWaylandServer::OutputInterface::Transform)
158 Q_DECLARE_METATYPE(KWaylandServer::OutputInterface::DpmsMode)
The OutputInterface class represents a screen.
Class holding the Wayland server display loop.
Definition: display.h:47
Convenient Class which represents a wl_client.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Oct 23 2021 23:08:27 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.