From 252aaaecfa3b57eb07822177a8bf3b609aff7115 Mon Sep 17 00:00:00 2001 From: vaxerski Date: Tue, 9 Jan 2024 13:17:55 +0100 Subject: [PATCH] input: add special_fallthrough fixes #4323 --- src/Compositor.cpp | 17 ++++++++++++++--- src/config/ConfigManager.cpp | 1 + 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/Compositor.cpp b/src/Compositor.cpp index b98c714d..62903cf9 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -654,6 +654,7 @@ CWindow* CCompositor::vectorToWindowIdeal(const Vector2D& pos, CWindow* pIgnoreW static auto* const PRESIZEONBORDER = &g_pConfigManager->getConfigValuePtr("general:resize_on_border")->intValue; static auto* const PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue; static auto* const PBORDERGRABEXTEND = &g_pConfigManager->getConfigValuePtr("general:extend_border_grab_area")->intValue; + static auto* const PSPECIALFALLTHRU = &g_pConfigManager->getConfigValuePtr("input:special_fallthrough")->intValue; const auto BORDER_GRAB_AREA = *PRESIZEONBORDER ? *PBORDERSIZE + *PBORDERGRABEXTEND : 0; // pinned windows on top of floating regardless @@ -735,9 +736,16 @@ CWindow* CCompositor::vectorToWindowIdeal(const Vector2D& pos, CWindow* pIgnoreW }; // special workspace - if (PMONITOR->specialWorkspaceID) + if (PMONITOR->specialWorkspaceID && !*PSPECIALFALLTHRU) return windowForWorkspace(true); + if (PMONITOR->specialWorkspaceID) { + const auto PWINDOW = windowForWorkspace(true); + + if (PWINDOW) + return PWINDOW; + } + return windowForWorkspace(false); } @@ -876,7 +884,8 @@ CMonitor* CCompositor::getMonitorFromOutput(wlr_output* out) { void CCompositor::focusWindow(CWindow* pWindow, wlr_surface* pSurface) { - static auto* const PFOLLOWMOUSE = &g_pConfigManager->getConfigValuePtr("input:follow_mouse")->intValue; + static auto* const PFOLLOWMOUSE = &g_pConfigManager->getConfigValuePtr("input:follow_mouse")->intValue; + static auto* const PSPECIALFALLTHROUGH = &g_pConfigManager->getConfigValuePtr("input:special_fallthrough")->intValue; if (g_pCompositor->m_sSeat.exclusiveClient) { Debug::log(LOG, "Disallowing setting focus to a window due to there being an active input inhibitor layer."); @@ -943,7 +952,9 @@ void CCompositor::focusWindow(CWindow* pWindow, wlr_surface* pSurface) { const auto PLASTWINDOW = m_pLastWindow; m_pLastWindow = pWindow; - if (PMONITOR->specialWorkspaceID && PMONITOR->specialWorkspaceID != pWindow->m_iWorkspaceID) + /* If special fallthrough is enabled, this behavior will be disabled, as I have no better idea of nicely tracking which + window focuses are "via keybinds" and which ones aren't. */ + if (PMONITOR->specialWorkspaceID && PMONITOR->specialWorkspaceID != pWindow->m_iWorkspaceID && !*PSPECIALFALLTHROUGH) PMONITOR->setSpecialWorkspace(nullptr); // we need to make the PLASTWINDOW not equal to m_pLastWindow so that RENDERDATA is correct for an unfocused window diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 44b5374b..69128c52 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -223,6 +223,7 @@ void CConfigManager::setDefaultVars() { configValues["input:follow_mouse"].intValue = 1; configValues["input:mouse_refocus"].intValue = 1; + configValues["input:special_fallthrough"].intValue = 0; configValues["input:sensitivity"].floatValue = 0.f; configValues["input:accel_profile"].strValue = STRVAL_EMPTY; configValues["input:kb_file"].strValue = STRVAL_EMPTY;