From 11afb660102198abb1e74fffdffd00f8c1a11cd9 Mon Sep 17 00:00:00 2001 From: vaxerski Date: Wed, 11 Jan 2023 18:38:54 +0100 Subject: release mouse buttons on map from LS --- src/managers/input/InputManager.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/managers/input/InputManager.cpp') diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index a5ff20f7..be148e89 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -322,6 +322,14 @@ void CInputManager::onMouseButton(wlr_pointer_button_event* e) { m_tmrLastCursorMovement.reset(); + if (e->state == WLR_BUTTON_PRESSED) { + m_lCurrentlyHeldButtons.push_back(e->button); + } else { + if (std::find_if(m_lCurrentlyHeldButtons.begin(), m_lCurrentlyHeldButtons.end(), [&](const auto& other) { return other == e->button; }) == m_lCurrentlyHeldButtons.end()) + return; + std::erase_if(m_lCurrentlyHeldButtons, [&](const auto& other) { return other == e->button; }); + } + switch (m_ecbClickBehavior) { case CLICKMODE_DEFAULT: processMouseDownNormal(e); break; case CLICKMODE_KILL: processMouseDownKill(e); break; @@ -1296,3 +1304,16 @@ SConstraint* CInputManager::constraintFromWlr(wlr_pointer_constraint_v1* constra return nullptr; } + +void CInputManager::releaseAllMouseButtons() { + const auto buttonsCopy = m_lCurrentlyHeldButtons; + + if (g_pInputManager->m_sDrag.drag) + return; + + for (auto& mb : buttonsCopy) { + wlr_seat_pointer_notify_button(g_pCompositor->m_sSeat.seat, 0, mb, WLR_BUTTON_RELEASED); + } + + m_lCurrentlyHeldButtons.clear(); +} -- cgit v1.2.3