From 741c75d907916d760163f910e65186d410e27874 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Mon, 22 Apr 2024 18:21:03 +0100 Subject: gamma-control: move to new impl --- src/protocols/GammaControl.hpp | 58 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 src/protocols/GammaControl.hpp (limited to 'src/protocols/GammaControl.hpp') diff --git a/src/protocols/GammaControl.hpp b/src/protocols/GammaControl.hpp new file mode 100644 index 00000000..074a51f0 --- /dev/null +++ b/src/protocols/GammaControl.hpp @@ -0,0 +1,58 @@ +#pragma once + +#include +#include +#include +#include "WaylandProtocol.hpp" +#include "wlr-gamma-control-unstable-v1.hpp" +#include "../helpers/signal/Listener.hpp" + +class CMonitor; + +class CGammaControl { + public: + CGammaControl(SP resource_, wl_resource* output); + ~CGammaControl(); + + bool good(); + void applyToMonitor(); + CMonitor* getMonitor(); + + private: + SP resource; + CMonitor* pMonitor = nullptr; + size_t gammaSize = 0; + bool gammaTableSet = false; + std::vector gammaTable; + + void onMonitorDestroy(); + + struct { + CHyprSignalListener monitorDisconnect; + CHyprSignalListener monitorDestroy; + } listeners; +}; + +class CGammaControlProtocol : public IWaylandProtocol { + public: + CGammaControlProtocol(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 applyGammaToState(CMonitor* pMonitor); + + private: + void onManagerResourceDestroy(wl_resource* res); + void destroyGammaControl(CGammaControl* gamma); + void onGetGammaControl(CZwlrGammaControlManagerV1* pMgr, uint32_t id, wl_resource* output); + + // + std::vector> m_vManagers; + std::vector> m_vGammaControllers; + + friend class CGammaControl; +}; + +namespace PROTO { + inline UP gamma; +}; -- cgit v1.2.3