From c8b23f1ea8c4198c60b08e5aebfb920b2a33a8e3 Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Fri, 8 May 2026 11:18:31 +0800 Subject: t --- src/config/values/ConfigValues.cpp | 1 + .../algorithm/tiled/scrolling/ScrollingAlgorithm.cpp | 16 ++++++++++++++-- .../algorithm/tiled/scrolling/ScrollingAlgorithm.hpp | 4 ++++ 3 files changed, 19 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/config/values/ConfigValues.cpp b/src/config/values/ConfigValues.cpp index 88269989..78c349e8 100644 --- a/src/config/values/ConfigValues.cpp +++ b/src/config/values/ConfigValues.cpp @@ -666,6 +666,7 @@ std::vector> Values::getConfigValues() { MS("scrolling:follow_focus", "when a window is focused, should the layout move to bring it into view automatically", true), MS("scrolling:follow_min_visible", "when a window is focused, require that at least a given fraction of it is visible for focus to follow", 0.4, {.min = 0.0, .max = 1.0}), + MS("scrolling:focus_edge_ms", "when a window is focused, require that at least a given amount of time of cursor hovering the edge", 250, {.min = 0, .max = 3000}), MS("scrolling:explicit_column_widths", "A comma-separated list of preconfigured widths for colresize +conf/-conf", "0.333, 0.5, 0.667, 1.0"), MS("scrolling:direction", "Direction in which new windows appear and the layout scrolls", "right", {.refresh = Supplementary::REFRESH_LAYOUTS}), MS("scrolling:wrap_focus", "Determines if column focus wraps around", true), diff --git a/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.cpp b/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.cpp index c6cfbada..c505be4c 100644 --- a/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.cpp +++ b/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.cpp @@ -614,6 +614,7 @@ CScrollingAlgorithm::~CScrollingAlgorithm() { void CScrollingAlgorithm::focusOnInput(SP target, eInputMode input) { static const auto PFOLLOW_FOCUS_MIN_PERC = CConfigValue("scrolling:follow_min_visible"); + static const auto PHOVERDELAY = CConfigValue("scrolling:focus_edge_ms"); if (!target || target->space() != m_parent->space()) return; @@ -635,8 +636,19 @@ void CScrollingAlgorithm::focusOnInput(SP target, eInputMode input) { std::abs(std::min(MON_BOX.y + MON_BOX.h, TARGET_POS.y + TARGET_POS.h) - (std::max(MON_BOX.y, TARGET_POS.y))); // if the amount of visible X is below minimum, reject - if (VISIBLE_LEN < (IS_HORIZ ? MON_BOX.w : MON_BOX.h) * std::clamp(*PFOLLOW_FOCUS_MIN_PERC, 0.F, 1.F)) - return; + if (VISIBLE_LEN < (IS_HORIZ ? MON_BOX.w : MON_BOX.h) * std::clamp(*PFOLLOW_FOCUS_MIN_PERC, 0.F, 1.F)) { + if (*PHOVERDELAY > 0.F) { + if (m_hoveredTarget.lock() != target) { + m_hoveredTarget = target; + m_hoverTimer.reset(); + return; + } else if (m_hoverTimer.getMillis() < *PHOVERDELAY) { + return; + } + } else { + return; + } + } } // if we moved via non-kb, and it's fully visible, ignore diff --git a/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.hpp b/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.hpp index a7c64aa8..b8e175d7 100644 --- a/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.hpp +++ b/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.hpp @@ -4,6 +4,7 @@ #include "../../../../helpers/math/Direction.hpp" #include "ScrollTapeController.hpp" #include "../../../../helpers/signal/Signal.hpp" +#include "../../../../helpers/time/Timer.hpp" #include #include @@ -176,6 +177,9 @@ namespace Layout::Tiled { std::vector m_fullscreenTargets; bool m_lastFullscreenCover = false; + CTimer m_hoverTimer; + WP m_hoveredTarget; + friend struct SScrollingData; }; }; -- cgit v1.2.3