diff options
| author | Vaxry <43317083+vaxerski@users.noreply.github.com> | 2025-09-02 13:16:43 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-02 13:16:43 +0200 |
| commit | 127aab815908ecbd3db4d23f127d2e96b79855f9 (patch) | |
| tree | 289ee3e7c9be70c3b45ff91a693b33fe7598502a /src/managers/input/InputManager.cpp | |
| parent | 78e86d879fa9bf3afeb73b29a3e668d47df5e9ab (diff) | |
input: add per-device scroll-factor (#11241)
Diffstat (limited to 'src/managers/input/InputManager.cpp')
| -rw-r--r-- | src/managers/input/InputManager.cpp | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index 5224f940..5e844bec 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -835,7 +835,7 @@ void CInputManager::processMouseDownKill(const IPointer::SButtonEvent& e) { m_clickBehavior = CLICKMODE_DEFAULT; } -void CInputManager::onMouseWheel(IPointer::SAxisEvent e) { +void CInputManager::onMouseWheel(IPointer::SAxisEvent e, SP<IPointer> pointer) { static auto POFFWINDOWAXIS = CConfigValue<Hyprlang::INT>("input:off_window_axis_events"); static auto PINPUTSCROLLFACTOR = CConfigValue<Hyprlang::FLOAT>("input:scroll_factor"); static auto PTOUCHPADSCROLLFACTOR = CConfigValue<Hyprlang::FLOAT>("input:touchpad:scroll_factor"); @@ -845,7 +845,10 @@ void CInputManager::onMouseWheel(IPointer::SAxisEvent e) { const bool ISTOUCHPADSCROLL = *PTOUCHPADSCROLLFACTOR <= 0.f || e.source == WL_POINTER_AXIS_SOURCE_FINGER; auto factor = ISTOUCHPADSCROLL ? *PTOUCHPADSCROLLFACTOR : *PINPUTSCROLLFACTOR; - const auto EMAP = std::unordered_map<std::string, std::any>{{"event", e}}; + if (pointer && pointer->m_scrollFactor.has_value()) + factor = *pointer->m_scrollFactor; + + const auto EMAP = std::unordered_map<std::string, std::any>{{"event", e}}; EMIT_HOOK_EVENT_CANCELLABLE("mouseAxis", EMAP); if (e.mouse) @@ -888,7 +891,11 @@ void CInputManager::onMouseWheel(IPointer::SAxisEvent e) { if (*PFOLLOWMOUSE == 1 && PCURRWINDOW && PWINDOW != PCURRWINDOW) simulateMouseMovement(); } - factor = ISTOUCHPADSCROLL ? PWINDOW->getScrollTouchpad() : PWINDOW->getScrollMouse(); + + if (!ISTOUCHPADSCROLL && PWINDOW->isScrollMouseOverridden()) + factor = PWINDOW->getScrollMouse(); + else if (ISTOUCHPADSCROLL && PWINDOW->isScrollTouchpadOverridden()) + factor = PWINDOW->getScrollTouchpad(); } } @@ -1117,6 +1124,14 @@ void CInputManager::newVirtualMouse(SP<CVirtualPointerV1Resource> mouse) { Debug::log(LOG, "New virtual mouse created"); } +void CInputManager::newMouse(SP<IPointer> mouse) { + m_pointers.emplace_back(mouse); + + setupMouse(mouse); + + Debug::log(LOG, "New mouse created, pointer Hypr: {:x}", rc<uintptr_t>(mouse.get())); +} + void CInputManager::newMouse(SP<Aquamarine::IPointer> mouse) { const auto PMOUSE = m_pointers.emplace_back(CMouse::create(mouse)); @@ -1172,6 +1187,11 @@ void CInputManager::setPointerConfigs() { } } + if (g_pConfigManager->deviceConfigExplicitlySet(devname, "scroll_factor")) + m->m_scrollFactor = std::clamp(g_pConfigManager->getDeviceFloat(devname, "scroll_factor", "input:scroll_factor"), 0.F, 100.F); + else + m->m_scrollFactor = std::nullopt; + if (m->aq() && m->aq()->getLibinputHandle()) { const auto LIBINPUTDEV = m->aq()->getLibinputHandle(); |
