@@ -10,7 +10,8 @@ static int onTimer(SP<CEventLoopTimer> self, void* data) {
10
10
return 0 ;
11
11
}
12
12
13
- CExtIdleNotification::CExtIdleNotification (SP<CExtIdleNotificationV1> resource_, uint32_t timeoutMs_) : resource(resource_), timeoutMs(timeoutMs_) {
13
+ CExtIdleNotification::CExtIdleNotification (SP<CExtIdleNotificationV1> resource_, uint32_t timeoutMs_, bool obeyInhibitors_) :
14
+ resource(resource_), timeoutMs(timeoutMs_), obeyInhibitors(obeyInhibitors_) {
14
15
if UNLIKELY (!resource_->resource ())
15
16
return ;
16
17
@@ -35,7 +36,7 @@ bool CExtIdleNotification::good() {
35
36
}
36
37
37
38
void CExtIdleNotification::updateTimer () {
38
- if (PROTO::idle->isInhibited )
39
+ if (PROTO::idle->isInhibited && obeyInhibitors )
39
40
timer->updateTimeout (std::nullopt);
40
41
else
41
42
timer->updateTimeout (std::chrono::milliseconds (timeoutMs));
@@ -54,6 +55,10 @@ void CExtIdleNotification::onActivity() {
54
55
updateTimer ();
55
56
}
56
57
58
+ bool CExtIdleNotification::inhibitorsAreObeyed () const {
59
+ return obeyInhibitors;
60
+ }
61
+
57
62
CIdleNotifyProtocol::CIdleNotifyProtocol (const wl_interface* iface, const int & ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
58
63
;
59
64
}
@@ -63,7 +68,10 @@ void CIdleNotifyProtocol::bindManager(wl_client* client, void* data, uint32_t ve
63
68
RESOURCE->setOnDestroy ([this ](CExtIdleNotifierV1* p) { this ->onManagerResourceDestroy (p->resource ()); });
64
69
65
70
RESOURCE->setDestroy ([this ](CExtIdleNotifierV1* pMgr) { this ->onManagerResourceDestroy (pMgr->resource ()); });
66
- RESOURCE->setGetIdleNotification ([this ](CExtIdleNotifierV1* pMgr, uint32_t id, uint32_t timeout, wl_resource* seat) { this ->onGetNotification (pMgr, id, timeout, seat); });
71
+ RESOURCE->setGetIdleNotification (
72
+ [this ](CExtIdleNotifierV1* pMgr, uint32_t id, uint32_t timeout, wl_resource* seat) { this ->onGetNotification (pMgr, id, timeout, seat, true ); });
73
+ RESOURCE->setGetInputIdleNotification (
74
+ [this ](CExtIdleNotifierV1* pMgr, uint32_t id, uint32_t timeout, wl_resource* seat) { this ->onGetNotification (pMgr, id, timeout, seat, false ); });
67
75
}
68
76
69
77
void CIdleNotifyProtocol::onManagerResourceDestroy (wl_resource* res) {
@@ -74,9 +82,10 @@ void CIdleNotifyProtocol::destroyNotification(CExtIdleNotification* notif) {
74
82
std::erase_if (m_vNotifications, [&](const auto & other) { return other.get () == notif; });
75
83
}
76
84
77
- void CIdleNotifyProtocol::onGetNotification (CExtIdleNotifierV1* pMgr, uint32_t id, uint32_t timeout, wl_resource* seat) {
78
- const auto CLIENT = pMgr->client ();
79
- const auto RESOURCE = m_vNotifications.emplace_back (makeShared<CExtIdleNotification>(makeShared<CExtIdleNotificationV1>(CLIENT, pMgr->version (), id), timeout)).get ();
85
+ void CIdleNotifyProtocol::onGetNotification (CExtIdleNotifierV1* pMgr, uint32_t id, uint32_t timeout, wl_resource* seat, bool obeyInhibitors) {
86
+ const auto CLIENT = pMgr->client ();
87
+ const auto RESOURCE =
88
+ m_vNotifications.emplace_back (makeShared<CExtIdleNotification>(makeShared<CExtIdleNotificationV1>(CLIENT, pMgr->version (), id), timeout, obeyInhibitors)).get ();
80
89
81
90
if UNLIKELY (!RESOURCE->good ()) {
82
91
pMgr->noMemory ();
@@ -94,6 +103,7 @@ void CIdleNotifyProtocol::onActivity() {
94
103
void CIdleNotifyProtocol::setInhibit (bool inhibited) {
95
104
isInhibited = inhibited;
96
105
for (auto const & n : m_vNotifications) {
97
- n->onActivity ();
106
+ if (n->inhibitorsAreObeyed ())
107
+ n->onActivity ();
98
108
}
99
- }
109
+ }
0 commit comments