From 90e1411315065ead5b5a7873be4109bdfb9f5470 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Tue, 30 Apr 2024 16:32:05 +0100 Subject: session-lock: move to new impl --- src/protocols/SessionLock.hpp | 102 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 src/protocols/SessionLock.hpp (limited to 'src/protocols/SessionLock.hpp') diff --git a/src/protocols/SessionLock.hpp b/src/protocols/SessionLock.hpp new file mode 100644 index 00000000..b5d7aed5 --- /dev/null +++ b/src/protocols/SessionLock.hpp @@ -0,0 +1,102 @@ +#pragma once + +#include +#include +#include +#include "WaylandProtocol.hpp" +#include "ext-session-lock-v1.hpp" +#include "../helpers/signal/Signal.hpp" + +class CMonitor; +class CSessionLock; + +class CSessionLockSurface { + public: + CSessionLockSurface(SP resource_, wlr_surface* surface_, CMonitor* pMonitor_, WP owner_); + ~CSessionLockSurface(); + + bool good(); + bool inert(); + CMonitor* monitor(); + wlr_surface* surface(); + + struct { + CSignal map; + CSignal destroy; + CSignal commit; + } events; + + private: + SP resource; + WP sessionLock; + wlr_surface* pSurface = nullptr; + CMonitor* pMonitor = nullptr; + + bool ackdConfigure = false; + bool committed = false; + + void sendConfigure(); + + DYNLISTENER(surfaceCommit); + DYNLISTENER(surfaceDestroy); + + struct { + CHyprSignalListener monitorMode; + } listeners; +}; + +class CSessionLock { + public: + CSessionLock(SP resource_); + ~CSessionLock(); + + bool good(); + void sendLocked(); + + struct { + CSignal newLockSurface; // SP + CSignal unlockAndDestroy; + CSignal destroyed; // fires regardless of whether there was a unlockAndDestroy or not. + } events; + + private: + SP resource; + + bool inert = false; + + friend class CSessionLockProtocol; +}; + +class CSessionLockProtocol : public IWaylandProtocol { + public: + CSessionLockProtocol(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); + + bool isLocked(); + + struct { + CSignal newLock; // SP + } events; + + private: + void onManagerResourceDestroy(wl_resource* res); + void destroyResource(CSessionLock* lock); + void destroyResource(CSessionLockSurface* surf); + void onLock(CExtSessionLockManagerV1* pMgr, uint32_t id); + void onGetLockSurface(CExtSessionLockV1* lock, uint32_t id, wl_resource* surface, wl_resource* output); + + bool locked = false; + + // + std::vector> m_vManagers; + std::vector> m_vLocks; + std::vector> m_vLockSurfaces; + + friend class CSessionLock; + friend class CSessionLockSurface; +}; + +namespace PROTO { + inline UP sessionLock; +}; -- cgit v1.2.3