From dde3e082c96cd6987420556bfc430cd5b8e0980c Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Wed, 1 Jan 2025 15:34:02 -0800 Subject: protocols: add hyprland_surface_v1 implementation (#8877) --- src/protocols/HyprlandSurface.hpp | 54 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/protocols/HyprlandSurface.hpp (limited to 'src/protocols/HyprlandSurface.hpp') diff --git a/src/protocols/HyprlandSurface.hpp b/src/protocols/HyprlandSurface.hpp new file mode 100644 index 00000000..f67de115 --- /dev/null +++ b/src/protocols/HyprlandSurface.hpp @@ -0,0 +1,54 @@ +#pragma once + +#include +#include +#include +#include "WaylandProtocol.hpp" +#include "hyprland-surface-v1.hpp" +#include "../helpers/signal/Signal.hpp" + +class CWLSurfaceResource; +class CHyprlandSurfaceProtocol; + +class CHyprlandSurface { + public: + CHyprlandSurface(SP resource, SP surface); + + bool good() const; + void setResource(SP resource); + + private: + SP m_pResource; + WP m_pSurface; + float m_fOpacity = 1.0; + + void destroy(); + + struct { + CHyprSignalListener surfaceCommitted; + CHyprSignalListener surfaceDestroyed; + } listeners; + + friend class CHyprlandSurfaceProtocol; +}; + +class CHyprlandSurfaceProtocol : public IWaylandProtocol { + public: + CHyprlandSurfaceProtocol(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); + + private: + void destroyManager(CHyprlandSurfaceManagerV1* res); + void destroySurface(CHyprlandSurface* surface); + void getSurface(CHyprlandSurfaceManagerV1* manager, uint32_t id, SP surface); + + std::vector> m_vManagers; + std::unordered_map, UP> m_mSurfaces; + + friend class CHyprlandSurface; +}; + +namespace PROTO { + inline UP hyprlandSurface; +} -- cgit v1.2.3