From 5ba33f846129f3e6c0505b19f94634b24505e828 Mon Sep 17 00:00:00 2001 From: Vaxry <43317083+vaxerski@users.noreply.github.com> Date: Sun, 26 Apr 2026 15:16:36 +0100 Subject: config/lua: init lua config manager, use lua if available (#13817) Adds a new lua config manager, which will automatically be used if there is a lua config present. --- src/managers/input/InputManager.cpp | 57 +++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 28 deletions(-) (limited to 'src/managers/input/InputManager.cpp') diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index c4df7c53..a4df12fe 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -6,6 +6,7 @@ #include #include #include "../../config/ConfigValue.hpp" +#include "../../config/shared/actions/ConfigActions.hpp" #include "../../config/legacy/ConfigManager.hpp" #include "../../desktop/view/WLSurface.hpp" #include "../../desktop/state/FocusState.hpp" @@ -116,7 +117,7 @@ CInputManager::~CInputManager() { } void CInputManager::onMouseMoved(IPointer::SMotionEvent e) { - static auto PNOACCEL = CConfigValue("input:force_no_accel"); + static auto PNOACCEL = CConfigValue("input:force_no_accel"); Vector2D delta = e.delta; Vector2D unaccel = e.unaccel; @@ -212,14 +213,14 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse, st if (MOUSECOORDSFLOORED == m_lastCursorPosFloored && !refocus) return; - static auto PFOLLOWMOUSE = CConfigValue("input:follow_mouse"); - static auto PFOLLOWMOUSETHRESHOLD = CConfigValue("input:follow_mouse_threshold"); - static auto PMOUSEREFOCUS = CConfigValue("input:mouse_refocus"); - static auto PFOLLOWONDND = CConfigValue("misc:always_follow_on_dnd"); - static auto PFLOATBEHAVIOR = CConfigValue("input:float_switch_override_focus"); - static auto PMOUSEFOCUSMON = CConfigValue("misc:mouse_move_focuses_monitor"); - static auto PRESIZEONBORDER = CConfigValue("general:resize_on_border"); - static auto PRESIZECURSORICON = CConfigValue("general:hover_icon_on_border"); + static auto PFOLLOWMOUSE = CConfigValue("input:follow_mouse"); + static auto PFOLLOWMOUSETHRESHOLD = CConfigValue("input:follow_mouse_threshold"); + static auto PMOUSEREFOCUS = CConfigValue("input:mouse_refocus"); + static auto PFOLLOWONDND = CConfigValue("misc:always_follow_on_dnd"); + static auto PFLOATBEHAVIOR = CConfigValue("input:float_switch_override_focus"); + static auto PMOUSEFOCUSMON = CConfigValue("misc:mouse_move_focuses_monitor"); + static auto PRESIZEONBORDER = CConfigValue("general:resize_on_border"); + static auto PRESIZECURSORICON = CConfigValue("general:hover_icon_on_border"); const auto FOLLOWMOUSE = *PFOLLOWONDND && PROTO::data->dndActive() ? 1 : *PFOLLOWMOUSE; @@ -785,12 +786,12 @@ void CInputManager::setClickMode(eClickBehaviorMode mode) { void CInputManager::processMouseDownNormal(const IPointer::SButtonEvent& e, SP mouse) { // notify the keybind manager - static auto PPASSMOUSE = CConfigValue("binds:pass_mouse_when_bound"); + static auto PPASSMOUSE = CConfigValue("binds:pass_mouse_when_bound"); const auto PASS = g_pKeybindManager->onMouseEvent(e, mouse); - static auto PFOLLOWMOUSE = CConfigValue("input:follow_mouse"); - static auto PRESIZEONBORDER = CConfigValue("general:resize_on_border"); - static auto PBORDERSIZE = CConfigValue("general:border_size"); - static auto PBORDERGRABEXTEND = CConfigValue("general:extend_border_grab_area"); + static auto PFOLLOWMOUSE = CConfigValue("input:follow_mouse"); + static auto PRESIZEONBORDER = CConfigValue("general:resize_on_border"); + static auto PBORDERSIZE = CConfigValue("general:border_size"); + static auto PBORDERGRABEXTEND = CConfigValue("general:extend_border_grab_area"); const auto BORDER_GRAB_AREA = *PRESIZEONBORDER ? *PBORDERSIZE + *PBORDERGRABEXTEND : 0; if (!PASS && !*PPASSMOUSE) @@ -891,11 +892,11 @@ void CInputManager::processMouseDownKill(const IPointer::SButtonEvent& e) { } void CInputManager::onMouseWheel(IPointer::SAxisEvent e, SP pointer) { - static auto POFFWINDOWAXIS = CConfigValue("input:off_window_axis_events"); - static auto PINPUTSCROLLFACTOR = CConfigValue("input:scroll_factor"); - static auto PTOUCHPADSCROLLFACTOR = CConfigValue("input:touchpad:scroll_factor"); - static auto PEMULATEDISCRETE = CConfigValue("input:emulate_discrete_scroll"); - static auto PFOLLOWMOUSE = CConfigValue("input:follow_mouse"); + static auto POFFWINDOWAXIS = CConfigValue("input:off_window_axis_events"); + static auto PINPUTSCROLLFACTOR = CConfigValue("input:scroll_factor"); + static auto PTOUCHPADSCROLLFACTOR = CConfigValue("input:touchpad:scroll_factor"); + static auto PEMULATEDISCRETE = CConfigValue("input:emulate_discrete_scroll"); + static auto PFOLLOWMOUSE = CConfigValue("input:follow_mouse"); const bool ISTOUCHPADSCROLL = *PTOUCHPADSCROLLFACTOR <= 0.f || e.source == WL_POINTER_AXIS_SOURCE_FINGER; auto factor = ISTOUCHPADSCROLL ? *PTOUCHPADSCROLLFACTOR : *PINPUTSCROLLFACTOR; @@ -1041,7 +1042,7 @@ void CInputManager::newVirtualKeyboard(SP keyboard) } void CInputManager::setupKeyboard(SP keeb) { - static auto PDPMS = CConfigValue("misc:key_press_enables_dpms"); + static auto PDPMS = CConfigValue("misc:key_press_enables_dpms"); m_hids.emplace_back(keeb); @@ -1069,8 +1070,8 @@ void CInputManager::setupKeyboard(SP keeb) { if (PKEEB->m_enabled) PROTO::idle->onActivity(); - if (PKEEB->m_enabled && *PDPMS && !g_pCompositor->m_dpmsStateOn) - g_pKeybindManager->dpms("on"); + if (PKEEB->m_enabled && *PDPMS && !g_pCompositor->m_dpmsStateOn) // NOLINTNEXTLINE + Config::Actions::dpms(Config::Actions::TOGGLE_ACTION_ENABLE, std::nullopt); }); keeb->m_keyboardEvents.modifiers.listenStatic([this, keeb = keeb.get()] { @@ -1081,8 +1082,8 @@ void CInputManager::setupKeyboard(SP keeb) { if (PKEEB->m_enabled) PROTO::idle->onActivity(); - if (PKEEB->m_enabled && *PDPMS && !g_pCompositor->m_dpmsStateOn) - g_pKeybindManager->dpms("on"); + if (PKEEB->m_enabled && *PDPMS && !g_pCompositor->m_dpmsStateOn) // NOLINTNEXTLINE + Config::Actions::dpms(Config::Actions::TOGGLE_ACTION_ENABLE, std::nullopt); }); keeb->m_keyboardEvents.keymap.listenStatic([keeb = keeb.get()] { @@ -1138,8 +1139,8 @@ void CInputManager::applyConfigToKeyboard(SP pKeyboard) { const auto VARIANT = Config::mgr()->getDeviceString(devname, "kb_variant", "input:kb_variant"); const auto OPTIONS = Config::mgr()->getDeviceString(devname, "kb_options", "input:kb_options"); - const auto ENABLED = HASCONFIG ? Config::mgr()->getDeviceInt(devname, "enabled") : true; - const auto ALLOWBINDS = HASCONFIG ? Config::mgr()->getDeviceInt(devname, "keybinds") : true; + const auto ENABLED = HASCONFIG && Config::mgr()->deviceConfigExplicitlySet(devname, "enabled") ? Config::mgr()->getDeviceInt(devname, "enabled") : true; + const auto ALLOWBINDS = HASCONFIG && Config::mgr()->deviceConfigExplicitlySet(devname, "keybinds") ? Config::mgr()->getDeviceInt(devname, "keybinds") : true; pKeyboard->m_enabled = ENABLED; pKeyboard->m_resolveBindsBySym = RESOLVEBINDSBYSYM; @@ -1979,7 +1980,7 @@ void CInputManager::setCursorIconOnBorder(PHLWINDOW w) { return; } - static auto PEXTENDBORDERGRAB = CConfigValue("general:extend_border_grab_area"); + static auto PEXTENDBORDERGRAB = CConfigValue("general:extend_border_grab_area"); const int BORDERSIZE = w->getRealBorderSize(); const int ROUNDING = w->rounding(); @@ -2072,7 +2073,7 @@ void CInputManager::setCursorIconOnBorder(PHLWINDOW w) { } void CInputManager::recheckMouseWarpOnMouseInput() { - static auto PWARPFORNONMOUSE = CConfigValue("cursor:warp_back_after_non_mouse_input"); + static auto PWARPFORNONMOUSE = CConfigValue("cursor:warp_back_after_non_mouse_input"); if (!m_lastInputMouse && *PWARPFORNONMOUSE) g_pPointerManager->warpTo(m_lastMousePos); -- cgit v1.2.3