diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index 964730be..79b71c95 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -1313,7 +1313,7 @@ void CInputManager::newTouchDevice(wlr_input_device* pDevice) { Debug::log(ERR, "Touch Device had no name???"); // logic error } - setTouchDeviceConfigs(); + setTouchDeviceConfigs(PNEWDEV); wlr_cursor_attach_input_device(g_pCompositor->m_sWLRCursor, pDevice); Debug::log(LOG, "New touch device added at %lx", PNEWDEV); @@ -1322,14 +1322,13 @@ void CInputManager::newTouchDevice(wlr_input_device* pDevice) { &pDevice->events.destroy, [&](void* owner, void* data) { destroyTouchDevice((STouchDevice*)data); }, PNEWDEV, "TouchDevice"); } -void CInputManager::setTouchDeviceConfigs() { - for (auto& m : m_lTouchDevices) { - const auto PTOUCHDEV = &m; +void CInputManager::setTouchDeviceConfigs(STouchDevice* dev) { + auto setConfig = [&](STouchDevice* const PTOUCHDEV) -> void { const auto HASCONFIG = g_pConfigManager->deviceConfigExists(PTOUCHDEV->name); - if (wlr_input_device_is_libinput(m.pWlrDevice)) { - const auto LIBINPUTDEV = (libinput_device*)wlr_libinput_get_device_handle(m.pWlrDevice); + if (wlr_input_device_is_libinput(PTOUCHDEV->pWlrDevice)) { + const auto LIBINPUTDEV = (libinput_device*)wlr_libinput_get_device_handle(PTOUCHDEV->pWlrDevice); const int ROTATION = std::clamp(HASCONFIG ? g_pConfigManager->getDeviceInt(PTOUCHDEV->name, "transform") : g_pConfigManager->getInt("input:touchdevice:transform"), 0, 7); @@ -1342,6 +1341,17 @@ void CInputManager::setTouchDeviceConfigs() { else PTOUCHDEV->boundOutput = ""; } + }; + + if (dev) { + setConfig(dev); + return; + } + + for (auto& m : m_lTouchDevices) { + const auto PTOUCHDEV = &m; + + setConfig(PTOUCHDEV); } } diff --git a/src/managers/input/InputManager.hpp b/src/managers/input/InputManager.hpp index f536072f..5cc3c6a6 100644 --- a/src/managers/input/InputManager.hpp +++ b/src/managers/input/InputManager.hpp @@ -91,7 +91,7 @@ class CInputManager { void setKeyboardLayout(); void setPointerConfigs(); - void setTouchDeviceConfigs(); + void setTouchDeviceConfigs(STouchDevice* dev = nullptr); void setTabletConfigs(); void updateDragIcon();