diff options
Diffstat (limited to 'src/managers/input/InputManager.cpp')
-rw-r--r-- | src/managers/input/InputManager.cpp | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index fdaa6bfa..cccaa43e 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -94,13 +94,19 @@ void CInputManager::onMouseMoved(IPointer::SMotionEvent e) { PROTO::relativePointer->sendRelativeMotion((uint64_t)e.timeMs * 1000, DELTA, e.unaccel); + if (e.mouse) + recheckMouseWarpOnMouseInput(); + g_pPointerManager->move(DELTA); - mouseMoveUnified(e.timeMs); + mouseMoveUnified(e.timeMs, false, e.mouse); m_tmrLastCursorMovement.reset(); m_bLastInputTouch = false; + + if (e.mouse) + m_vLastMousePos = getMouseCoordsInternal(); } void CInputManager::onMouseWarp(IPointer::SMotionAbsoluteEvent e) { @@ -138,7 +144,9 @@ void CInputManager::sendMotionEventsToFocused() { g_pSeatManager->setPointerFocus(g_pCompositor->m_pLastFocus.lock(), LOCAL); } -void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { +void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse) { + m_bLastInputMouse = mouse; + if (!g_pCompositor->m_bReadyToProcess || g_pCompositor->m_bIsShuttingDown || g_pCompositor->m_bUnsafeState) return; @@ -534,6 +542,9 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { void CInputManager::onMouseButton(IPointer::SButtonEvent e) { EMIT_HOOK_EVENT_CANCELLABLE("mouseButton", e); + if (e.mouse) + recheckMouseWarpOnMouseInput(); + m_tmrLastCursorMovement.reset(); if (e.state == WL_POINTER_BUTTON_STATE_PRESSED) { @@ -768,6 +779,9 @@ void CInputManager::onMouseWheel(IPointer::SAxisEvent e) { const auto EMAP = std::unordered_map<std::string, std::any>{{"event", e}}; EMIT_HOOK_EVENT_CANCELLABLE("mouseAxis", EMAP); + if (e.mouse) + recheckMouseWarpOnMouseInput(); + bool passEvent = g_pKeybindManager->onAxisEvent(e); if (!passEvent) @@ -1790,3 +1804,10 @@ void CInputManager::setCursorIconOnBorder(PHLWINDOW w) { case BORDERICON_DOWN_RIGHT: setCursorImageUntilUnset("bottom_right_corner"); break; } } + +void CInputManager::recheckMouseWarpOnMouseInput() { + static auto PWARPFORNONMOUSE = CConfigValue<Hyprlang::INT>("cursor:warp_back_after_non_mouse_input"); + + if (!m_bLastInputMouse && *PWARPFORNONMOUSE) + g_pPointerManager->warpTo(m_vLastMousePos); +} |