From f971f0931f20063d961a14ae6dc80d500d0bc71d Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Sat, 9 May 2026 00:05:35 +0800 Subject: copilot --- .../tiled/scrolling/ScrollingAlgorithm.cpp | 21 +++++++++++++++------ 1 file 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 target, eInputMode input) { static const auto PFOLLOW_FOCUS_MIN_PERC = CConfigValue("scrolling:follow_min_visible"); - static const auto PHOVERDELAY = CConfigValue("scrolling:focus_edge_ms"); + static const auto PHOVERDELAY = CConfigValue("scrolling:focus_edge_ms"); if (!target || target->space() != m_parent->space()) return; @@ -642,15 +646,17 @@ void CScrollingAlgorithm::focusOnInput(SP 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( - std::chrono::milliseconds((int)*PHOVERDELAY), - [this, target, input](SP self, void* data) { + std::chrono::milliseconds(*PHOVERDELAY), + [this, weakTarget = WP(target), input](SP 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 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) -- cgit v1.2.3