Directory: | ./ |
---|---|
File: | server/output.h |
Date: | 2024-01-22 17:25:27 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 15 | 15 | 100.0% |
Branches: | 13 | 26 | 50.0% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | /******************************************************************** | ||
2 | Copyright © 2020 Roman Gilg <subdiff@gmail.com> | ||
3 | |||
4 | This library is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU Lesser General Public | ||
6 | License as published by the Free Software Foundation; either | ||
7 | version 2.1 of the License, or (at your option) version 3, or any | ||
8 | later version accepted by the membership of KDE e.V. (or its | ||
9 | successor approved by the membership of KDE e.V.), which shall | ||
10 | act as a proxy defined in Section 6 of version 3 of the license. | ||
11 | |||
12 | This library is distributed in the hope that it will be useful, | ||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
15 | Lesser General Public License for more details. | ||
16 | |||
17 | You should have received a copy of the GNU Lesser General Public | ||
18 | License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||
19 | *********************************************************************/ | ||
20 | #pragma once | ||
21 | |||
22 | #include <Wrapland/Server/wraplandserver_export.h> | ||
23 | |||
24 | #include <QObject> | ||
25 | #include <QRectF> | ||
26 | #include <QSize> | ||
27 | #include <memory> | ||
28 | #include <string> | ||
29 | #include <vector> | ||
30 | |||
31 | namespace Wrapland::Server | ||
32 | { | ||
33 | |||
34 | class output_manager; | ||
35 | class WlOutput; | ||
36 | class XdgOutput; | ||
37 | |||
38 | enum class output_dpms_mode { | ||
39 | on, | ||
40 | standby, | ||
41 | suspend, | ||
42 | off, | ||
43 | }; | ||
44 | |||
45 | enum class output_subpixel { | ||
46 | unknown, | ||
47 | none, | ||
48 | horizontal_rgb, | ||
49 | horizontal_bgr, | ||
50 | vertical_rgb, | ||
51 | vertical_bgr, | ||
52 | }; | ||
53 | |||
54 | enum class output_transform { | ||
55 | normal, | ||
56 | rotated_90, | ||
57 | rotated_180, | ||
58 | rotated_270, | ||
59 | flipped, | ||
60 | flipped_90, | ||
61 | flipped_180, | ||
62 | flipped_270, | ||
63 | }; | ||
64 | |||
65 | 448 | struct output_mode { | |
66 | bool operator==(output_mode const& mode) const; | ||
67 | bool operator!=(output_mode const& mode) const; | ||
68 | QSize size; | ||
69 | static constexpr int defaultRefreshRate = 60000; | ||
70 | 448 | int refresh_rate{defaultRefreshRate}; | |
71 | 448 | bool preferred{false}; | |
72 | 448 | int id{-1}; | |
73 | }; | ||
74 | |||
75 |
3/6✓ Branch 0 taken 794 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 794 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 794 times.
|
1421 | struct output_metadata { |
76 |
1/2✓ Branch 0 taken 627 times.
✗ Branch 1 not taken.
|
627 | std::string name{"Unknown"}; |
77 | std::string description; | ||
78 | std::string make; | ||
79 | std::string model; | ||
80 | std::string serial_number; | ||
81 | QSize physical_size; | ||
82 | }; | ||
83 | |||
84 | 1308 | struct output_state { | |
85 | 436 | bool enabled{false}; | |
86 | |||
87 | output_mode mode; | ||
88 | 436 | output_subpixel subpixel{output_subpixel::unknown}; | |
89 | |||
90 | 436 | output_transform transform{output_transform::normal}; | |
91 | QRectF geometry; | ||
92 | |||
93 | // Automatically calculated on setter call. | ||
94 | 436 | int client_scale = 1; | |
95 | 436 | bool adaptive_sync{false}; | |
96 | }; | ||
97 | |||
98 | /** | ||
99 | * Produces a description from available data. The pattern will be: | ||
100 | * - if make or model available: "<make> <model> (<name>)" | ||
101 | * - otherwise: "<name>" | ||
102 | */ | ||
103 | WRAPLANDSERVER_EXPORT std::string output_generate_description(output_metadata const& data); | ||
104 | |||
105 | /** | ||
106 | * Central class for outputs in Wrapland. Manages and forwards all required information to and from | ||
107 | * other output related classes such that compositors only need to interact with the Output class | ||
108 | * under normal circumstances. | ||
109 | */ | ||
110 | class WRAPLANDSERVER_EXPORT output : public QObject | ||
111 | { | ||
112 | Q_OBJECT | ||
113 | public: | ||
114 | explicit output(output_manager& manager); | ||
115 | output(output_metadata metadata, output_manager& manager); | ||
116 | ~output() override; | ||
117 | |||
118 | output_metadata const& get_metadata() const; | ||
119 | |||
120 | /** | ||
121 | * Override of metadata. Prefer setting metadata through the ctor. Not all metadata may be | ||
122 | * updated on all protocol objects. | ||
123 | */ | ||
124 | void set_metadata(output_metadata const& data); | ||
125 | |||
126 | std::vector<output_mode> modes() const; | ||
127 | void add_mode(output_mode const& mode); | ||
128 | |||
129 | output_state const& get_state() const; | ||
130 | void set_state(output_state const& data); | ||
131 | |||
132 | int connector_id() const; | ||
133 | void set_connector_id(int id); | ||
134 | |||
135 | bool dpms_supported() const; | ||
136 | void set_dpms_supported(bool supported); | ||
137 | |||
138 | output_dpms_mode dpms_mode() const; | ||
139 | void set_dpms_mode(output_dpms_mode mode); | ||
140 | |||
141 | /** | ||
142 | * Sends all pending changes out to connected clients. Must only be called when all atomic | ||
143 | * changes to an output has been completed. | ||
144 | */ | ||
145 | void done(); | ||
146 | |||
147 | WlOutput* wayland_output() const; | ||
148 | XdgOutput* xdg_output() const; | ||
149 | |||
150 | Q_SIGNALS: | ||
151 | void dpms_mode_changed(); | ||
152 | void dpms_supported_changed(); | ||
153 | void dpms_mode_requested(Wrapland::Server::output_dpms_mode mode); | ||
154 | |||
155 | private: | ||
156 | friend class WlOutput; | ||
157 | friend class wlr_output_configuration_head_v1; | ||
158 | friend class wlr_output_head_v1; | ||
159 | friend class XdgOutput; | ||
160 | |||
161 | class Private; | ||
162 | std::unique_ptr<Private> d_ptr; | ||
163 | }; | ||
164 | |||
165 | } | ||
166 | |||
167 |
3/6✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | Q_DECLARE_METATYPE(Wrapland::Server::output_subpixel) |
168 |
3/6✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | Q_DECLARE_METATYPE(Wrapland::Server::output_transform) |
169 |
3/6✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | Q_DECLARE_METATYPE(Wrapland::Server::output_dpms_mode) |
170 |