diff options
| author | J. J. Ramsey <jjramsey@users.noreply.github.com> | 2025-02-11 09:58:43 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-11 15:58:43 +0100 |
| commit | f83fe9986b34c53c67b113a015d54fe8c084e9bd (patch) | |
| tree | 77c9a5e76b5666138b98c487a275390da0489884 /src | |
| parent | f2d43e5f2180adb81b3b7b51a7d0f39dace70b05 (diff) | |
protocols: add version 2 of ext-idle-notify-v1 protocol (#8959)
Signed-off-by: James Ramsey <james.jehiel.ramsey@gmail.com>
Co-authored-by: James Ramsey <james.jehiel.ramsey@gmail.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/managers/ProtocolManager.cpp | 2 | ||||
| -rw-r--r-- | src/protocols/IdleNotify.cpp | 26 | ||||
| -rw-r--r-- | src/protocols/IdleNotify.hpp | 9 |
3 files changed, 25 insertions, 12 deletions
diff --git a/src/managers/ProtocolManager.cpp b/src/managers/ProtocolManager.cpp index 6cd3a608..6474d661 100644 --- a/src/managers/ProtocolManager.cpp +++ b/src/managers/ProtocolManager.cpp @@ -147,7 +147,7 @@ CProtocolManager::CProtocolManager() { PROTO::constraints = makeUnique<CPointerConstraintsProtocol>(&zwp_pointer_constraints_v1_interface, 1, "PointerConstraints"); PROTO::outputPower = makeUnique<COutputPowerProtocol>(&zwlr_output_power_manager_v1_interface, 1, "OutputPower"); PROTO::activation = makeUnique<CXDGActivationProtocol>(&xdg_activation_v1_interface, 1, "XDGActivation"); - PROTO::idle = makeUnique<CIdleNotifyProtocol>(&ext_idle_notifier_v1_interface, 1, "IdleNotify"); + PROTO::idle = makeUnique<CIdleNotifyProtocol>(&ext_idle_notifier_v1_interface, 2, "IdleNotify"); PROTO::lockNotify = makeUnique<CLockNotifyProtocol>(&hyprland_lock_notifier_v1_interface, 1, "IdleNotify"); PROTO::sessionLock = makeUnique<CSessionLockProtocol>(&ext_session_lock_manager_v1_interface, 1, "SessionLock"); PROTO::ime = makeUnique<CInputMethodV2Protocol>(&zwp_input_method_manager_v2_interface, 1, "IMEv2"); diff --git a/src/protocols/IdleNotify.cpp b/src/protocols/IdleNotify.cpp index bc5aabb1..14a5f3e1 100644 --- a/src/protocols/IdleNotify.cpp +++ b/src/protocols/IdleNotify.cpp @@ -10,7 +10,8 @@ static int onTimer(SP<CEventLoopTimer> self, void* data) { return 0; } -CExtIdleNotification::CExtIdleNotification(SP<CExtIdleNotificationV1> resource_, uint32_t timeoutMs_) : resource(resource_), timeoutMs(timeoutMs_) { +CExtIdleNotification::CExtIdleNotification(SP<CExtIdleNotificationV1> resource_, uint32_t timeoutMs_, bool obeyInhibitors_) : + resource(resource_), timeoutMs(timeoutMs_), obeyInhibitors(obeyInhibitors_) { if UNLIKELY (!resource_->resource()) return; @@ -35,7 +36,7 @@ bool CExtIdleNotification::good() { } void CExtIdleNotification::updateTimer() { - if (PROTO::idle->isInhibited) + if (PROTO::idle->isInhibited && obeyInhibitors) timer->updateTimeout(std::nullopt); else timer->updateTimeout(std::chrono::milliseconds(timeoutMs)); @@ -54,6 +55,10 @@ void CExtIdleNotification::onActivity() { updateTimer(); } +bool CExtIdleNotification::inhibitorsAreObeyed() const { + return obeyInhibitors; +} + CIdleNotifyProtocol::CIdleNotifyProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { ; } @@ -63,7 +68,10 @@ void CIdleNotifyProtocol::bindManager(wl_client* client, void* data, uint32_t ve RESOURCE->setOnDestroy([this](CExtIdleNotifierV1* p) { this->onManagerResourceDestroy(p->resource()); }); RESOURCE->setDestroy([this](CExtIdleNotifierV1* pMgr) { this->onManagerResourceDestroy(pMgr->resource()); }); - RESOURCE->setGetIdleNotification([this](CExtIdleNotifierV1* pMgr, uint32_t id, uint32_t timeout, wl_resource* seat) { this->onGetNotification(pMgr, id, timeout, seat); }); + RESOURCE->setGetIdleNotification( + [this](CExtIdleNotifierV1* pMgr, uint32_t id, uint32_t timeout, wl_resource* seat) { this->onGetNotification(pMgr, id, timeout, seat, true); }); + RESOURCE->setGetInputIdleNotification( + [this](CExtIdleNotifierV1* pMgr, uint32_t id, uint32_t timeout, wl_resource* seat) { this->onGetNotification(pMgr, id, timeout, seat, false); }); } void CIdleNotifyProtocol::onManagerResourceDestroy(wl_resource* res) { @@ -74,9 +82,10 @@ void CIdleNotifyProtocol::destroyNotification(CExtIdleNotification* notif) { std::erase_if(m_vNotifications, [&](const auto& other) { return other.get() == notif; }); } -void CIdleNotifyProtocol::onGetNotification(CExtIdleNotifierV1* pMgr, uint32_t id, uint32_t timeout, wl_resource* seat) { - const auto CLIENT = pMgr->client(); - const auto RESOURCE = m_vNotifications.emplace_back(makeShared<CExtIdleNotification>(makeShared<CExtIdleNotificationV1>(CLIENT, pMgr->version(), id), timeout)).get(); +void CIdleNotifyProtocol::onGetNotification(CExtIdleNotifierV1* pMgr, uint32_t id, uint32_t timeout, wl_resource* seat, bool obeyInhibitors) { + const auto CLIENT = pMgr->client(); + const auto RESOURCE = + m_vNotifications.emplace_back(makeShared<CExtIdleNotification>(makeShared<CExtIdleNotificationV1>(CLIENT, pMgr->version(), id), timeout, obeyInhibitors)).get(); if UNLIKELY (!RESOURCE->good()) { pMgr->noMemory(); @@ -94,6 +103,7 @@ void CIdleNotifyProtocol::onActivity() { void CIdleNotifyProtocol::setInhibit(bool inhibited) { isInhibited = inhibited; for (auto const& n : m_vNotifications) { - n->onActivity(); + if (n->inhibitorsAreObeyed()) + n->onActivity(); } -}
\ No newline at end of file +} diff --git a/src/protocols/IdleNotify.hpp b/src/protocols/IdleNotify.hpp index e3dcdc98..efc3accc 100644 --- a/src/protocols/IdleNotify.hpp +++ b/src/protocols/IdleNotify.hpp @@ -9,19 +9,22 @@ class CEventLoopTimer; class CExtIdleNotification { public: - CExtIdleNotification(SP<CExtIdleNotificationV1> resource_, uint32_t timeoutMs); + CExtIdleNotification(SP<CExtIdleNotificationV1> resource_, uint32_t timeoutMs, bool obeyInhibitors); ~CExtIdleNotification(); bool good(); void onTimerFired(); void onActivity(); + bool inhibitorsAreObeyed() const; + private: SP<CExtIdleNotificationV1> resource; uint32_t timeoutMs = 0; SP<CEventLoopTimer> timer; - bool idled = false; + bool idled = false; + bool obeyInhibitors = false; void updateTimer(); }; @@ -38,7 +41,7 @@ class CIdleNotifyProtocol : public IWaylandProtocol { private: void onManagerResourceDestroy(wl_resource* res); void destroyNotification(CExtIdleNotification* notif); - void onGetNotification(CExtIdleNotifierV1* pMgr, uint32_t id, uint32_t timeout, wl_resource* seat); + void onGetNotification(CExtIdleNotifierV1* pMgr, uint32_t id, uint32_t timeout, wl_resource* seat, bool obeyInhibitors); bool isInhibited = false; |
