From 28c81fc71ec2593cdac6cbf945369b201c1e3e71 Mon Sep 17 00:00:00 2001 From: vaxerski Date: Thu, 27 Oct 2022 12:58:10 +0100 Subject: [PATCH] add disabling pointer devices --- src/config/ConfigManager.cpp | 1 + src/helpers/WLClasses.hpp | 2 ++ src/managers/input/InputManager.cpp | 13 +++++++++++++ 3 files changed, 16 insertions(+) diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index bccabe17..664e07cd 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -193,6 +193,7 @@ void CConfigManager::setDeviceDefaultVars(const std::string& dev) { cfgValues["scroll_method"].strValue = STRVAL_EMPTY; cfgValues["touch_transform"].intValue = 0; cfgValues["touch_output"].strValue = STRVAL_EMPTY; + cfgValues["enabled"].intValue = 1; // only for mice / touchpads } void CConfigManager::setDefaultAnimationVars() { diff --git a/src/helpers/WLClasses.hpp b/src/helpers/WLClasses.hpp index 515ef946..c340a516 100644 --- a/src/helpers/WLClasses.hpp +++ b/src/helpers/WLClasses.hpp @@ -131,6 +131,8 @@ struct SMouse { bool virt = false; + bool connected = false; // means connected to the cursor + DYNLISTENER(commitConstraint); DYNLISTENER(destroyMouse); diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index d76810e3..27d16899 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -683,6 +683,8 @@ void CInputManager::newMouse(wlr_input_device* mouse, bool virt) { wlr_cursor_attach_input_device(g_pCompositor->m_sWLRCursor, mouse); + PMOUSE->connected = true; + g_pCompositor->m_sSeat.mouse = PMOUSE; m_tmrLastCursorMovement.reset(); @@ -699,6 +701,17 @@ void CInputManager::setPointerConfigs() { const auto HASCONFIG = g_pConfigManager->deviceConfigExists(devname); + if (HASCONFIG) { + const auto ENABLED = g_pConfigManager->getDeviceInt(devname, "enabled"); + if (ENABLED && !m.connected) { + wlr_cursor_attach_input_device(g_pCompositor->m_sWLRCursor, m.mouse); + m.connected = true; + } else if (!ENABLED && m.connected) { + wlr_cursor_detach_input_device(g_pCompositor->m_sWLRCursor, m.mouse); + m.connected = false; + } + } + if (wlr_input_device_is_libinput(m.mouse)) { const auto LIBINPUTDEV = (libinput_device*)wlr_libinput_get_device_handle(m.mouse);