#pragma once #include #include #include "WaylandProtocol.hpp" #include "primary-selection-unstable-v1.hpp" #include "types/DataDevice.hpp" #include class CPrimarySelectionOffer; class CPrimarySelectionSource; class CPrimarySelectionDevice; class CPrimarySelectionManager; class CPrimarySelectionOffer { public: CPrimarySelectionOffer(SP resource_, SP source_); bool good(); void sendData(); bool m_dead = false; WP m_source; private: SP m_resource; friend class CPrimarySelectionDevice; }; class CPrimarySelectionSource : public IDataSource { public: CPrimarySelectionSource(SP resource_, SP device_); ~CPrimarySelectionSource(); static SP fromResource(wl_resource*); bool good(); virtual std::vector mimes(); virtual void send(const std::string& mime, Hyprutils::OS::CFileDescriptor fd); virtual void accepted(const std::string& mime); virtual void cancelled(); virtual void error(uint32_t code, const std::string& msg); std::vector m_mimeTypes; WP m_self; WP m_device; private: SP m_resource; }; class CPrimarySelectionDevice { public: CPrimarySelectionDevice(SP resource_); bool good(); wl_client* client(); void sendDataOffer(SP offer); void sendSelection(SP selection); WP m_self; private: SP m_resource; wl_client* m_client = nullptr; friend class CPrimarySelectionProtocol; }; class CPrimarySelectionManager { public: CPrimarySelectionManager(SP resource_); bool good(); WP m_device; std::vector> m_sources; private: SP m_resource; }; class CPrimarySelectionProtocol : public IWaylandProtocol { public: CPrimarySelectionProtocol(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 destroyResource(CPrimarySelectionManager* resource); void destroyResource(CPrimarySelectionDevice* resource); void destroyResource(CPrimarySelectionSource* resource); void destroyResource(CPrimarySelectionOffer* resource); // std::vector> m_managers; std::vector> m_devices; std::vector> m_sources; std::vector> m_offers; // void setSelection(SP source); void sendSelectionToDevice(SP dev, SP sel); void updateSelection(); void onPointerFocus(); // SP dataDeviceForClient(wl_client*); friend class CPrimarySelectionManager; friend class CPrimarySelectionDevice; friend class CPrimarySelectionSource; friend class CPrimarySelectionOffer; friend class CSeatManager; struct { CHyprSignalListener onPointerFocusChange; } m_listeners; }; namespace PROTO { inline UP primarySelection; };