From 057f00bf8ff2747e799f1cc78d0476be7c3d8b10 Mon Sep 17 00:00:00 2001 From: Gwilherm Folliot Date: Mon, 23 Sep 2024 11:12:55 +0200 Subject: [PATCH 01/10] WIP: input capture --- .gitmodules | 3 ++- CMakeLists.txt | 2 ++ src/managers/PointerManager.cpp | 4 ++++ src/managers/ProtocolManager.cpp | 3 +++ src/protocols/InputCapture.cpp | 33 ++++++++++++++++++++++++++++++++ src/protocols/InputCapture.hpp | 23 ++++++++++++++++++++++ src/protocols/core/Output.cpp | 2 ++ subprojects/hyprland-protocols | 2 +- 8 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 src/protocols/InputCapture.cpp create mode 100644 src/protocols/InputCapture.hpp diff --git a/.gitmodules b/.gitmodules index 638f8ba9776..8c9b93366c8 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 df919d7650d..a59f21d83eb 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 ae90349bb81..ba01d2aa12f 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 601e564d46b..1db92b0cd7f 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 00000000000..889f2599cd0 --- /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 00000000000..172c17dcb5f --- /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 e9f35abc26e..dbeb67fa94f 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 c7c3f4cd0fa..1c4de2b22b9 160000 --- a/subprojects/hyprland-protocols +++ b/subprojects/hyprland-protocols @@ -1 +1 @@ -Subproject commit c7c3f4cd0faed21fc90ba6bd06fe4f3e0e057ea8 +Subproject commit 1c4de2b22b9a7100ca664e46e37e29b0b724ce97 From 9a22c90741b9c9bf25a184979ea6bc5464a3fa1c Mon Sep 17 00:00:00 2001 From: Gwilherm Folliot Date: Wed, 25 Sep 2024 18:03:12 +0200 Subject: [PATCH 02/10] input-capture: impl keyboard, mouse button & mouse wheel --- src/managers/PointerManager.cpp | 1 + src/managers/input/InputManager.cpp | 22 ++++++++++++++++++ src/managers/input/InputManager.hpp | 1 + src/protocols/InputCapture.cpp | 36 +++++++++++++++++++++++++++++ src/protocols/InputCapture.hpp | 8 +++++++ subprojects/hyprland-protocols | 2 +- 6 files changed, 69 insertions(+), 1 deletion(-) diff --git a/src/managers/PointerManager.cpp b/src/managers/PointerManager.cpp index ba01d2aa12f..65929355922 100644 --- a/src/managers/PointerManager.cpp +++ b/src/managers/PointerManager.cpp @@ -677,6 +677,7 @@ void CPointerManager::move(const Vector2D& deltaLogical) { PROTO::inputCapture->sendAbsoluteMotion(newPos, deltaLogical); + //TODO: Inhibit inputs warpTo(newPos); } diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index 196f0b714d3..bcf7f01c0ac 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -19,6 +19,7 @@ #include "../../protocols/core/DataDevice.hpp" #include "../../protocols/core/Compositor.hpp" #include "../../protocols/XDGShell.hpp" +#include "../../protocols/InputCapture.hpp" #include "../../devices/Mouse.hpp" #include "../../devices/VirtualPointer.hpp" @@ -96,6 +97,7 @@ void CInputManager::onMouseMoved(IPointer::SMotionEvent e) { g_pPointerManager->move(DELTA); + //TODO: Inhibit inputs mouseMoveUnified(e.timeMs); m_tmrLastCursorMovement.reset(); @@ -531,6 +533,9 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { void CInputManager::onMouseButton(IPointer::SButtonEvent e) { EMIT_HOOK_EVENT_CANCELLABLE("mouseButton", e); + PROTO::inputCapture->sendButton(e.button, (hyprlandInputCaptureManagerV1ButtonState)e.state); + + //TODO: Inhibit inputs m_tmrLastCursorMovement.reset(); if (e.state == WL_POINTER_BUTTON_STATE_PRESSED) { @@ -763,6 +768,13 @@ void CInputManager::onMouseWheel(IPointer::SAxisEvent e) { const auto EMAP = std::unordered_map{{"event", e}}; EMIT_HOOK_EVENT_CANCELLABLE("mouseAxis", EMAP); + PROTO::inputCapture->sendAxis((hyprlandInputCaptureManagerV1Axis)e.axis, e.delta); + if (e.source == 0) + PROTO::inputCapture->sendAxisValue120((hyprlandInputCaptureManagerV1Axis)e.axis, e.delta); + else if (e.delta == 0) + PROTO::inputCapture->sendAxisStop((hyprlandInputCaptureManagerV1Axis)e.axis); + + //TODO: Inhibit inputs bool passEvent = g_pKeybindManager->onAxisEvent(e); if (!passEvent) @@ -833,6 +845,13 @@ void CInputManager::onMouseWheel(IPointer::SAxisEvent e) { g_pSeatManager->sendPointerAxis(e.timeMs, e.axis, delta, deltaDiscrete, value120, e.source, WL_POINTER_AXIS_RELATIVE_DIRECTION_IDENTICAL); } +void CInputManager::onMouseFrame() { + PROTO::inputCapture->sendFrame(); + + //TODO: Inhibit inputs + g_pSeatManager->sendPointerFrame(); +} + Vector2D CInputManager::getMouseCoordsInternal() { return g_pPointerManager->position(); } @@ -1296,6 +1315,9 @@ void CInputManager::onKeyboardKey(std::any event, SP pKeyboard) { auto e = std::any_cast(event); + //TODO: Inhibit inputs + PROTO::inputCapture->sendKey(e.keycode, (hyprlandInputCaptureManagerV1KeyState)e.state); + if (passEvent) { const auto IME = m_sIMERelay.m_pIME.lock(); diff --git a/src/managers/input/InputManager.hpp b/src/managers/input/InputManager.hpp index 10faff24139..30835c07c0a 100644 --- a/src/managers/input/InputManager.hpp +++ b/src/managers/input/InputManager.hpp @@ -87,6 +87,7 @@ class CInputManager { void onMouseWarp(IPointer::SMotionAbsoluteEvent); void onMouseButton(IPointer::SButtonEvent); void onMouseWheel(IPointer::SAxisEvent); + void onMouseFrame(); void onKeyboardKey(std::any, SP); void onKeyboardMod(SP); diff --git a/src/protocols/InputCapture.cpp b/src/protocols/InputCapture.cpp index 889f2599cd0..1d9bdecffa8 100644 --- a/src/protocols/InputCapture.cpp +++ b/src/protocols/InputCapture.cpp @@ -31,3 +31,39 @@ void CInputCaptureProtocol::sendAbsoluteMotion(const Vector2D& absolutePosition, wl_fixed_from_double(delta.y)); } } + +void CInputCaptureProtocol::sendKey(uint32_t keyCode, hyprlandInputCaptureManagerV1KeyState state) { + for (const UP& manager : m_vManagers) { + manager->sendKey(keyCode, state); + } +} + +void CInputCaptureProtocol::sendButton(uint32_t button, hyprlandInputCaptureManagerV1ButtonState state) { + for (const UP& manager : m_vManagers) { + manager->sendButton(button, state); + } +} + +void CInputCaptureProtocol::sendAxis(hyprlandInputCaptureManagerV1Axis axis, double value) { + for (const UP& manager : m_vManagers) { + manager->sendAxis(axis, value); + } +} + +void CInputCaptureProtocol::sendAxisValue120(hyprlandInputCaptureManagerV1Axis axis, int32_t value120) { + for (const UP& manager : m_vManagers) { + manager->sendAxisValue120(axis, value120); + } +} + +void CInputCaptureProtocol::sendAxisStop(hyprlandInputCaptureManagerV1Axis axis) { + for (const UP& manager : m_vManagers) { + manager->sendAxisStop(axis); + } +} + +void CInputCaptureProtocol::sendFrame() { + for (const UP& manager : m_vManagers) { + manager->sendFrame(); + } +} diff --git a/src/protocols/InputCapture.hpp b/src/protocols/InputCapture.hpp index 172c17dcb5f..639a21f157e 100644 --- a/src/protocols/InputCapture.hpp +++ b/src/protocols/InputCapture.hpp @@ -9,12 +9,20 @@ 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); void sendAbsoluteMotion(const Vector2D& absolutePosition, const Vector2D& delta); + void sendKey(uint32_t keyCode, hyprlandInputCaptureManagerV1KeyState state); + void sendButton(uint32_t button, hyprlandInputCaptureManagerV1ButtonState state); + void sendAxis(hyprlandInputCaptureManagerV1Axis axis, double value); + void sendAxisValue120(hyprlandInputCaptureManagerV1Axis axis, int32_t value120); + void sendAxisStop(hyprlandInputCaptureManagerV1Axis axis); + + void sendFrame(); private: void onManagerResourceDestroy(wl_resource* res); void onCapture(CHyprlandInputCaptureManagerV1* pMgr); void onRelease(CHyprlandInputCaptureManagerV1* pMgr); + // std::vector> m_vManagers; }; diff --git a/subprojects/hyprland-protocols b/subprojects/hyprland-protocols index 1c4de2b22b9..53a994b2efb 160000 --- a/subprojects/hyprland-protocols +++ b/subprojects/hyprland-protocols @@ -1 +1 @@ -Subproject commit 1c4de2b22b9a7100ca664e46e37e29b0b724ce97 +Subproject commit 53a994b2efbcc19862125fc9a8d5a752a24a0f20 From 98ecfe583eb159af4b67bf16ce8c4f899a2de220 Mon Sep 17 00:00:00 2001 From: Gwilherm Folliot Date: Thu, 26 Sep 2024 08:47:21 +0200 Subject: [PATCH 03/10] input-capture: inhibit inputs --- src/managers/PointerManager.cpp | 4 +++- src/managers/input/InputManager.cpp | 18 +++++++++++------- src/protocols/InputCapture.cpp | 16 +++++++++++++--- src/protocols/InputCapture.hpp | 20 +++++++++++++------- 4 files changed, 40 insertions(+), 18 deletions(-) diff --git a/src/managers/PointerManager.cpp b/src/managers/PointerManager.cpp index 65929355922..cc3671f3133 100644 --- a/src/managers/PointerManager.cpp +++ b/src/managers/PointerManager.cpp @@ -677,7 +677,9 @@ void CPointerManager::move(const Vector2D& deltaLogical) { PROTO::inputCapture->sendAbsoluteMotion(newPos, deltaLogical); - //TODO: Inhibit inputs + if (PROTO::inputCapture->isCaptured()) + return; + warpTo(newPos); } diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index bcf7f01c0ac..47f712c84a1 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -97,7 +97,9 @@ void CInputManager::onMouseMoved(IPointer::SMotionEvent e) { g_pPointerManager->move(DELTA); - //TODO: Inhibit inputs + if (PROTO::inputCapture->isCaptured()) + return; + mouseMoveUnified(e.timeMs); m_tmrLastCursorMovement.reset(); @@ -535,7 +537,9 @@ void CInputManager::onMouseButton(IPointer::SButtonEvent e) { PROTO::inputCapture->sendButton(e.button, (hyprlandInputCaptureManagerV1ButtonState)e.state); - //TODO: Inhibit inputs + if (PROTO::inputCapture->isCaptured()) + return; + m_tmrLastCursorMovement.reset(); if (e.state == WL_POINTER_BUTTON_STATE_PRESSED) { @@ -774,8 +778,7 @@ void CInputManager::onMouseWheel(IPointer::SAxisEvent e) { else if (e.delta == 0) PROTO::inputCapture->sendAxisStop((hyprlandInputCaptureManagerV1Axis)e.axis); - //TODO: Inhibit inputs - bool passEvent = g_pKeybindManager->onAxisEvent(e); + bool passEvent = !PROTO::inputCapture->isCaptured() && g_pKeybindManager->onAxisEvent(e); if (!passEvent) return; @@ -848,7 +851,9 @@ void CInputManager::onMouseWheel(IPointer::SAxisEvent e) { void CInputManager::onMouseFrame() { PROTO::inputCapture->sendFrame(); - //TODO: Inhibit inputs + if (PROTO::inputCapture->isCaptured()) + return; + g_pSeatManager->sendPointerFrame(); } @@ -1311,11 +1316,10 @@ void CInputManager::onKeyboardKey(std::any event, SP pKeyboard) { const auto EMAP = std::unordered_map{{"keyboard", pKeyboard}, {"event", event}}; EMIT_HOOK_EVENT_CANCELLABLE("keyPress", EMAP); - bool passEvent = DISALLOWACTION || g_pKeybindManager->onKeyEvent(event, pKeyboard); + bool passEvent = !PROTO::inputCapture->isCaptured() && (DISALLOWACTION || g_pKeybindManager->onKeyEvent(event, pKeyboard)); auto e = std::any_cast(event); - //TODO: Inhibit inputs PROTO::inputCapture->sendKey(e.keycode, (hyprlandInputCaptureManagerV1KeyState)e.state); if (passEvent) { diff --git a/src/protocols/InputCapture.cpp b/src/protocols/InputCapture.cpp index 1d9bdecffa8..075c551ede6 100644 --- a/src/protocols/InputCapture.cpp +++ b/src/protocols/InputCapture.cpp @@ -5,7 +5,7 @@ #include CInputCaptureProtocol::CInputCaptureProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { - ; + active = false; } void CInputCaptureProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { @@ -21,9 +21,19 @@ 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::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; +} -void CInputCaptureProtocol::onRelease(CHyprlandInputCaptureManagerV1* pMgr) {} +bool CInputCaptureProtocol::isCaptured() { + return active; +} void CInputCaptureProtocol::sendAbsoluteMotion(const Vector2D& absolutePosition, const Vector2D& delta) { for (const UP& manager : m_vManagers) { diff --git a/src/protocols/InputCapture.hpp b/src/protocols/InputCapture.hpp index 639a21f157e..07af655359c 100644 --- a/src/protocols/InputCapture.hpp +++ b/src/protocols/InputCapture.hpp @@ -8,16 +8,22 @@ 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); - void sendKey(uint32_t keyCode, hyprlandInputCaptureManagerV1KeyState state); - void sendButton(uint32_t button, hyprlandInputCaptureManagerV1ButtonState state); - void sendAxis(hyprlandInputCaptureManagerV1Axis axis, double value); - void sendAxisValue120(hyprlandInputCaptureManagerV1Axis axis, int32_t value120); - void sendAxisStop(hyprlandInputCaptureManagerV1Axis axis); - void sendFrame(); + bool isCaptured(); + + // + void sendAbsoluteMotion(const Vector2D& absolutePosition, const Vector2D& delta); + void sendKey(uint32_t keyCode, hyprlandInputCaptureManagerV1KeyState state); + void sendButton(uint32_t button, hyprlandInputCaptureManagerV1ButtonState state); + void sendAxis(hyprlandInputCaptureManagerV1Axis axis, double value); + void sendAxisValue120(hyprlandInputCaptureManagerV1Axis axis, int32_t value120); + void sendAxisStop(hyprlandInputCaptureManagerV1Axis axis); + + void sendFrame(); private: + bool active; + void onManagerResourceDestroy(wl_resource* res); void onCapture(CHyprlandInputCaptureManagerV1* pMgr); void onRelease(CHyprlandInputCaptureManagerV1* pMgr); From 36328f3f8c5fbd6b3773c1cdd2d564b5d5091b9b Mon Sep 17 00:00:00 2001 From: Gwilherm Folliot Date: Thu, 26 Sep 2024 12:06:17 +0200 Subject: [PATCH 04/10] input-capture: code cleanup --- src/protocols/InputCapture.cpp | 4 ---- src/protocols/InputCapture.hpp | 1 - 2 files changed, 5 deletions(-) diff --git a/src/protocols/InputCapture.cpp b/src/protocols/InputCapture.cpp index 075c551ede6..e8ac910ad7e 100644 --- a/src/protocols/InputCapture.cpp +++ b/src/protocols/InputCapture.cpp @@ -1,8 +1,4 @@ #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) { active = false; diff --git a/src/protocols/InputCapture.hpp b/src/protocols/InputCapture.hpp index 07af655359c..1c6685f5028 100644 --- a/src/protocols/InputCapture.hpp +++ b/src/protocols/InputCapture.hpp @@ -1,6 +1,5 @@ #pragma once -#include "WaylandProtocol.hpp" #include "hyprland-input-capture-v1.hpp" #include From 6c211d49b5ee41fd982ae729ab6e78e1d4e94a41 Mon Sep 17 00:00:00 2001 From: Gwilherm Folliot Date: Thu, 26 Sep 2024 14:09:35 +0200 Subject: [PATCH 05/10] input-capture: fix build --- src/protocols/InputCapture.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/protocols/InputCapture.hpp b/src/protocols/InputCapture.hpp index 1c6685f5028..fafe81bbc87 100644 --- a/src/protocols/InputCapture.hpp +++ b/src/protocols/InputCapture.hpp @@ -1,6 +1,7 @@ #pragma once #include "hyprland-input-capture-v1.hpp" +#include "../protocols/WaylandProtocol.hpp" #include class CInputCaptureProtocol : public IWaylandProtocol { From 124582b8d200b3ac94f614c2eb1e6f179bcb14b4 Mon Sep 17 00:00:00 2001 From: Gwilherm Folliot Date: Mon, 30 Sep 2024 12:31:31 +0200 Subject: [PATCH 06/10] input-capture: Init active property & upstream protocol changes --- src/managers/PointerManager.cpp | 3 +-- src/protocols/InputCapture.cpp | 6 +++--- src/protocols/InputCapture.hpp | 4 ++-- subprojects/hyprland-protocols | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/managers/PointerManager.cpp b/src/managers/PointerManager.cpp index cc3671f3133..4ecc362b9d0 100644 --- a/src/managers/PointerManager.cpp +++ b/src/managers/PointerManager.cpp @@ -674,8 +674,7 @@ 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); + PROTO::inputCapture->sendMotion(newPos, deltaLogical); if (PROTO::inputCapture->isCaptured()) return; diff --git a/src/protocols/InputCapture.cpp b/src/protocols/InputCapture.cpp index e8ac910ad7e..2fa99ac2a9f 100644 --- a/src/protocols/InputCapture.cpp +++ b/src/protocols/InputCapture.cpp @@ -1,7 +1,7 @@ #include "InputCapture.hpp" CInputCaptureProtocol::CInputCaptureProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { - active = false; + ; } void CInputCaptureProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { @@ -31,9 +31,9 @@ bool CInputCaptureProtocol::isCaptured() { return active; } -void CInputCaptureProtocol::sendAbsoluteMotion(const Vector2D& absolutePosition, const Vector2D& delta) { +void CInputCaptureProtocol::sendMotion(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), + 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)); } } diff --git a/src/protocols/InputCapture.hpp b/src/protocols/InputCapture.hpp index fafe81bbc87..efe69463fad 100644 --- a/src/protocols/InputCapture.hpp +++ b/src/protocols/InputCapture.hpp @@ -12,7 +12,7 @@ class CInputCaptureProtocol : public IWaylandProtocol { bool isCaptured(); // - void sendAbsoluteMotion(const Vector2D& absolutePosition, const Vector2D& delta); + void sendMotion(const Vector2D& absolutePosition, const Vector2D& delta); void sendKey(uint32_t keyCode, hyprlandInputCaptureManagerV1KeyState state); void sendButton(uint32_t button, hyprlandInputCaptureManagerV1ButtonState state); void sendAxis(hyprlandInputCaptureManagerV1Axis axis, double value); @@ -22,7 +22,7 @@ class CInputCaptureProtocol : public IWaylandProtocol { void sendFrame(); private: - bool active; + bool active = false; void onManagerResourceDestroy(wl_resource* res); void onCapture(CHyprlandInputCaptureManagerV1* pMgr); diff --git a/subprojects/hyprland-protocols b/subprojects/hyprland-protocols index 53a994b2efb..479cc226451 160000 --- a/subprojects/hyprland-protocols +++ b/subprojects/hyprland-protocols @@ -1 +1 @@ -Subproject commit 53a994b2efbcc19862125fc9a8d5a752a24a0f20 +Subproject commit 479cc226451c264396a4c442710d6b56dce2fa46 From ad6cbb0f46c59b40215e195f79c6142e08642f45 Mon Sep 17 00:00:00 2001 From: Gwilherm Folliot Date: Mon, 30 Sep 2024 17:13:37 +0200 Subject: [PATCH 07/10] input-capture: fixes --- src/protocols/InputCapture.cpp | 43 ++++++++++++++-------------------- src/protocols/InputCapture.hpp | 7 +----- 2 files changed, 18 insertions(+), 32 deletions(-) diff --git a/src/protocols/InputCapture.cpp b/src/protocols/InputCapture.cpp index 2fa99ac2a9f..c2cfd6f2d1c 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 efe69463fad..645c25ecca4 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; }; From e0321f721e23c6d45f9e3bde28f7737941cd4995 Mon Sep 17 00:00:00 2001 From: Gwilherm Folliot Date: Mon, 7 Oct 2024 14:48:52 +0200 Subject: [PATCH 08/10] input-capture: impl keymap --- src/managers/SeatManager.cpp | 2 ++ src/protocols/InputCapture.cpp | 58 ++++++++++++++++++++++++++-------- src/protocols/InputCapture.hpp | 7 ++-- subprojects/hyprland-protocols | 2 +- 4 files changed, 53 insertions(+), 16 deletions(-) diff --git a/src/managers/SeatManager.cpp b/src/managers/SeatManager.cpp index b40d6cad66f..92b1173eaa9 100644 --- a/src/managers/SeatManager.cpp +++ b/src/managers/SeatManager.cpp @@ -4,6 +4,7 @@ #include "../protocols/DataDeviceWlr.hpp" #include "../protocols/PrimarySelection.hpp" #include "../protocols/core/Compositor.hpp" +#include "../protocols/InputCapture.hpp" #include "../Compositor.hpp" #include "../devices/IKeyboard.hpp" #include "wlr-layer-shell-unstable-v1.hpp" @@ -98,6 +99,7 @@ void CSeatManager::updateActiveKeyboardData() { if (keyboard) PROTO::seat->updateRepeatInfo(keyboard->repeatRate, keyboard->repeatDelay); PROTO::seat->updateKeymap(); + PROTO::inputCapture->updateKeymap(); } void CSeatManager::setKeyboardFocus(SP surf) { diff --git a/src/protocols/InputCapture.cpp b/src/protocols/InputCapture.cpp index c2cfd6f2d1c..0381d63c60f 100644 --- a/src/protocols/InputCapture.cpp +++ b/src/protocols/InputCapture.cpp @@ -1,11 +1,15 @@ #include "InputCapture.hpp" +#include "../devices/IKeyboard.hpp" +#include "managers/SeatManager.hpp" +#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(); + const auto& RESOURCE = m_vManagers.emplace_back(std::make_unique(client, ver, id)); RESOURCE->setOnDestroy([this](CHyprlandInputCaptureManagerV1* p) { std::erase_if(m_vManagers, [&](const auto& other) { return other->resource() == p->resource(); }); }); @@ -17,50 +21,78 @@ void CInputCaptureProtocol::bindManager(wl_client* client, void* data, uint32_t Debug::log(LOG, "[input-capture] Input released"); active = false; }); + + sendKeymap(g_pSeatManager->keyboard.lock(), RESOURCE); } bool CInputCaptureProtocol::isCaptured() { return active; } +void CInputCaptureProtocol::updateKeymap() { + for (const auto& manager : m_vManagers) + sendKeymap(g_pSeatManager->keyboard.lock(), manager); +} + void CInputCaptureProtocol::sendMotion(const Vector2D& absolutePosition, const Vector2D& delta) { 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::sendKeymap(SP keyboard, const std::unique_ptr& manager) { + if (!keyboard) + return; + + hyprlandInputCaptureManagerV1KeymapFormat format; + int fd; + uint32_t size; + if (keyboard) { + format = HYPRLAND_INPUT_CAPTURE_MANAGER_V1_KEYMAP_FORMAT_XKB_V1; + fd = keyboard->xkbKeymapFD; + size = keyboard->xkbKeymapString.length() + 1; + } else { + format = HYPRLAND_INPUT_CAPTURE_MANAGER_V1_KEYMAP_FORMAT_NO_KEYMAP; + fd = open("/dev/null", O_RDONLY | O_CLOEXEC); + if (fd < 0) { + LOGM(ERR, "Failed to open /dev/null"); + return; + } + size = 0; + } + + manager->sendKeymap(format, fd, size); + + if (!keyboard) + close(fd); +} + void CInputCaptureProtocol::sendKey(uint32_t keyCode, hyprlandInputCaptureManagerV1KeyState state) { - for (const auto& manager : m_vManagers) { + for (const auto& manager : m_vManagers) manager->sendKey(keyCode, state); - } } void CInputCaptureProtocol::sendButton(uint32_t button, hyprlandInputCaptureManagerV1ButtonState state) { - for (const auto& manager : m_vManagers) { + for (const auto& manager : m_vManagers) manager->sendButton(button, state); - } } void CInputCaptureProtocol::sendAxis(hyprlandInputCaptureManagerV1Axis axis, double value) { - for (const auto& manager : m_vManagers) { + for (const auto& manager : m_vManagers) manager->sendAxis(axis, value); - } } void CInputCaptureProtocol::sendAxisValue120(hyprlandInputCaptureManagerV1Axis axis, int32_t value120) { - for (const auto& manager : m_vManagers) { + for (const auto& manager : m_vManagers) manager->sendAxisValue120(axis, value120); - } } void CInputCaptureProtocol::sendAxisStop(hyprlandInputCaptureManagerV1Axis axis) { - for (const auto& manager : m_vManagers) { + for (const auto& manager : m_vManagers) manager->sendAxisStop(axis); - } } void CInputCaptureProtocol::sendFrame() { - for (const auto& manager : m_vManagers) { + for (const auto& manager : m_vManagers) manager->sendFrame(); - } } diff --git a/src/protocols/InputCapture.hpp b/src/protocols/InputCapture.hpp index 645c25ecca4..3f174448c56 100644 --- a/src/protocols/InputCapture.hpp +++ b/src/protocols/InputCapture.hpp @@ -9,9 +9,10 @@ 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 updateKeymap(); void sendMotion(const Vector2D& absolutePosition, const Vector2D& delta); void sendKey(uint32_t keyCode, hyprlandInputCaptureManagerV1KeyState state); void sendButton(uint32_t button, hyprlandInputCaptureManagerV1ButtonState state); @@ -22,6 +23,8 @@ class CInputCaptureProtocol : public IWaylandProtocol { void sendFrame(); private: + void sendKeymap(SP keyboard, const std::unique_ptr& manager); + bool active = false; // std::vector> m_vManagers; diff --git a/subprojects/hyprland-protocols b/subprojects/hyprland-protocols index 479cc226451..d3674e1f4ea 160000 --- a/subprojects/hyprland-protocols +++ b/subprojects/hyprland-protocols @@ -1 +1 @@ -Subproject commit 479cc226451c264396a4c442710d6b56dce2fa46 +Subproject commit d3674e1f4eac730efc01c08e794a988be31ec73e From 255db256648c9747122faf45dfd9c9937cbb9d1f Mon Sep 17 00:00:00 2001 From: Gwilherm Folliot Date: Mon, 21 Oct 2024 10:27:03 +0200 Subject: [PATCH 09/10] input-capture: impl force release --- src/managers/KeybindManager.cpp | 15 +++++++++++++++ src/managers/KeybindManager.hpp | 1 + src/managers/input/InputManager.cpp | 2 +- src/protocols/InputCapture.cpp | 8 ++++++++ src/protocols/InputCapture.hpp | 2 ++ subprojects/hyprland-protocols | 2 +- 6 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 9c22fb93249..ddff64e3cb4 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -13,6 +13,7 @@ #include "eventLoop/EventLoopManager.hpp" #include "debug/Log.hpp" #include "helpers/varlist/VarList.hpp" +#include "protocols/InputCapture.hpp" #include #include @@ -126,6 +127,7 @@ CKeybindManager::CKeybindManager() { m_mDispatchers["denywindowfromgroup"] = denyWindowFromGroup; m_mDispatchers["event"] = event; m_mDispatchers["global"] = global; + m_mDispatchers["releaseinputcapture"] = releaseInputCapture; m_tScrollTimer.reset(); @@ -716,6 +718,14 @@ SDispatchResult CKeybindManager::handleKeybinds(const uint32_t modmask, const SP m_iPassPressed = (int)pressed; + // We only process the releaseinputcapture dispatcher when input capture is active + if (PROTO::inputCapture->isCaptured()) { + if (k.handler == "releaseinputcapture") + res = DISPATCHER->second(k.arg); + else + break; + } + // if the dispatchers says to pass event then we will if (k.handler == "mouse") res = DISPATCHER->second((pressed ? "1" : "0") + k.arg); @@ -2891,3 +2901,8 @@ SDispatchResult CKeybindManager::event(std::string args) { g_pEventManager->postEvent(SHyprIPCEvent{"custom", args}); return {}; } + +SDispatchResult CKeybindManager::releaseInputCapture(std::string args) { + PROTO::inputCapture->forceRelease(); + return {}; +} diff --git a/src/managers/KeybindManager.hpp b/src/managers/KeybindManager.hpp index 8981dcaf353..4abb1d6b907 100644 --- a/src/managers/KeybindManager.hpp +++ b/src/managers/KeybindManager.hpp @@ -217,6 +217,7 @@ class CKeybindManager { static SDispatchResult denyWindowFromGroup(std::string); static SDispatchResult global(std::string); static SDispatchResult event(std::string); + static SDispatchResult releaseInputCapture(std::string); friend class CCompositor; friend class CInputManager; diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index 47f712c84a1..579cf1fdda7 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -1316,7 +1316,7 @@ void CInputManager::onKeyboardKey(std::any event, SP pKeyboard) { const auto EMAP = std::unordered_map{{"keyboard", pKeyboard}, {"event", event}}; EMIT_HOOK_EVENT_CANCELLABLE("keyPress", EMAP); - bool passEvent = !PROTO::inputCapture->isCaptured() && (DISALLOWACTION || g_pKeybindManager->onKeyEvent(event, pKeyboard)); + bool passEvent = (DISALLOWACTION || g_pKeybindManager->onKeyEvent(event, pKeyboard)) && !PROTO::inputCapture->isCaptured(); auto e = std::any_cast(event); diff --git a/src/protocols/InputCapture.cpp b/src/protocols/InputCapture.cpp index 0381d63c60f..b305827e0ea 100644 --- a/src/protocols/InputCapture.cpp +++ b/src/protocols/InputCapture.cpp @@ -67,6 +67,14 @@ void CInputCaptureProtocol::sendKeymap(SP keyboard, const std::unique close(fd); } +void CInputCaptureProtocol::forceRelease() { + Debug::log(LOG, "[input-capture] Force Input released"); + active = false; + + for (const auto& manager : m_vManagers) + manager->sendForceRelease(); +} + void CInputCaptureProtocol::sendKey(uint32_t keyCode, hyprlandInputCaptureManagerV1KeyState state) { for (const auto& manager : m_vManagers) manager->sendKey(keyCode, state); diff --git a/src/protocols/InputCapture.hpp b/src/protocols/InputCapture.hpp index 3f174448c56..90dd74e5c38 100644 --- a/src/protocols/InputCapture.hpp +++ b/src/protocols/InputCapture.hpp @@ -13,6 +13,8 @@ class CInputCaptureProtocol : public IWaylandProtocol { bool isCaptured(); void updateKeymap(); + void forceRelease(); + void sendMotion(const Vector2D& absolutePosition, const Vector2D& delta); void sendKey(uint32_t keyCode, hyprlandInputCaptureManagerV1KeyState state); void sendButton(uint32_t button, hyprlandInputCaptureManagerV1ButtonState state); diff --git a/subprojects/hyprland-protocols b/subprojects/hyprland-protocols index d3674e1f4ea..0c7cf263fae 160000 --- a/subprojects/hyprland-protocols +++ b/subprojects/hyprland-protocols @@ -1 +1 @@ -Subproject commit d3674e1f4eac730efc01c08e794a988be31ec73e +Subproject commit 0c7cf263faeae9429942c6ffbc1e9b5dfd709bf4 From 189f6152f1354ae936cafffa7b7dd62af8dd5bd4 Mon Sep 17 00:00:00 2001 From: Gwilherm Folliot Date: Tue, 22 Oct 2024 11:54:16 +0200 Subject: [PATCH 10/10] input-capture: fix rebase issues --- src/managers/PointerManager.cpp | 9 +-------- src/managers/input/InputManager.cpp | 9 ++++++++- src/protocols/core/Output.cpp | 3 --- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/managers/PointerManager.cpp b/src/managers/PointerManager.cpp index 4ecc362b9d0..3749a73f6be 100644 --- a/src/managers/PointerManager.cpp +++ b/src/managers/PointerManager.cpp @@ -852,14 +852,7 @@ void CPointerManager::attachPointer(SP pointer) { }); listener->frame = pointer->pointerEvents.frame.registerListener([this] (std::any e) { - bool shouldSkip = false; - if (!g_pSeatManager->mouse.expired() && g_pInputManager->isLocked()) { - auto PMONITOR = g_pCompositor->m_pLastMonitor.get(); - shouldSkip = PMONITOR && PMONITOR->shouldSkipScheduleFrameOnMouseEvent(); - } - g_pSeatManager->isPointerFrameSkipped = shouldSkip; - if (!g_pSeatManager->isPointerFrameSkipped) - g_pSeatManager->sendPointerFrame(); + g_pInputManager->onMouseFrame(); }); listener->swipeBegin = pointer->pointerEvents.swipeBegin.registerListener([this] (std::any e) { diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index 579cf1fdda7..1d235c0081b 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -854,7 +854,14 @@ void CInputManager::onMouseFrame() { if (PROTO::inputCapture->isCaptured()) return; - g_pSeatManager->sendPointerFrame(); + bool shouldSkip = false; + if (!g_pSeatManager->mouse.expired() && g_pInputManager->isLocked()) { + auto PMONITOR = g_pCompositor->m_pLastMonitor.get(); + shouldSkip = PMONITOR && PMONITOR->shouldSkipScheduleFrameOnMouseEvent(); + } + g_pSeatManager->isPointerFrameSkipped = shouldSkip; + if (!g_pSeatManager->isPointerFrameSkipped) + g_pSeatManager->sendPointerFrame(); } Vector2D CInputManager::getMouseCoordsInternal() { diff --git a/src/protocols/core/Output.cpp b/src/protocols/core/Output.cpp index dbeb67fa94f..e94709367f1 100644 --- a/src/protocols/core/Output.cpp +++ b/src/protocols/core/Output.cpp @@ -78,9 +78,6 @@ void CWLOutputResource::updateState() { 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(), - monitor->output->model.c_str(), monitor->transform); - if (resource->version() >= 2) resource->sendDone(); }