#pragma once #include "WaylandProtocol.hpp" #include "hyprland-focus-grab-v1.hpp" #include "macros.hpp" #include #include #include #include "../helpers/signal/Signal.hpp" class CFocusGrab; class CSeatGrab; class CWLSurfaceResource; class CFocusGrabSurfaceState { public: CFocusGrabSurfaceState(CFocusGrab* grab, SP surface); ~CFocusGrabSurfaceState(); enum State { PendingAddition, PendingRemoval, Comitted, } state = PendingAddition; private: struct { CHyprSignalListener destroy; } listeners; }; class CFocusGrab { public: CFocusGrab(SP resource_); ~CFocusGrab(); bool good(); bool isSurfaceComitted(SP surface); void start(); void finish(bool sendCleared); private: void addSurface(SP surface); void removeSurface(SP surface); void eraseSurface(SP surface); void refocusKeyboard(); void commit(bool removeOnly = false); SP resource; std::unordered_map, UP> m_mSurfaces; SP grab; bool m_bGrabActive = false; friend class CFocusGrabSurfaceState; }; class CFocusGrabProtocol : public IWaylandProtocol { public: CFocusGrabProtocol(const wl_interface* iface, const int& var, const std::string& name); virtual void bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id); private: void onManagerResourceDestroy(wl_resource* res); void destroyGrab(CFocusGrab* grab); void onCreateGrab(CHyprlandFocusGrabManagerV1* pMgr, uint32_t id); std::vector> m_vManagers; std::vector> m_vGrabs; friend class CFocusGrab; }; namespace PROTO { inline UP focusGrab; }