diff --git a/src/protocols/InputCapture.cpp b/src/protocols/InputCapture.cpp index 2fa99ac2..c2cfd6f2 100644 --- a/src/protocols/InputCapture.cpp +++ b/src/protocols/InputCapture.cpp @@ -7,24 +7,16 @@ CInputCaptureProtocol::CInputCaptureProtocol(const wl_interface* iface, const in void CInputCaptureProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { const auto RESOURCE = m_vManagers.emplace_back(std::make_unique(client, ver, id)).get(); - RESOURCE->setOnDestroy([this](CHyprlandInputCaptureManagerV1* p) { this->onManagerResourceDestroy(p->resource()); }); + RESOURCE->setOnDestroy([this](CHyprlandInputCaptureManagerV1* p) { std::erase_if(m_vManagers, [&](const auto& other) { return other->resource() == p->resource(); }); }); - RESOURCE->setCapture([this](CHyprlandInputCaptureManagerV1* p) { this->onCapture(p); }); - RESOURCE->setRelease([this](CHyprlandInputCaptureManagerV1* p) { this->onRelease(p); }); -} - -void CInputCaptureProtocol::onManagerResourceDestroy(wl_resource* res) { - std::erase_if(m_vManagers, [&](const auto& other) { return other->resource() == res; }); -} - -void CInputCaptureProtocol::onCapture(CHyprlandInputCaptureManagerV1* pMgr) { - Debug::log(LOG, "[input-capture] Input captured"); - active = true; -} - -void CInputCaptureProtocol::onRelease(CHyprlandInputCaptureManagerV1* pMgr) { - Debug::log(LOG, "[input-capture] Input released"); - active = false; + RESOURCE->setCapture([this](CHyprlandInputCaptureManagerV1* p) { + Debug::log(LOG, "[input-capture] Input captured"); + active = true; + }); + RESOURCE->setRelease([this](CHyprlandInputCaptureManagerV1* p) { + Debug::log(LOG, "[input-capture] Input released"); + active = false; + }); } bool CInputCaptureProtocol::isCaptured() { @@ -32,44 +24,43 @@ bool CInputCaptureProtocol::isCaptured() { } void CInputCaptureProtocol::sendMotion(const Vector2D& absolutePosition, const Vector2D& delta) { - for (const UP& manager : m_vManagers) { - manager->sendMotion(wl_fixed_from_double(absolutePosition.x), wl_fixed_from_double(absolutePosition.y), wl_fixed_from_double(delta.x), - wl_fixed_from_double(delta.y)); + for (const auto& manager : m_vManagers) { + manager->sendMotion(wl_fixed_from_double(absolutePosition.x), wl_fixed_from_double(absolutePosition.y), wl_fixed_from_double(delta.x), wl_fixed_from_double(delta.y)); } } void CInputCaptureProtocol::sendKey(uint32_t keyCode, hyprlandInputCaptureManagerV1KeyState state) { - for (const UP& manager : m_vManagers) { + for (const auto& manager : m_vManagers) { manager->sendKey(keyCode, state); } } void CInputCaptureProtocol::sendButton(uint32_t button, hyprlandInputCaptureManagerV1ButtonState state) { - for (const UP& manager : m_vManagers) { + for (const auto& manager : m_vManagers) { manager->sendButton(button, state); } } void CInputCaptureProtocol::sendAxis(hyprlandInputCaptureManagerV1Axis axis, double value) { - for (const UP& manager : m_vManagers) { + for (const auto& manager : m_vManagers) { manager->sendAxis(axis, value); } } void CInputCaptureProtocol::sendAxisValue120(hyprlandInputCaptureManagerV1Axis axis, int32_t value120) { - for (const UP& manager : m_vManagers) { + for (const auto& manager : m_vManagers) { manager->sendAxisValue120(axis, value120); } } void CInputCaptureProtocol::sendAxisStop(hyprlandInputCaptureManagerV1Axis axis) { - for (const UP& manager : m_vManagers) { + for (const auto& manager : m_vManagers) { manager->sendAxisStop(axis); } } void CInputCaptureProtocol::sendFrame() { - for (const UP& manager : m_vManagers) { + for (const auto& manager : m_vManagers) { manager->sendFrame(); } } diff --git a/src/protocols/InputCapture.hpp b/src/protocols/InputCapture.hpp index efe69463..645c25ec 100644 --- a/src/protocols/InputCapture.hpp +++ b/src/protocols/InputCapture.hpp @@ -9,7 +9,7 @@ class CInputCaptureProtocol : public IWaylandProtocol { CInputCaptureProtocol(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); - bool isCaptured(); + bool isCaptured(); // void sendMotion(const Vector2D& absolutePosition, const Vector2D& delta); @@ -23,11 +23,6 @@ class CInputCaptureProtocol : public IWaylandProtocol { private: bool active = false; - - void onManagerResourceDestroy(wl_resource* res); - void onCapture(CHyprlandInputCaptureManagerV1* pMgr); - void onRelease(CHyprlandInputCaptureManagerV1* pMgr); - // std::vector> m_vManagers; };