From d9fe1d0f58bcafd22ee23097de41e7039a36afe2 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Sun, 21 Apr 2024 16:29:30 +0100 Subject: idle-inhibit: move to new impl --- src/protocols/IdleInhibit.hpp | 63 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 src/protocols/IdleInhibit.hpp (limited to 'src/protocols/IdleInhibit.hpp') diff --git a/src/protocols/IdleInhibit.hpp b/src/protocols/IdleInhibit.hpp new file mode 100644 index 00000000..3283333f --- /dev/null +++ b/src/protocols/IdleInhibit.hpp @@ -0,0 +1,63 @@ +#pragma once + +#include +#include +#include "WaylandProtocol.hpp" +#include "idle-inhibit-unstable-v1.hpp" +#include "../helpers/signal/Signal.hpp" + +class CIdleInhibitorResource; + +class CIdleInhibitor { + public: + CIdleInhibitor(SP resource_, wlr_surface* surf_); + + struct { + CHyprSignalListener destroy; + } listeners; + + WP resource; + wlr_surface* surface = nullptr; +}; + +class CIdleInhibitorResource { + public: + CIdleInhibitorResource(SP resource_, wlr_surface* surface_); + ~CIdleInhibitorResource(); + + SP inhibitor; + + struct { + CSignal destroy; + } events; + + private: + SP resource; + wlr_surface* surface = nullptr; + + DYNLISTENER(surfaceDestroy); +}; + +class CIdleInhibitProtocol : public IWaylandProtocol { + public: + CIdleInhibitProtocol(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 onManagerResourceDestroy(wl_resource* res); + void onCreateInhibitor(CZwpIdleInhibitManagerV1* pMgr, uint32_t id, wlr_surface* surface); + + void removeInhibitor(CIdleInhibitorResource*); + + struct { + CSignal newIdleInhibitor; // data: SP + } events; + + private: + std::vector> m_vManagers; + std::vector> m_vInhibitors; +}; + +namespace PROTO { + inline UP idleInhibit; +} \ No newline at end of file -- cgit v1.2.3