diff --git a/.gitmodules b/.gitmodules index 638f8ba9..8c9b9336 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,7 @@ [submodule "subprojects/hyprland-protocols"] path = subprojects/hyprland-protocols - url = https://github.com/hyprwm/hyprland-protocols + url = https://github.com/3l0w/hyprland-protocols + branch = feat/input-capture-impl [submodule "subprojects/udis86"] path = subprojects/udis86 url = https://github.com/canihavesomecoffee/udis86 diff --git a/CMakeLists.txt b/CMakeLists.txt index df919d76..a59f21d8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -337,6 +337,8 @@ protocolnew("staging/xdg-dialog" "xdg-dialog-v1" false) protocolnew("staging/single-pixel-buffer" "single-pixel-buffer-v1" false) protocolnew("staging/security-context" "security-context-v1" false) +protocolnew("subprojects/hyprland-protocols/protocols" "hyprland-input-capture-v1" + true) protocolwayland() # tools diff --git a/src/managers/PointerManager.cpp b/src/managers/PointerManager.cpp index ae90349b..ba01d2aa 100644 --- a/src/managers/PointerManager.cpp +++ b/src/managers/PointerManager.cpp @@ -9,6 +9,7 @@ #include "../protocols/core/Seat.hpp" #include "eventLoop/EventLoopManager.hpp" #include "SeatManager.hpp" +#include "protocols/InputCapture.hpp" #include #include @@ -673,6 +674,9 @@ void CPointerManager::move(const Vector2D& deltaLogical) { const auto oldPos = pointerPos; auto newPos = oldPos + Vector2D{std::isnan(deltaLogical.x) ? 0.0 : deltaLogical.x, std::isnan(deltaLogical.y) ? 0.0 : deltaLogical.y}; + + PROTO::inputCapture->sendAbsoluteMotion(newPos, deltaLogical); + warpTo(newPos); } diff --git a/src/managers/ProtocolManager.cpp b/src/managers/ProtocolManager.cpp index 601e564d..1db92b0c 100644 --- a/src/managers/ProtocolManager.cpp +++ b/src/managers/ProtocolManager.cpp @@ -47,6 +47,7 @@ #include "../protocols/SinglePixel.hpp" #include "../protocols/SecurityContext.hpp" #include "../protocols/CTMControl.hpp" +#include "../protocols/InputCapture.hpp" #include "../protocols/core/Seat.hpp" #include "../protocols/core/DataDevice.hpp" @@ -159,6 +160,7 @@ CProtocolManager::CProtocolManager() { PROTO::singlePixel = std::make_unique(&wp_single_pixel_buffer_manager_v1_interface, 1, "SinglePixel"); PROTO::securityContext = std::make_unique(&wp_security_context_manager_v1_interface, 1, "SecurityContext"); PROTO::ctm = std::make_unique(&hyprland_ctm_control_manager_v1_interface, 1, "CTMControl"); + PROTO::inputCapture = std::make_unique(&hyprland_input_capture_manager_v1_interface, 1, "InputCapture"); for (auto const& b : g_pCompositor->m_pAqBackend->getImplementations()) { if (b->type() != Aquamarine::AQ_BACKEND_DRM) @@ -232,6 +234,7 @@ CProtocolManager::~CProtocolManager() { PROTO::singlePixel.reset(); PROTO::securityContext.reset(); PROTO::ctm.reset(); + PROTO::inputCapture.reset(); PROTO::lease.reset(); PROTO::sync.reset(); diff --git a/src/protocols/InputCapture.cpp b/src/protocols/InputCapture.cpp new file mode 100644 index 00000000..889f2599 --- /dev/null +++ b/src/protocols/InputCapture.cpp @@ -0,0 +1,33 @@ +#include "InputCapture.hpp" +#include "hyprland-input-capture-v1.hpp" +#include +#include +#include + +CInputCaptureProtocol::CInputCaptureProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { + ; +} + +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->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) {} + +void CInputCaptureProtocol::onRelease(CHyprlandInputCaptureManagerV1* pMgr) {} + +void CInputCaptureProtocol::sendAbsoluteMotion(const Vector2D& absolutePosition, const Vector2D& delta) { + for (const UP& manager : m_vManagers) { + manager->sendAbsoluteMotion(wl_fixed_from_double(absolutePosition.x), wl_fixed_from_double(absolutePosition.y), wl_fixed_from_double(delta.x), + wl_fixed_from_double(delta.y)); + } +} diff --git a/src/protocols/InputCapture.hpp b/src/protocols/InputCapture.hpp new file mode 100644 index 00000000..172c17dc --- /dev/null +++ b/src/protocols/InputCapture.hpp @@ -0,0 +1,23 @@ +#pragma once + +#include "WaylandProtocol.hpp" +#include "hyprland-input-capture-v1.hpp" +#include + +class CInputCaptureProtocol : public IWaylandProtocol { + public: + 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); + void sendAbsoluteMotion(const Vector2D& absolutePosition, const Vector2D& delta); + + private: + void onManagerResourceDestroy(wl_resource* res); + void onCapture(CHyprlandInputCaptureManagerV1* pMgr); + void onRelease(CHyprlandInputCaptureManagerV1* pMgr); + + std::vector> m_vManagers; +}; + +namespace PROTO { + inline UP inputCapture; +} diff --git a/src/protocols/core/Output.cpp b/src/protocols/core/Output.cpp index e9f35abc..dbeb67fa 100644 --- a/src/protocols/core/Output.cpp +++ b/src/protocols/core/Output.cpp @@ -74,6 +74,8 @@ void CWLOutputResource::updateState() { if (resource->version() >= 2) resource->sendScale(std::ceil(monitor->scale)); + resource->sendGeometry(monitor->vecPosition.x, monitor->vecPosition.y, monitor->output->physicalSize.x, monitor->output->physicalSize.y, (wl_output_subpixel)monitor->output->subpixel, monitor->output->make.c_str(), + monitor->output->model.c_str(), monitor->transform); resource->sendMode((wl_output_mode)(WL_OUTPUT_MODE_CURRENT), monitor->vecPixelSize.x, monitor->vecPixelSize.y, monitor->refreshRate * 1000.0); resource->sendGeometry(0, 0, monitor->output->physicalSize.x, monitor->output->physicalSize.y, (wl_output_subpixel)monitor->output->subpixel, monitor->output->make.c_str(), diff --git a/subprojects/hyprland-protocols b/subprojects/hyprland-protocols index c7c3f4cd..1c4de2b2 160000 --- a/subprojects/hyprland-protocols +++ b/subprojects/hyprland-protocols @@ -1 +1 @@ -Subproject commit c7c3f4cd0faed21fc90ba6bd06fe4f3e0e057ea8 +Subproject commit 1c4de2b22b9a7100ca664e46e37e29b0b724ce97