blob: 0e0433a42e8f0cd483171f8d987d0a8776fc7c24 (
plain)
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
|
#pragma once
#include <vector>
#include <unordered_map>
#include "WaylandProtocol.hpp"
#include "ext-idle-notify-v1.hpp"
class CEventLoopTimer;
class CExtIdleNotification {
public:
CExtIdleNotification(SP<CExtIdleNotificationV1> resource_, uint32_t timeoutMs, bool obeyInhibitors);
~CExtIdleNotification();
bool good();
void onTimerFired();
bool inhibitorsAreObeyed() const;
private:
SP<CExtIdleNotificationV1> m_resource;
uint32_t m_timeoutMs = 0;
SP<CEventLoopTimer> m_timer;
bool m_idled = false;
bool m_obeyInhibitors = false;
void reset();
void update();
void update(uint32_t elapsedMs);
friend class CIdleNotifyProtocol;
};
class CIdleNotifyProtocol : public IWaylandProtocol {
public:
CIdleNotifyProtocol(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);
void onActivity();
void setInhibit(bool inhibited);
void setTimers(uint32_t elapsedMs);
private:
void onManagerResourceDestroy(wl_resource* res);
void destroyNotification(CExtIdleNotification* notif);
void onGetNotification(CExtIdleNotifierV1* pMgr, uint32_t id, uint32_t timeout, wl_resource* seat, bool obeyInhibitors);
bool isInhibited = false;
//
std::vector<UP<CExtIdleNotifierV1>> m_managers;
std::vector<SP<CExtIdleNotification>> m_notifications;
friend class CExtIdleNotification;
};
namespace PROTO {
inline UP<CIdleNotifyProtocol> idle;
};
|