From 1ea0a43615fa103b28f58648b36ffa2c95366753 Mon Sep 17 00:00:00 2001 From: Visal Vijay <150381094+B2krobbery@users.noreply.github.com> Date: Thu, 16 Apr 2026 22:23:12 +0530 Subject: monocle: avoid repeated workspace monitor lock() calls (#14085) * refactor(monocle): avoid repeated workspace monitor lock() calls * clang-format * cleanup: avoid repeated weak_ptr::lock() calls * style: shorten variable name PMONITORWORKSPACEOWNER to PMONITOR --- src/helpers/Monitor.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src/helpers/Monitor.cpp') diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp index bff57c7e..2c0727c0 100644 --- a/src/helpers/Monitor.cpp +++ b/src/helpers/Monitor.cpp @@ -1503,21 +1503,22 @@ void CMonitor::setSpecialWorkspace(const PHLWORKSPACE& pWorkspace) { bool wasActive = false; //close if open elsewhere - const auto PMONITORWORKSPACEOWNER = pWorkspace->m_monitor.lock(); - if (const auto PMWSOWNER = pWorkspace->m_monitor.lock(); PMWSOWNER && PMWSOWNER->m_activeSpecialWorkspace == pWorkspace) { - PMWSOWNER->m_activeSpecialWorkspace.reset(); - g_layoutManager->recalculateMonitor(PMWSOWNER); - g_pHyprRenderer->damageMonitor(PMWSOWNER); - g_pEventManager->postEvent(SHyprIPCEvent{"activespecial", "," + PMWSOWNER->m_name}); - g_pEventManager->postEvent(SHyprIPCEvent{"activespecialv2", ",," + PMWSOWNER->m_name}); + const auto PMONITOR = pWorkspace->m_monitor.lock(); + + if (PMONITOR && PMONITOR->m_activeSpecialWorkspace == pWorkspace) { + PMONITOR->m_activeSpecialWorkspace.reset(); + g_layoutManager->recalculateMonitor(PMONITOR); + g_pHyprRenderer->damageMonitor(PMONITOR); + g_pEventManager->postEvent(SHyprIPCEvent{"activespecial", "," + PMONITOR->m_name}); + g_pEventManager->postEvent(SHyprIPCEvent{"activespecialv2", ",," + PMONITOR->m_name}); // Reset layer surfaces on the old monitor when special workspace is stolen for (auto const& ls : g_pCompositor->m_layers) { - if (ls->m_monitor == PMWSOWNER) + if (ls->m_monitor == PMONITOR) ls->m_aboveFullscreen = false; } - const auto PACTIVEWORKSPACE = PMWSOWNER->m_activeWorkspace; + const auto PACTIVEWORKSPACE = PMONITOR->m_activeWorkspace; g_pDesktopAnimationManager->setFullscreenFadeAnimation(PACTIVEWORKSPACE, PACTIVEWORKSPACE && PACTIVEWORKSPACE->m_hasFullscreenWindow ? CDesktopAnimationManager::ANIMATION_TYPE_IN : CDesktopAnimationManager::ANIMATION_TYPE_OUT); @@ -1539,7 +1540,7 @@ void CMonitor::setSpecialWorkspace(const PHLWORKSPACE& pWorkspace) { if (POLDSPECIAL) POLDSPECIAL->m_events.activeChanged.emit(); - if (PMONITORWORKSPACEOWNER != m_self) + if (PMONITOR != m_self) pWorkspace->m_events.monitorChanged.emit(); if (!wasActive) -- cgit v1.2.3