From fb2679d5ef1e35358808b336711ad49cb7359717 Mon Sep 17 00:00:00 2001 From: vaxerski Date: Fri, 20 Jan 2023 19:15:15 +0100 Subject: add a focus history vec --- src/Compositor.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/Compositor.cpp') diff --git a/src/Compositor.cpp b/src/Compositor.cpp index ca7f9b69..37ec97d5 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -865,6 +865,14 @@ void CCompositor::focusWindow(CWindow* pWindow, wlr_surface* pSurface) { } g_pInputManager->recheckIdleInhibitorStatus(); + + // move to front of the window history + const auto HISTORYPIVOT = std::find_if(m_vWindowFocusHistory.begin(), m_vWindowFocusHistory.end(), [&](const auto& other) { return other == pWindow; }); + if (HISTORYPIVOT == m_vWindowFocusHistory.end()) { + Debug::log(ERR, "BUG THIS: Window %x has no pivot in history", pWindow); + } else { + std::rotate(m_vWindowFocusHistory.begin(), HISTORYPIVOT, HISTORYPIVOT + 1); + } } void CCompositor::focusSurface(wlr_surface* pSurface, CWindow* pWindowOwner) { -- cgit v1.2.3