From a2c2a93f7900fecfc2007717b621d3d71946aa95 Mon Sep 17 00:00:00 2001 From: erstarr <253168930+erstarr@users.noreply.github.com> Date: Sat, 4 Apr 2026 06:19:38 +0200 Subject: [PATCH] Fix hyprctl keyword causing scrolling view move. rename INPUT_MODE_KB to INPUT_MODE_HARD since it seems to have little to do with keybinds --- src/config/legacy/ConfigManager.cpp | 2 +- src/layout/LayoutManager.cpp | 5 +++++ src/layout/LayoutManager.hpp | 3 ++- .../algorithm/tiled/scrolling/ScrollingAlgorithm.cpp | 12 +++++++----- .../algorithm/tiled/scrolling/ScrollingAlgorithm.hpp | 2 +- src/layout/space/Space.hpp | 1 + 6 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/config/legacy/ConfigManager.cpp b/src/config/legacy/ConfigManager.cpp index 2705c3959..f97fde7e9 100644 --- a/src/config/legacy/ConfigManager.cpp +++ b/src/config/legacy/ConfigManager.cpp @@ -1096,7 +1096,7 @@ std::string CConfigManager::parseKeyword(const std::string& COMMAND, const std:: // invalidate layouts if they changed if (COMMAND == "monitor" || COMMAND.contains("gaps_") || COMMAND.starts_with("dwindle:") || COMMAND.starts_with("master:")) { for (auto const& m : g_pCompositor->m_monitors) { - g_layoutManager->recalculateMonitor(m); + g_layoutManager->recalculateMonitor(m, Layout::CLayoutManager::RECALCULATE_MONITOR_REASON_HYPRCTL_KEYWORD); } } diff --git a/src/layout/LayoutManager.cpp b/src/layout/LayoutManager.cpp index f9a2821e9..57fd99ea0 100644 --- a/src/layout/LayoutManager.cpp +++ b/src/layout/LayoutManager.cpp @@ -332,10 +332,13 @@ void CLayoutManager::performSnap(Vector2D& sourcePos, Vector2D& sourceSize, SP reason) { if (m->m_activeSpecialWorkspace) { if (reason == RECALCULATE_MONITOR_REASON_TOGGLE_SPECIAL_WORKSPACE) m->m_activeSpecialWorkspace->m_space->recalculate(RECALCULATE_REASON_SPECIAL_WORKSPACE_TOGGLE); + else if (reason == RECALCULATE_MONITOR_REASON_HYPRCTL_KEYWORD) + m->m_activeSpecialWorkspace->m_space->recalculate(RECALCULATE_REASON_HYPRCTL_KEYWORD); else m->m_activeSpecialWorkspace->m_space->recalculate(); return; @@ -344,6 +347,8 @@ void CLayoutManager::recalculateMonitor(PHLMONITOR m, std::optionalm_activeWorkspace) { if (reason == RECALCULATE_MONITOR_REASON_WORKSPACE_CHANGE) m->m_activeWorkspace->m_space->recalculate(RECALCULATE_REASON_WORKSPACE_CHANGE); + else if (reason == RECALCULATE_MONITOR_REASON_HYPRCTL_KEYWORD) + m->m_activeWorkspace->m_space->recalculate(RECALCULATE_REASON_HYPRCTL_KEYWORD); else m->m_activeWorkspace->m_space->recalculate(); return; diff --git a/src/layout/LayoutManager.hpp b/src/layout/LayoutManager.hpp index 19f18f47b..977d21cbe 100644 --- a/src/layout/LayoutManager.hpp +++ b/src/layout/LayoutManager.hpp @@ -47,7 +47,8 @@ namespace Layout { enum eRecalculateMonitorReason : uint8_t { RECALCULATE_MONITOR_REASON_WORKSPACE_CHANGE, - RECALCULATE_MONITOR_REASON_TOGGLE_SPECIAL_WORKSPACE + RECALCULATE_MONITOR_REASON_TOGGLE_SPECIAL_WORKSPACE, + RECALCULATE_MONITOR_REASON_HYPRCTL_KEYWORD, }; void newTarget(SP target, SP space); diff --git a/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.cpp b/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.cpp index 7bca0f9e1..2de2ec62a 100644 --- a/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.cpp +++ b/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.cpp @@ -535,7 +535,7 @@ CScrollingAlgorithm::CScrollingAlgorithm() { if (!TARGET || TARGET->floating()) return; - focusOnInput(TARGET, reason == Desktop::FOCUS_REASON_CLICK ? INPUT_MODE_CLICK : (Desktop::isHardInputFocusReason(reason) ? INPUT_MODE_KB : INPUT_MODE_SOFT)); + focusOnInput(TARGET, reason == Desktop::FOCUS_REASON_CLICK ? INPUT_MODE_CLICK : (Desktop::isHardInputFocusReason(reason) ? INPUT_MODE_HARD : INPUT_MODE_SOFT)); }); // Initialize default widths and direction @@ -576,7 +576,7 @@ void CScrollingAlgorithm::focusOnInput(SP target, eInputMode input) { } // if we moved via non-kb, and it's fully visible, ignore - if (m_scrollingData->visible(TARGETDATA->column.lock(), true) && input != INPUT_MODE_KB) + if (m_scrollingData->visible(TARGETDATA->column.lock(), true) && input != INPUT_MODE_HARD) return; static const auto PFITMETHOD = CConfigValue("scrolling:focus_fit_method"); @@ -808,9 +808,11 @@ void CScrollingAlgorithm::recalculate(std::optional reason) const auto TARGETDATA = dataFor(TARGET); if (TARGETDATA && !m_scrollingData->visible(TARGETDATA->column.lock(), true)) { - // guard against scrolling tape move when switching workspaces when target is scrolling (special or not) - if (reason != RECALCULATE_REASON_WORKSPACE_CHANGE && reason != RECALCULATE_REASON_SPECIAL_WORKSPACE_TOGGLE) - focusOnInput(Desktop::focusState()->window()->layoutTarget(), INPUT_MODE_KB); + // TODO: erstarr Maybe do smt about this mess + // RECALCULATE_REASON_WORKSPACE_CHANGE, RECALCULATE_REASON_SPECIAL_WORKSPACE_TOGGLE => guard against scrolling view move when switching workspaces when target is scrolling (special or not) + // RECALCULATE_REASON_HYPRCTL_KEYWORD => guard against `hyprctl keyword` commands moving scrolling view + if (reason != RECALCULATE_REASON_WORKSPACE_CHANGE && reason != RECALCULATE_REASON_SPECIAL_WORKSPACE_TOGGLE && reason != RECALCULATE_REASON_HYPRCTL_KEYWORD) + focusOnInput(Desktop::focusState()->window()->layoutTarget(), INPUT_MODE_HARD); } } diff --git a/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.hpp b/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.hpp index 7c430a2a6..7addcd0ea 100644 --- a/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.hpp +++ b/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.hpp @@ -115,7 +115,7 @@ namespace Layout::Tiled { enum eInputMode : uint8_t { INPUT_MODE_SOFT = 0, INPUT_MODE_CLICK, - INPUT_MODE_KB + INPUT_MODE_HARD }; private: diff --git a/src/layout/space/Space.hpp b/src/layout/space/Space.hpp index c116c6d6e..18b26945d 100644 --- a/src/layout/space/Space.hpp +++ b/src/layout/space/Space.hpp @@ -16,6 +16,7 @@ namespace Layout { enum eRecalculateReason : uint8_t { RECALCULATE_REASON_WORKSPACE_CHANGE, RECALCULATE_REASON_SPECIAL_WORKSPACE_TOGGLE, + RECALCULATE_REASON_HYPRCTL_KEYWORD, };