input: add per-device scroll-factor (#11241)
This commit is contained in:
parent
78e86d879f
commit
127aab8159
16 changed files with 593 additions and 22 deletions
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue