diff --git a/src/managers/PointerManager.cpp b/src/managers/PointerManager.cpp index 65929355..cc3671f3 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 bcf7f01c..47f712c8 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 1d9bdecf..075c551e 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) {} +void CInputCaptureProtocol::onRelease(CHyprlandInputCaptureManagerV1* pMgr) { + Debug::log(LOG, "[input-capture] Input released"); + active = false; +} + +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 639a21f1..07af6553 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);