#pragma once #include #include #include #include "WaylandProtocol.hpp" #include "wlr-data-control-unstable-v1.hpp" #include "types/DataDevice.hpp" class CWLRDataControlManagerResource; class CWLRDataSource; class CWLRDataDevice; class CWLRDataOffer; class CWLRDataOffer { public: CWLRDataOffer(SP resource_, SP source); bool good(); void sendData(); bool dead = false; WP source; private: SP resource; friend class CWLRDataDevice; }; class CWLRDataSource : public IDataSource { public: CWLRDataSource(SP resource_, SP device_); ~CWLRDataSource(); static SP fromResource(wl_resource*); bool good(); virtual std::vector mimes(); virtual void send(const std::string& mime, uint32_t fd); virtual void accepted(const std::string& mime); virtual void cancelled(); virtual void error(uint32_t code, const std::string& msg); std::vector mimeTypes; WP self; WP device; private: SP resource; }; class CWLRDataDevice { public: CWLRDataDevice(SP resource_); bool good(); wl_client* client(); void sendInitialSelections(); void sendDataOffer(SP offer); void sendSelection(SP selection); WP self; private: SP resource; wl_client* pClient = nullptr; friend class CDataDeviceWLRProtocol; }; class CWLRDataControlManagerResource { public: CWLRDataControlManagerResource(SP resource_); bool good(); WP device; std::vector> sources; private: SP resource; }; class CDataDeviceWLRProtocol : public IWaylandProtocol { public: CDataDeviceWLRProtocol(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(CWLRDataControlManagerResource* resource); void destroyResource(CWLRDataSource* resource); void destroyResource(CWLRDataDevice* resource); void destroyResource(CWLRDataOffer* resource); // std::vector> m_vManagers; std::vector> m_vSources; std::vector> m_vDevices; std::vector> m_vOffers; // void setSelection(SP source); void sendSelectionToDevice(SP dev, SP sel); // SP dataDeviceForClient(wl_client*); friend class CSeatManager; friend class CWLRDataControlManagerResource; friend class CWLRDataSource; friend class CWLRDataDevice; friend class CWLRDataOffer; }; namespace PROTO { inline UP dataWlr; };