diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2026-05-09 00:05:35 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2026-05-09 00:05:35 +0800 |
| commit | f971f0931f20063d961a14ae6dc80d500d0bc71d (patch) | |
| tree | 044d9182d69639fe735557561246d72940b1be25 /src/layout/algorithm | |
| parent | 32fcd204b0dc587fa44f3335bcb0b9e8cd817e97 (diff) | |
copilotscrolling/focus_edge_ms
Diffstat (limited to 'src/layout/algorithm')
| -rw-r--r-- | src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.cpp b/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.cpp index e4943371..e5fe33c5 100644 --- a/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.cpp +++ b/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.cpp @@ -613,13 +613,17 @@ CScrollingAlgorithm::~CScrollingAlgorithm() { m_configCallback.reset(); m_focusCallback.reset(); - if (m_hoverTimer) + if (m_hoverTimer) { m_hoverTimer->cancel(); + if (g_pEventLoopManager) + g_pEventLoopManager->removeTimer(m_hoverTimer); + m_hoverTimer.reset(); + } } void CScrollingAlgorithm::focusOnInput(SP<ITarget> target, eInputMode input) { static const auto PFOLLOW_FOCUS_MIN_PERC = CConfigValue<Config::FLOAT>("scrolling:follow_min_visible"); - static const auto PHOVERDELAY = CConfigValue<Config::FLOAT>("scrolling:focus_edge_ms"); + static const auto PHOVERDELAY = CConfigValue<Config::INTEGER>("scrolling:focus_edge_ms"); if (!target || target->space() != m_parent->space()) return; @@ -642,15 +646,17 @@ void CScrollingAlgorithm::focusOnInput(SP<ITarget> target, eInputMode input) { // 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)) { - if (*PHOVERDELAY > 0.F) { + if (*PHOVERDELAY > 0) { if (m_hoveredTarget.lock() != target) { m_hoveredTarget = target; if (m_hoverTimer) m_hoverTimer->cancel(); m_hoverTimer = makeShared<CEventLoopTimer>( - std::chrono::milliseconds((int)*PHOVERDELAY), - [this, target, input](SP<CEventLoopTimer> self, void* data) { + std::chrono::milliseconds(*PHOVERDELAY), + [this, weakTarget = WP<ITarget>(target), input](SP<CEventLoopTimer> self, void* data) { + auto target = weakTarget.lock(); + if (!target) return; if (m_hoveredTarget.lock() == target) { m_hoverTimer.reset(); focusOnInput(target, input); @@ -669,8 +675,11 @@ void CScrollingAlgorithm::focusOnInput(SP<ITarget> target, eInputMode input) { } m_hoveredTarget.reset(); - if (m_hoverTimer) + if (m_hoverTimer) { m_hoverTimer->cancel(); + g_pEventLoopManager->removeTimer(m_hoverTimer); + m_hoverTimer.reset(); + } // if we moved via non-kb, and it's fully visible, ignore if (m_scrollingData->visible(TARGETDATA->column.lock(), true) && input != INPUT_MODE_KB) |
