From 63c56bad6fcc55f99d1437da7cd1b0b68fd9cc88 Mon Sep 17 00:00:00 2001 From: Chris Naporlee <55722668+chrisn731@users.noreply.github.com> Date: Mon, 23 Mar 2026 19:08:58 -0400 Subject: protocols: reimplement unstable/xdg-foreign-v2 (#13716) --- src/protocols/XDGForeignV2.hpp | 92 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 src/protocols/XDGForeignV2.hpp (limited to 'src/protocols/XDGForeignV2.hpp') diff --git a/src/protocols/XDGForeignV2.hpp b/src/protocols/XDGForeignV2.hpp new file mode 100644 index 00000000..78c8dbf7 --- /dev/null +++ b/src/protocols/XDGForeignV2.hpp @@ -0,0 +1,92 @@ +#include +#include +#include +#include +#include +#include "WaylandProtocol.hpp" +#include "xdg-foreign-unstable-v2.hpp" +#include "../helpers/signal/Signal.hpp" + +class CXDGImportedResourceV2; +class CWLSurface; +class CXDGToplevelResource; + +class CXDGExportedResourceV2 { + public: + CXDGExportedResourceV2(SP resource_, SP surface_, const std::string& handle); + ~CXDGExportedResourceV2(); + + struct { + CSignalT<> destroy; + } m_events; + + bool good() const; + std::string_view handle() const; + WP xdgSurf() const; + + private: + bool m_topLevelDestroyed = false; + struct { + CHyprSignalListener topLevelDestroyed; + } m_listeners; + SP m_resource; + WP m_toplevel; + std::string m_handle; + + friend class CXDGForeignExporterProtocolV2; +}; + +// zxdg_imported_v2 +class CXDGImportedResourceV2 { + public: + CXDGImportedResourceV2(SP resource, SP exported, const std::string& handle); + ~CXDGImportedResourceV2(); + + private: + SP m_resource; + WP m_exported; + std::string m_handle; + + struct { + CHyprSignalListener exportedDestroyed; + } m_listeners; + + friend class CXDGForeignImporterProtocolV2; +}; + +class CXDGForeignExporterProtocolV2 : public IWaylandProtocol { + public: + CXDGForeignExporterProtocolV2(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) override; + + SP getExported(const std::string& handle) const; + + private: + void destroyExported(CXDGExportedResourceV2*); + void onExporterDestroyed(CZxdgExporterV2*); + std::vector> m_exporters; + std::unordered_map> m_exported; + + friend class CXDGExportedResourceV2; +}; + +class CXDGForeignImporterProtocolV2 : public IWaylandProtocol { + public: + CXDGForeignImporterProtocolV2(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) override; + + private: + void destroyImported(CXDGImportedResourceV2*); + void onImporterDestroyed(CZxdgImporterV2*); + std::vector> m_importers; + std::vector> m_imports; + + friend class CXDGImportedResourceV2; +}; + +namespace PROTO { + inline UP xdgForeignExporter; + inline UP xdgForeignImporter; +}; \ No newline at end of file -- cgit v1.2.3