diff --git a/src/managers/PointerManager.cpp b/src/managers/PointerManager.cpp index ba01d2aa..65929355 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 196f0b71..bcf7f01c 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 10faff24..30835c07 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 889f2599..1d9bdecf 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 172c17dc..639a21f1 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 1c4de2b2..53a994b2 160000 --- a/subprojects/hyprland-protocols +++ b/subprojects/hyprland-protocols @@ -1 +1 @@ -Subproject commit 1c4de2b22b9a7100ca664e46e37e29b0b724ce97 +Subproject commit 53a994b2efbcc19862125fc9a8d5a752a24a0f20