summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVisal Vijay <150381094+B2krobbery@users.noreply.github.com>2026-04-16 22:23:12 +0530
committerGitHub <noreply@github.com>2026-04-16 17:53:12 +0100
commit1ea0a43615fa103b28f58648b36ffa2c95366753 (patch)
treeaa82e2a2b5fafe5d8c16df33175c19ad420b3aef /src
parented349e84d26f35a6ef20019f7315ddfd85d1e7ee (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')
-rw-r--r--src/helpers/Monitor.cpp21
-rw-r--r--src/layout/algorithm/tiled/monocle/MonocleAlgorithm.cpp5
-rw-r--r--src/managers/input/InputManager.cpp7
3 files changed, 19 insertions, 14 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)
diff --git a/src/layout/algorithm/tiled/monocle/MonocleAlgorithm.cpp b/src/layout/algorithm/tiled/monocle/MonocleAlgorithm.cpp
index fe92f27c..e1b4c608 100644
--- a/src/layout/algorithm/tiled/monocle/MonocleAlgorithm.cpp
+++ b/src/layout/algorithm/tiled/monocle/MonocleAlgorithm.cpp
@@ -211,10 +211,11 @@ void CMonocleAlgorithm::moveTargetInDirection(SP<ITarget> t, Math::eDirection di
if (!t || !t->space() || !t->space()->workspace())
return;
- const auto PMONINDIR = g_pCompositor->getMonitorInDirection(t->space()->workspace()->m_monitor.lock(), dir);
+ const auto PMONITOR = t->space()->workspace()->m_monitor.lock();
+ const auto PMONINDIR = g_pCompositor->getMonitorInDirection(PMONITOR, dir);
// if we found a monitor, move the window there
- if (PMONINDIR && PMONINDIR != t->space()->workspace()->m_monitor.lock()) {
+ if (PMONINDIR && PMONINDIR != PMONITOR) {
const auto TARGETWS = PMONINDIR->m_activeWorkspace;
if (t->window())
diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp
index d1dafbc9..95e7704a 100644
--- a/src/managers/input/InputManager.cpp
+++ b/src/managers/input/InputManager.cpp
@@ -626,8 +626,11 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse, st
m_lastFocusOnLS = false;
return; // don't enter any new surfaces
} else {
- if (allowKeyboardRefocus && ((FOLLOWMOUSE != 3 && (*PMOUSEREFOCUS || m_lastMouseFocus.lock() != pFoundWindow)) || refocus)) {
- if (m_lastMouseFocus.lock() != pFoundWindow || Desktop::focusState()->window() != pFoundWindow || Desktop::focusState()->surface() != foundSurface || refocus) {
+ auto lastFocus = m_lastMouseFocus.lock();
+
+ if (allowKeyboardRefocus && ((FOLLOWMOUSE != 3 && (*PMOUSEREFOCUS || lastFocus != pFoundWindow)) || refocus)) {
+ if (lastFocus != pFoundWindow || Desktop::focusState()->window() != pFoundWindow || Desktop::focusState()->surface() != foundSurface || refocus) {
+
m_lastMouseFocus = pFoundWindow;
// TODO: this looks wrong. When over a popup, it constantly is switching.