From df956a0f6fbcfd7397b2d7b86883c0936c7795ec Mon Sep 17 00:00:00 2001 From: Mike Will Date: Fri, 6 Dec 2024 01:16:58 -0500 Subject: windowrules: add rules for mouse and touchpad scroll factors (#8655) --- src/desktop/Window.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/desktop/Window.cpp') diff --git a/src/desktop/Window.cpp b/src/desktop/Window.cpp index e4651e61..e2106e4a 100644 --- a/src/desktop/Window.cpp +++ b/src/desktop/Window.cpp @@ -718,6 +718,10 @@ void CWindow::applyDynamicRule(const SWindowRule& r) { try { *(search->second(m_pSelf.lock())) = CWindowOverridableVar(std::stoi(VARS[1]), priority); } catch (std::exception& e) { Debug::log(ERR, "Rule \"{}\" failed with: {}", r.szRule, e.what()); } + } else if (auto search = g_pConfigManager->mfWindowProperties.find(VARS[0]); search != g_pConfigManager->mfWindowProperties.end()) { + try { + *(search->second(m_pSelf.lock())) = CWindowOverridableVar(std::stof(VARS[1]), priority); + } catch (std::exception& e) { Debug::log(ERR, "Rule \"{}\" failed with: {}", r.szRule, e.what()); } } else if (r.szRule.starts_with("idleinhibit")) { auto IDLERULE = r.szRule.substr(r.szRule.find_first_of(' ') + 1); @@ -1178,6 +1182,16 @@ int CWindow::getRealBorderSize() { return m_sWindowData.borderSize.valueOr(*PBORDERSIZE); } +float CWindow::getScrollMouse() { + static auto PINPUTSCROLLFACTOR = CConfigValue("input:scroll_factor"); + return m_sWindowData.scrollMouse.valueOr(*PINPUTSCROLLFACTOR); +} + +float CWindow::getScrollTouchpad() { + static auto PTOUCHPADSCROLLFACTOR = CConfigValue("input:touchpad:scroll_factor"); + return m_sWindowData.scrollTouchpad.valueOr(*PTOUCHPADSCROLLFACTOR); +} + bool CWindow::canBeTorn() { static auto PTEARING = CConfigValue("general:allow_tearing"); return m_sWindowData.tearing.valueOr(m_bTearingHint) && *PTEARING; @@ -1602,6 +1616,9 @@ void CWindow::unsetWindowData(eOverridePriority priority) { for (auto const& element : g_pConfigManager->miWindowProperties) { element.second(m_pSelf.lock())->unset(priority); } + for (auto const& element : g_pConfigManager->mfWindowProperties) { + element.second(m_pSelf.lock())->unset(priority); + } } bool CWindow::isX11OverrideRedirect() { -- cgit v1.2.3