From b16a57ceeb2c9fefb0fad444d763211254d36971 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Fri, 26 Aug 2022 00:38:20 +0200 Subject: [PATCH] fix window rules --- src/events/Windows.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp index fbaadd51..b0cd460f 100644 --- a/src/events/Windows.cpp +++ b/src/events/Windows.cpp @@ -267,7 +267,9 @@ void Events::listener_mapWindow(void* owner, void* data) { PWINDOW->m_vPseudoSize = PWINDOW->m_vRealSize.goalv() - Vector2D(10,10); } - if (!PWINDOW->m_bNoFocus && !PWINDOW->m_bNoInitialFocus && PWINDOW->m_iX11Type != 2 && shouldFocus) { + const auto PFOCUSEDWINDOWPREV = g_pCompositor->m_pLastWindow; + + if (!PWINDOW->m_bNoFocus && !PWINDOW->m_bNoInitialFocus && PWINDOW->m_iX11Type != 2) { g_pCompositor->focusWindow(PWINDOW); PWINDOW->m_fActiveInactiveAlpha.setValueAndWarp(*PACTIVEALPHA); } else @@ -335,6 +337,13 @@ void Events::listener_mapWindow(void* owner, void* data) { PWINDOW->updateToplevel(); + if (!shouldFocus) { + if (g_pCompositor->windowValidMapped(PFOCUSEDWINDOWPREV)) + g_pCompositor->focusWindow(PFOCUSEDWINDOWPREV); + else if (!PFOCUSEDWINDOWPREV) + g_pCompositor->focusWindow(nullptr); + } + Debug::log(LOG, "Map request dispatched, monitor %s, xywh: %f %f %f %f", PMONITOR->szName.c_str(), PWINDOW->m_vRealPosition.goalv().x, PWINDOW->m_vRealPosition.goalv().y, PWINDOW->m_vRealSize.goalv().x, PWINDOW->m_vRealSize.goalv().y); auto workspaceID = requestedWorkspace != "" ? requestedWorkspace : PWORKSPACE->m_szName;