#pragma once #include #include #include #include "WaylandProtocol.hpp" #include "ext-session-lock-v1.hpp" #include "../helpers/signal/Signal.hpp" class CMonitor; class CSessionLock; class CWLSurfaceResource; class CSessionLockSurface { public: CSessionLockSurface(SP resource_, SP surface_, CMonitor* pMonitor_, WP owner_); ~CSessionLockSurface(); bool good(); bool inert(); CMonitor* monitor(); SP surface(); struct { CSignal map; CSignal destroy; CSignal commit; } events; private: SP resource; WP sessionLock; WP pSurface; CMonitor* pMonitor = nullptr; bool ackdConfigure = false; bool committed = false; void sendConfigure(); struct { CHyprSignalListener monitorMode; CHyprSignalListener surfaceCommit; CHyprSignalListener surfaceDestroy; } listeners; }; class CSessionLock { public: CSessionLock(SP resource_); ~CSessionLock(); bool good(); void sendLocked(); void sendDenied(); 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; };