diff options
| author | vaxerski <vaxry@vaxry.net> | 2023-01-20 19:15:15 +0100 |
|---|---|---|
| committer | vaxerski <vaxry@vaxry.net> | 2023-01-20 19:15:15 +0100 |
| commit | fb2679d5ef1e35358808b336711ad49cb7359717 (patch) | |
| tree | a9345c0ccd7c4c48f6a40d87a6046d995edd9e91 /src | |
| parent | 6f3548b18486fe9eb9285c6a3971b9a1168e07f5 (diff) | |
add a focus history vec
Diffstat (limited to 'src')
| -rw-r--r-- | src/Compositor.cpp | 8 | ||||
| -rw-r--r-- | src/Compositor.hpp | 2 | ||||
| -rw-r--r-- | src/Window.cpp | 4 |
3 files changed, 14 insertions, 0 deletions
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) { diff --git a/src/Compositor.hpp b/src/Compositor.hpp index 080ac96f..7bcd6cf4 100644 --- a/src/Compositor.hpp +++ b/src/Compositor.hpp @@ -96,6 +96,8 @@ class CCompositor { CWindow* m_pLastWindow = nullptr; CMonitor* m_pLastMonitor = nullptr; + std::vector<CWindow*> m_vWindowFocusHistory; // first element is the most recently focused. + SSeat m_sSeat; bool m_bReadyToProcess = false; diff --git a/src/Window.cpp b/src/Window.cpp index 9cf59287..cb0565bf 100644 --- a/src/Window.cpp +++ b/src/Window.cpp @@ -267,6 +267,8 @@ void CWindow::onUnmap() { m_fDimPercent.setCallbackOnEnd(unregisterVar); m_vRealSize.setCallbackOnBegin(nullptr); + + std::erase_if(g_pCompositor->m_vWindowFocusHistory, [&](const auto& other) { return other == this; }); } void CWindow::onMap() { @@ -290,6 +292,8 @@ void CWindow::onMap() { m_vRealSize.setCallbackOnEnd([&](void* ptr) { g_pHyprOpenGL->onWindowResizeEnd(this); }, false); m_vRealSize.setCallbackOnBegin([&](void* ptr) { g_pHyprOpenGL->onWindowResizeStart(this); }, false); + + g_pCompositor->m_vWindowFocusHistory.push_back(this); } void CWindow::setHidden(bool hidden) { |
