From a14c39cbe2eb7c039b670a0c0d0819b532b26539 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Sat, 19 Oct 2024 18:46:55 +0100 Subject: XD --- src/managers/PointerManager.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/managers/PointerManager.cpp b/src/managers/PointerManager.cpp index ff61cb54..ae90349b 100644 --- a/src/managers/PointerManager.cpp +++ b/src/managers/PointerManager.cpp @@ -51,22 +51,22 @@ void CPointerManager::unlockSoftwareAll() { updateCursorBackend(); } -void CPointerManager::lockSoftwareForMonitor(PHLMONITOR Monitor) { - for (auto const& m : g_pCompositor->m_vMonitors) { - if (m->ID == Monitor->ID) { - lockSoftwareForMonitor(m); - return; - } - } +void CPointerManager::lockSoftwareForMonitor(PHLMONITOR mon) { + auto state = stateFor(mon); + state->softwareLocks++; + + if (state->softwareLocks == 1) + updateCursorBackend(); } -void CPointerManager::unlockSoftwareForMonitor(PHLMONITOR Monitor) { - for (auto const& m : g_pCompositor->m_vMonitors) { - if (m->ID == Monitor->ID) { - unlockSoftwareForMonitor(m); - return; - } - } +void CPointerManager::unlockSoftwareForMonitor(PHLMONITOR mon) { + auto state = stateFor(mon); + state->softwareLocks--; + if (state->softwareLocks < 0) + state->softwareLocks = 0; + + if (state->softwareLocks == 0) + updateCursorBackend(); } bool CPointerManager::softwareLockedFor(SP mon) { -- cgit v1.2.3