1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
#pragma once
#include <memory>
#include <vector>
#include <cstdint>
#include "WaylandProtocol.hpp"
#include "wlr-output-management-unstable-v1.hpp"
#include "../helpers/signal/Listener.hpp"
class CMonitor;
class COutputHead;
class COutputMode;
class COutputManager {
public:
COutputManager(SP<CZwlrOutputManagerV1> resource_);
bool good();
void ensureMonitorSent(CMonitor* pMonitor);
void sendDone();
private:
SP<CZwlrOutputManagerV1> resource;
bool stopped = false;
WP<COutputManager> self;
std::vector<WP<COutputHead>> heads;
void makeAndSendNewHead(CMonitor* pMonitor);
friend class COutputManagementProtocol;
};
class COutputMode {
public:
COutputMode(SP<CZwlrOutputModeV1> resource_, wlr_output_mode* mode_);
bool good();
wlr_output_mode* getMode();
void sendAllData();
private:
SP<CZwlrOutputModeV1> resource;
wlr_output_mode* mode = nullptr;
friend class COutputHead;
friend class COutputManagementProtocol;
};
class COutputHead {
public:
COutputHead(SP<CZwlrOutputHeadV1> resource_, CMonitor* pMonitor_);
bool good();
void sendAllData(); // this has to be separate as we need to send the head first, then set the data
void updateMode();
CMonitor* monitor();
private:
SP<CZwlrOutputHeadV1> resource;
CMonitor* pMonitor = nullptr;
void makeAndSendNewMode(wlr_output_mode* mode);
void sendCurrentMode();
std::vector<WP<COutputMode>> modes;
struct {
CHyprSignalListener monitorDestroy;
CHyprSignalListener monitorModeChange;
} listeners;
friend class COutputManager;
friend class COutputManagementProtocol;
};
class COutputConfigurationHead {
public:
COutputConfigurationHead(SP<CZwlrOutputConfigurationHeadV1> resource_, CMonitor* pMonitor_);
bool good();
enum eCommittedProperties : uint32_t {
OUTPUT_HEAD_COMMITTED_MODE = (1 << 0),
OUTPUT_HEAD_COMMITTED_CUSTOM_MODE = (1 << 1),
OUTPUT_HEAD_COMMITTED_POSITION = (1 << 2),
OUTPUT_HEAD_COMMITTED_TRANSFORM = (1 << 3),
OUTPUT_HEAD_COMMITTED_SCALE = (1 << 4),
OUTPUT_HEAD_COMMITTED_ADAPTIVE_SYNC = (1 << 5),
};
uint32_t committedProperties = 0;
struct {
WP<COutputMode> mode;
struct {
Vector2D size;
uint32_t refresh = 0;
} customMode;
Vector2D position;
wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL;
float scale = 1.F;
bool adaptiveSync = false;
} state;
private:
SP<CZwlrOutputConfigurationHeadV1> resource;
CMonitor* pMonitor = nullptr;
struct {
CHyprSignalListener monitorDestroy;
} listeners;
friend class COutputConfiguration;
};
class COutputConfiguration {
public:
COutputConfiguration(SP<CZwlrOutputConfigurationV1> resource_, SP<COutputManager> owner_);
bool good();
private:
SP<CZwlrOutputConfigurationV1> resource;
std::vector<WP<COutputConfigurationHead>> heads;
WP<COutputManager> owner;
bool applyTestConfiguration(bool test);
};
class COutputManagementProtocol : public IWaylandProtocol {
public:
COutputManagementProtocol(const wl_interface* iface, const int& ver, const std::string& name);
virtual void bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id);
private:
void destroyResource(COutputManager* resource);
void destroyResource(COutputHead* resource);
void destroyResource(COutputMode* resource);
void destroyResource(COutputConfiguration* resource);
void destroyResource(COutputConfigurationHead* resource);
void updateAllOutputs();
//
std::vector<SP<COutputManager>> m_vManagers;
std::vector<SP<COutputHead>> m_vHeads;
std::vector<SP<COutputMode>> m_vModes;
std::vector<SP<COutputConfiguration>> m_vConfigurations;
std::vector<SP<COutputConfigurationHead>> m_vConfigurationHeads;
SP<COutputHead> headFromResource(wl_resource* r);
SP<COutputMode> modeFromResource(wl_resource* r);
friend class COutputManager;
friend class COutputHead;
friend class COutputMode;
friend class COutputConfiguration;
friend class COutputConfigurationHead;
};
namespace PROTO {
inline UP<COutputManagementProtocol> outputManagement;
};
|