From 79c645f8cd42a389d3a8e6532b1928499d53dcb0 Mon Sep 17 00:00:00 2001 From: vaxerski Date: Wed, 21 Sep 2022 14:39:25 +0100 Subject: handle touch devices internally as objects --- src/managers/input/InputManager.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/managers/input/InputManager.cpp') diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index 2b099ac3..ccb9bda5 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -987,3 +987,22 @@ void CInputManager::disableAllKeyboards(bool virt) { k.active = false; } } + +void CInputManager::newTouchDevice(wlr_input_device* pDevice) { + const auto PNEWDEV = &m_lTouchDevices.emplace_back(); + PNEWDEV->pWlrDevice = pDevice; + + wlr_cursor_attach_input_device(g_pCompositor->m_sWLRCursor, pDevice); + + Debug::log(LOG, "New touch device added at %x", PNEWDEV); + + PNEWDEV->hyprListener_destroy.initCallback(&pDevice->events.destroy, [&](void* owner, void* data) { + destroyTouchDevice((STouchDevice*)data); + }, PNEWDEV, "TouchDevice"); +} + +void CInputManager::destroyTouchDevice(STouchDevice* pDevice) { + Debug::log(LOG, "Touch device at %x removed", pDevice); + + m_lTouchDevices.remove(*pDevice); +} -- cgit v1.2.3