From 32fcd204b0dc587fa44f3335bcb0b9e8cd817e97 Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Fri, 8 May 2026 18:47:01 +0800 Subject: fix --- .../tiled/scrolling/ScrollingAlgorithm.cpp | 25 ++++++++++++++++++++-- .../tiled/scrolling/ScrollingAlgorithm.hpp | 4 ++-- 2 files changed, 25 insertions(+), 4 deletions(-) (limited to 'src/layout/algorithm') diff --git a/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.cpp b/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.cpp index c505be4c..e4943371 100644 --- a/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.cpp +++ b/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.cpp @@ -13,6 +13,8 @@ #include "../../../../managers/input/InputManager.hpp" #include "../../../../managers/animation/DesktopAnimationManager.hpp" #include "../../../../event/EventBus.hpp" +#include "../../../../managers/eventLoop/EventLoopTimer.hpp" +#include "../../../../managers/eventLoop/EventLoopManager.hpp" #include #include @@ -610,6 +612,9 @@ CScrollingAlgorithm::~CScrollingAlgorithm() { m_configCallback.reset(); m_focusCallback.reset(); + + if (m_hoverTimer) + m_hoverTimer->cancel(); } void CScrollingAlgorithm::focusOnInput(SP target, eInputMode input) { @@ -640,9 +645,21 @@ void CScrollingAlgorithm::focusOnInput(SP target, eInputMode input) { if (*PHOVERDELAY > 0.F) { if (m_hoveredTarget.lock() != target) { m_hoveredTarget = target; - m_hoverTimer.reset(); + if (m_hoverTimer) + m_hoverTimer->cancel(); + + m_hoverTimer = makeShared( + std::chrono::milliseconds((int)*PHOVERDELAY), + [this, target, input](SP self, void* data) { + if (m_hoveredTarget.lock() == target) { + m_hoverTimer.reset(); + focusOnInput(target, input); + } + }, + nullptr); + g_pEventLoopManager->addTimer(m_hoverTimer); return; - } else if (m_hoverTimer.getMillis() < *PHOVERDELAY) { + } else if (m_hoverTimer && !m_hoverTimer->passed() && !m_hoverTimer->cancelled()) { return; } } else { @@ -651,6 +668,10 @@ void CScrollingAlgorithm::focusOnInput(SP target, eInputMode input) { } } + m_hoveredTarget.reset(); + if (m_hoverTimer) + m_hoverTimer->cancel(); + // if we moved via non-kb, and it's fully visible, ignore if (m_scrollingData->visible(TARGETDATA->column.lock(), true) && input != INPUT_MODE_KB) return; diff --git a/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.hpp b/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.hpp index b8e175d7..1d83b325 100644 --- a/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.hpp +++ b/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.hpp @@ -4,7 +4,7 @@ #include "../../../../helpers/math/Direction.hpp" #include "ScrollTapeController.hpp" #include "../../../../helpers/signal/Signal.hpp" -#include "../../../../helpers/time/Timer.hpp" +#include "../../../../managers/eventLoop/EventLoopTimer.hpp" #include #include @@ -177,7 +177,7 @@ namespace Layout::Tiled { std::vector m_fullscreenTargets; bool m_lastFullscreenCover = false; - CTimer m_hoverTimer; + SP m_hoverTimer; WP m_hoveredTarget; friend struct SScrollingData; -- cgit v1.2.3