WIP: input capture

This commit is contained in:
Gwilherm Folliot 2024-09-23 11:12:55 +02:00
parent 08cc063e17
commit 057f00bf8f
No known key found for this signature in database
GPG key ID: 90236D3623DCD660
8 changed files with 70 additions and 2 deletions

3
.gitmodules vendored
View file

@ -1,6 +1,7 @@
[submodule "subprojects/hyprland-protocols"] [submodule "subprojects/hyprland-protocols"]
path = 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"] [submodule "subprojects/udis86"]
path = subprojects/udis86 path = subprojects/udis86
url = https://github.com/canihavesomecoffee/udis86 url = https://github.com/canihavesomecoffee/udis86

View file

@ -337,6 +337,8 @@ protocolnew("staging/xdg-dialog" "xdg-dialog-v1" false)
protocolnew("staging/single-pixel-buffer" "single-pixel-buffer-v1" false) protocolnew("staging/single-pixel-buffer" "single-pixel-buffer-v1" false)
protocolnew("staging/security-context" "security-context-v1" false) protocolnew("staging/security-context" "security-context-v1" false)
protocolnew("subprojects/hyprland-protocols/protocols" "hyprland-input-capture-v1"
true)
protocolwayland() protocolwayland()
# tools # tools

View file

@ -9,6 +9,7 @@
#include "../protocols/core/Seat.hpp" #include "../protocols/core/Seat.hpp"
#include "eventLoop/EventLoopManager.hpp" #include "eventLoop/EventLoopManager.hpp"
#include "SeatManager.hpp" #include "SeatManager.hpp"
#include "protocols/InputCapture.hpp"
#include <cstring> #include <cstring>
#include <gbm.h> #include <gbm.h>
@ -673,6 +674,9 @@ void CPointerManager::move(const Vector2D& deltaLogical) {
const auto oldPos = pointerPos; const auto oldPos = pointerPos;
auto newPos = oldPos + Vector2D{std::isnan(deltaLogical.x) ? 0.0 : deltaLogical.x, std::isnan(deltaLogical.y) ? 0.0 : deltaLogical.y}; 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); warpTo(newPos);
} }

View file

@ -47,6 +47,7 @@
#include "../protocols/SinglePixel.hpp" #include "../protocols/SinglePixel.hpp"
#include "../protocols/SecurityContext.hpp" #include "../protocols/SecurityContext.hpp"
#include "../protocols/CTMControl.hpp" #include "../protocols/CTMControl.hpp"
#include "../protocols/InputCapture.hpp"
#include "../protocols/core/Seat.hpp" #include "../protocols/core/Seat.hpp"
#include "../protocols/core/DataDevice.hpp" #include "../protocols/core/DataDevice.hpp"
@ -159,6 +160,7 @@ CProtocolManager::CProtocolManager() {
PROTO::singlePixel = std::make_unique<CSinglePixelProtocol>(&wp_single_pixel_buffer_manager_v1_interface, 1, "SinglePixel"); PROTO::singlePixel = std::make_unique<CSinglePixelProtocol>(&wp_single_pixel_buffer_manager_v1_interface, 1, "SinglePixel");
PROTO::securityContext = std::make_unique<CSecurityContextProtocol>(&wp_security_context_manager_v1_interface, 1, "SecurityContext"); PROTO::securityContext = std::make_unique<CSecurityContextProtocol>(&wp_security_context_manager_v1_interface, 1, "SecurityContext");
PROTO::ctm = std::make_unique<CHyprlandCTMControlProtocol>(&hyprland_ctm_control_manager_v1_interface, 1, "CTMControl"); PROTO::ctm = std::make_unique<CHyprlandCTMControlProtocol>(&hyprland_ctm_control_manager_v1_interface, 1, "CTMControl");
PROTO::inputCapture = std::make_unique<CInputCaptureProtocol>(&hyprland_input_capture_manager_v1_interface, 1, "InputCapture");
for (auto const& b : g_pCompositor->m_pAqBackend->getImplementations()) { for (auto const& b : g_pCompositor->m_pAqBackend->getImplementations()) {
if (b->type() != Aquamarine::AQ_BACKEND_DRM) if (b->type() != Aquamarine::AQ_BACKEND_DRM)
@ -232,6 +234,7 @@ CProtocolManager::~CProtocolManager() {
PROTO::singlePixel.reset(); PROTO::singlePixel.reset();
PROTO::securityContext.reset(); PROTO::securityContext.reset();
PROTO::ctm.reset(); PROTO::ctm.reset();
PROTO::inputCapture.reset();
PROTO::lease.reset(); PROTO::lease.reset();
PROTO::sync.reset(); PROTO::sync.reset();

View file

@ -0,0 +1,33 @@
#include "InputCapture.hpp"
#include "hyprland-input-capture-v1.hpp"
#include <memory>
#include <vector>
#include <wayland-util.h>
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<CHyprlandInputCaptureManagerV1>(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<CHyprlandInputCaptureManagerV1>& 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));
}
}

View file

@ -0,0 +1,23 @@
#pragma once
#include "WaylandProtocol.hpp"
#include "hyprland-input-capture-v1.hpp"
#include <hyprutils/math/Vector2D.hpp>
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<UP<CHyprlandInputCaptureManagerV1>> m_vManagers;
};
namespace PROTO {
inline UP<CInputCaptureProtocol> inputCapture;
}

View file

@ -74,6 +74,8 @@ void CWLOutputResource::updateState() {
if (resource->version() >= 2) if (resource->version() >= 2)
resource->sendScale(std::ceil(monitor->scale)); 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->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(), resource->sendGeometry(0, 0, monitor->output->physicalSize.x, monitor->output->physicalSize.y, (wl_output_subpixel)monitor->output->subpixel, monitor->output->make.c_str(),

@ -1 +1 @@
Subproject commit c7c3f4cd0faed21fc90ba6bd06fe4f3e0e057ea8 Subproject commit 1c4de2b22b9a7100ca664e46e37e29b0b724ce97