summaryrefslogtreecommitdiff
path: root/src/protocols/HyprlandSurface.hpp
diff options
context:
space:
mode:
authoroutfoxxed <outfoxxed@outfoxxed.me>2025-01-01 15:34:02 -0800
committerGitHub <noreply@github.com>2025-01-01 23:34:02 +0000
commitdde3e082c96cd6987420556bfc430cd5b8e0980c (patch)
treeeb034fbc2fa747637758f09fc276887477633bfc /src/protocols/HyprlandSurface.hpp
parent9f3c9ac01a9a6ecef74429dc9a1dea250ef43c50 (diff)
protocols: add hyprland_surface_v1 implementation (#8877)
Diffstat (limited to 'src/protocols/HyprlandSurface.hpp')
-rw-r--r--src/protocols/HyprlandSurface.hpp54
1 files changed, 54 insertions, 0 deletions
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 <memory>
+#include <vector>
+#include <unordered_map>
+#include "WaylandProtocol.hpp"
+#include "hyprland-surface-v1.hpp"
+#include "../helpers/signal/Signal.hpp"
+
+class CWLSurfaceResource;
+class CHyprlandSurfaceProtocol;
+
+class CHyprlandSurface {
+ public:
+ CHyprlandSurface(SP<CHyprlandSurfaceV1> resource, SP<CWLSurfaceResource> surface);
+
+ bool good() const;
+ void setResource(SP<CHyprlandSurfaceV1> resource);
+
+ private:
+ SP<CHyprlandSurfaceV1> m_pResource;
+ WP<CWLSurfaceResource> 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<CWLSurfaceResource> surface);
+
+ std::vector<UP<CHyprlandSurfaceManagerV1>> m_vManagers;
+ std::unordered_map<WP<CWLSurfaceResource>, UP<CHyprlandSurface>> m_mSurfaces;
+
+ friend class CHyprlandSurface;
+};
+
+namespace PROTO {
+ inline UP<CHyprlandSurfaceProtocol> hyprlandSurface;
+}