diff options
| author | Vaxry <vaxry@vaxry.net> | 2024-04-29 17:42:07 +0100 |
|---|---|---|
| committer | Vaxry <vaxry@vaxry.net> | 2024-04-29 17:50:07 +0100 |
| commit | f2b03e9679bc1a091fecffd98b50a4179b5c7d43 (patch) | |
| tree | c86033d3436b0354db17e9209633ac7a6594631f /src/protocols/IdleNotify.hpp | |
| parent | 86133983a94a6ad52933e0577b6098dd8e98ed8c (diff) | |
ext-idle-notify: move to new impl
Diffstat (limited to 'src/protocols/IdleNotify.hpp')
| -rw-r--r-- | src/protocols/IdleNotify.hpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/protocols/IdleNotify.hpp b/src/protocols/IdleNotify.hpp new file mode 100644 index 00000000..c1c7b62d --- /dev/null +++ b/src/protocols/IdleNotify.hpp @@ -0,0 +1,55 @@ +#pragma once + +#include <memory> +#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); + ~CExtIdleNotification(); + + bool good(); + void onTimerFired(); + void onActivity(); + + private: + SP<CExtIdleNotificationV1> resource; + uint32_t timeoutMs = 0; + std::shared_ptr<CEventLoopTimer> timer; + + bool idled = false; + + void updateTimer(); +}; + +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); + + private: + void onManagerResourceDestroy(wl_resource* res); + void destroyNotification(CExtIdleNotification* notif); + void onGetNotification(CExtIdleNotifierV1* pMgr, uint32_t id, uint32_t timeout, wl_resource* seat); + + bool isInhibited = false; + + // + std::vector<UP<CExtIdleNotifierV1>> m_vManagers; + std::vector<SP<CExtIdleNotification>> m_vNotifications; + + friend class CExtIdleNotification; +}; + +namespace PROTO { + inline UP<CIdleNotifyProtocol> idle; +}; |
