diff options
| author | Visal Vijay <150381094+B2krobbery@users.noreply.github.com> | 2026-04-16 22:23:12 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-04-16 17:53:12 +0100 |
| commit | 1ea0a43615fa103b28f58648b36ffa2c95366753 (patch) | |
| tree | aa82e2a2b5fafe5d8c16df33175c19ad420b3aef /src/helpers/Monitor.cpp | |
| parent | ed349e84d26f35a6ef20019f7315ddfd85d1e7ee (diff) | |
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
Diffstat (limited to 'src/helpers/Monitor.cpp')
| -rw-r--r-- | src/helpers/Monitor.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
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) |
