#pragma once #include #include #include #include "WaylandProtocol.hpp" #include "drm-lease-v1.hpp" #include "../helpers/signal/Signal.hpp" /* TODO: this protocol is not made for systems with multiple DRM nodes (e.g. multigpu) */ AQUAMARINE_FORWARD(CDRMBackend); AQUAMARINE_FORWARD(CDRMLease); class CDRMLeaseDeviceResource; class CMonitor; class CDRMLeaseProtocol; class CDRMLeaseConnectorResource; class CDRMLeaseRequestResource; class CDRMLeaseResource { public: CDRMLeaseResource(SP resource_, SP request); ~CDRMLeaseResource(); bool good(); WP parent; std::vector> requested; SP lease; int leaseFD = -1; struct { CHyprSignalListener destroyLease; } listeners; private: SP resource; }; class CDRMLeaseRequestResource { public: CDRMLeaseRequestResource(SP resource_); bool good(); WP parent; WP self; std::vector> requested; private: SP resource; }; class CDRMLeaseConnectorResource { public: CDRMLeaseConnectorResource(SP resource_, SP monitor_); static SP fromResource(wl_resource*); bool good(); void sendData(); WP self; WP parent; WP monitor; bool dead = false; private: SP resource; struct { CHyprSignalListener destroyMonitor; } listeners; friend class CDRMLeaseDeviceResource; }; class CDRMLeaseDeviceResource { public: CDRMLeaseDeviceResource(SP resource_); bool good(); void sendConnector(SP monitor); std::vector> connectorsSent; WP self; private: SP resource; friend class CDRMLeaseProtocol; }; class CDRMLeaseDevice { public: CDRMLeaseDevice(SP drmBackend); std::string name = ""; bool success = false; SP backend; std::vector> offeredOutputs; }; class CDRMLeaseProtocol : public IWaylandProtocol { public: CDRMLeaseProtocol(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); void offer(SP monitor); private: void destroyResource(CDRMLeaseDeviceResource* resource); void destroyResource(CDRMLeaseConnectorResource* resource); void destroyResource(CDRMLeaseRequestResource* resource); void destroyResource(CDRMLeaseResource* resource); // std::vector> m_vManagers; std::vector> m_vConnectors; std::vector> m_vRequests; std::vector> m_vLeases; SP primaryDevice; friend class CDRMLeaseDeviceResource; friend class CDRMLeaseConnectorResource; friend class CDRMLeaseRequestResource; friend class CDRMLeaseResource; }; namespace PROTO { inline UP lease; };