diff options
| author | Vaxry <vaxry@vaxry.net> | 2024-06-12 17:03:04 +0200 |
|---|---|---|
| committer | Vaxry <vaxry@vaxry.net> | 2024-06-12 17:03:12 +0200 |
| commit | 9d7d5ec3c8ea3550ca3053a7a26e97231ad6fde9 (patch) | |
| tree | f4a5fb642ee9ed247dc1ab7c15c043b8e3795fa2 /src/managers/input/InputManager.cpp | |
| parent | c7e85e26f761fb58db6692649e259589cdf55cf0 (diff) | |
seatmgr: fix missing nullcheck in updateActiveKeyboardData
sometimes we may set a keyboard that's about-to-be-deleted, we might as well check for that
additionally avoid setting null keyboards altogether
Diffstat (limited to 'src/managers/input/InputManager.cpp')
| -rw-r--r-- | src/managers/input/InputManager.cpp | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index 033f4d6d..ed8e834c 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -1226,12 +1226,20 @@ void CInputManager::destroyKeyboard(SP<IKeyboard> pKeyboard) { std::erase_if(m_vKeyboards, [pKeyboard](const auto& other) { return other == pKeyboard; }); if (m_vKeyboards.size() > 0) { - const auto PNEWKEYBOARD = m_vKeyboards.back(); - g_pSeatManager->setKeyboard(PNEWKEYBOARD); - PNEWKEYBOARD->active = true; - } else { + bool found = false; + for (auto& k : m_vKeyboards | std::views::reverse) { + if (!k->wlr()) + continue; + + g_pSeatManager->setKeyboard(k); + found = true; + break; + } + + if (!found) + g_pSeatManager->setKeyboard(nullptr); + } else g_pSeatManager->setKeyboard(nullptr); - } removeFromHIDs(pKeyboard); } |
