From eff3bfe261e90b8950b59379ca7815f735a7aab6 Mon Sep 17 00:00:00 2001 From: fazzi <18248986+fxzzi@users.noreply.github.com> Date: Mon, 4 May 2026 17:00:56 +0100 Subject: windows/focus: add fallbacks when focussing workspaces (#14270) --- src/config/shared/actions/ConfigActions.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/config/shared/actions/ConfigActions.cpp') diff --git a/src/config/shared/actions/ConfigActions.cpp b/src/config/shared/actions/ConfigActions.cpp index 7111afd8..56fb88e9 100644 --- a/src/config/shared/actions/ConfigActions.cpp +++ b/src/config/shared/actions/ConfigActions.cpp @@ -94,7 +94,7 @@ static bool tryMoveFocusToMonitor(PHLMONITOR monitor) { const auto PNEWMAINWORKSPACE = monitor->m_activeWorkspace; const auto PNEWWORKSPACE = monitor->m_activeSpecialWorkspace ? monitor->m_activeSpecialWorkspace : PNEWMAINWORKSPACE; - const auto PNEWWINDOW = PNEWWORKSPACE->getLastFocusedWindow(); + auto PNEWWINDOW = PNEWWORKSPACE->getFocusCandidate(); if (PNEWWINDOW) { updateRelativeCursorCoords(); @@ -931,11 +931,13 @@ ActionResult Actions::changeWorkspace(PHLWORKSPACE ws) { PMONITORWORKSPACEOWNER->changeWorkspace(ws, false, true); if (PMONITOR != PMONITORWORKSPACEOWNER) { - Vector2D middle = PMONITORWORKSPACEOWNER->middle(); - if (const auto PLAST = ws->getLastFocusedWindow(); PLAST) { - Desktop::focusState()->fullWindowFocus(PLAST, Desktop::FOCUS_REASON_KEYBIND); + Vector2D middle = PMONITORWORKSPACEOWNER->middle(); + auto pWindow = ws->getFocusCandidate(); + + if (pWindow) { + Desktop::focusState()->fullWindowFocus(pWindow, Desktop::FOCUS_REASON_KEYBIND); if (*PWORKSPACECENTERON == 1) - middle = PLAST->middle(); + middle = pWindow->middle(); } g_pCompositor->warpCursorTo(middle); } -- cgit v1.2.3