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
|
#pragma once
#include <memory>
#include <vector>
#include <cstdint>
#include "WaylandProtocol.hpp"
#include "ext-session-lock-v1.hpp"
#include "../helpers/signal/Signal.hpp"
class CMonitor;
class CSessionLock;
class CWLSurfaceResource;
class CSessionLockSurface {
public:
CSessionLockSurface(SP<CExtSessionLockSurfaceV1> resource_, SP<CWLSurfaceResource> surface_, CMonitor* pMonitor_, WP<CSessionLock> owner_);
~CSessionLockSurface();
bool good();
bool inert();
CMonitor* monitor();
SP<CWLSurfaceResource> surface();
struct {
CSignal map;
CSignal destroy;
CSignal commit;
} events;
private:
SP<CExtSessionLockSurfaceV1> resource;
WP<CSessionLock> sessionLock;
WP<CWLSurfaceResource> pSurface;
CMonitor* pMonitor = nullptr;
bool ackdConfigure = false;
bool committed = false;
void sendConfigure();
struct {
CHyprSignalListener monitorMode;
CHyprSignalListener surfaceCommit;
CHyprSignalListener surfaceDestroy;
} listeners;
};
class CSessionLock {
public:
CSessionLock(SP<CExtSessionLockV1> resource_);
~CSessionLock();
bool good();
void sendLocked();
void sendDenied();
struct {
CSignal newLockSurface; // SP<CSessionLockSurface>
CSignal unlockAndDestroy;
CSignal destroyed; // fires regardless of whether there was a unlockAndDestroy or not.
} events;
private:
SP<CExtSessionLockV1> resource;
bool inert = false;
friend class CSessionLockProtocol;
};
class CSessionLockProtocol : public IWaylandProtocol {
public:
CSessionLockProtocol(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);
bool isLocked();
struct {
CSignal newLock; // SP<CSessionLock>
} events;
private:
void onManagerResourceDestroy(wl_resource* res);
void destroyResource(CSessionLock* lock);
void destroyResource(CSessionLockSurface* surf);
void onLock(CExtSessionLockManagerV1* pMgr, uint32_t id);
void onGetLockSurface(CExtSessionLockV1* lock, uint32_t id, wl_resource* surface, wl_resource* output);
bool locked = false;
//
std::vector<UP<CExtSessionLockManagerV1>> m_vManagers;
std::vector<SP<CSessionLock>> m_vLocks;
std::vector<SP<CSessionLockSurface>> m_vLockSurfaces;
friend class CSessionLock;
friend class CSessionLockSurface;
};
namespace PROTO {
inline UP<CSessionLockProtocol> sessionLock;
};
|