From cb59763d32b5ac9824ed921d225c376cd1f98df6 Mon Sep 17 00:00:00 2001 From: memchr <118117622+memchr@users.noreply.github.com> Date: Mon, 21 Aug 2023 18:54:02 +0000 Subject: fix: improved focus behaviour on workspace switching for follow_mouse!=1 (#3041) * fix: improved focus behaviour on workspace switching for follow_mouse!=1 When the 'input:follow_mouse' is not set to 1 and the target workspace for switching does not currently have the previously focused window, Hyprland will prioritize focusing on the top-left-most window. * fix: #2451 call simulateMouseMovement. * unify logic * multimon fix --------- Co-authored-by: vaxerski <43317083+vaxerski@users.noreply.github.com> --- src/Compositor.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/Compositor.cpp') diff --git a/src/Compositor.cpp b/src/Compositor.cpp index a6370de3..44d7c89e 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -1198,6 +1198,26 @@ CWindow* CCompositor::getFirstWindowOnWorkspace(const int& id) { return nullptr; } +CWindow* CCompositor::getTopLeftWindowOnWorkspace(const int& id) { + const auto PWORKSPACE = getWorkspaceByID(id); + + if (!PWORKSPACE) + return nullptr; + + const auto PMONITOR = getMonitorFromID(PWORKSPACE->m_iMonitorID); + + for (auto& w : m_vWindows) { + if (w->m_iWorkspaceID != id || !w->m_bIsMapped || w->isHidden()) + continue; + + const auto WINDOWIDEALBB = w->getWindowIdealBoundingBoxIgnoreReserved(); + + if (WINDOWIDEALBB.x <= PMONITOR->vecPosition.x + 1 && WINDOWIDEALBB.y <= PMONITOR->vecPosition.y + 1) + return w.get(); + } + return nullptr; +} + bool CCompositor::doesSeatAcceptInput(wlr_surface* surface) { if (g_pSessionLockManager->isSessionLocked()) { if (g_pSessionLockManager->isSurfaceSessionLock(surface)) -- cgit v1.2.3