diff options
Diffstat (limited to 'src/managers')
-rw-r--r-- | src/managers/input/InputManager.cpp | 25 | ||||
-rw-r--r-- | src/managers/input/InputManager.hpp | 7 |
2 files changed, 29 insertions, 3 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); +} diff --git a/src/managers/input/InputManager.hpp b/src/managers/input/InputManager.hpp index e56aaf6f..bc73d2cc 100644 --- a/src/managers/input/InputManager.hpp +++ b/src/managers/input/InputManager.hpp @@ -239,7 +239,8 @@ class CInputManager { uint32_t m_uiCapabilities = 0; - void mouseMoveUnified(uint32_t, bool refocus = false); + void mouseMoveUnified(uint32_t, bool refocus = false, bool mouse = false); + void recheckMouseWarpOnMouseInput(); SP<CTabletTool> ensureTabletToolPresent(SP<Aquamarine::ITabletTool>); @@ -250,6 +251,10 @@ class CInputManager { PHLLSREF m_pFoundLSToFocus; PHLWINDOWREF m_pFoundWindowToFocus; + // used for warping back after non-mouse input + Vector2D m_vLastMousePos = {}; + bool m_bLastInputMouse = true; + // for holding focus on buttons held bool m_bFocusHeldByButtons = false; bool m_bRefocusHeldByButtons = false; |