From 643cc80ae0cc5b35c6732c4e12a48b28b90f4064 Mon Sep 17 00:00:00 2001 From: lwouis Date: Wed, 4 Mar 2026 20:45:34 +0100 Subject: [PATCH] feat: refinements on mouse hover and dragging (#5350) --- src/logic/events/CursorEvents.swift | 5 +++++ src/ui/App.swift | 2 ++ src/ui/main-window/TilesView.swift | 17 +++++++++++------ 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/logic/events/CursorEvents.swift b/src/logic/events/CursorEvents.swift index c6d0323c..e8be364b 100644 --- a/src/logic/events/CursorEvents.swift +++ b/src/logic/events/CursorEvents.swift @@ -109,6 +109,11 @@ class CursorEvents { return Unmanaged.passUnretained(cgEvent) } + static func resetDeadzone() { + deadZoneInitialPosition = nil + isAllowedToMouseHover = false + } + static func isAllowedToReactToPointerMovement(_ location: CGPoint) -> Bool { updateDeadzoneSituation(location) return isAllowedToMouseHover diff --git a/src/ui/App.swift b/src/ui/App.swift index 274e246e..421ea5a3 100644 --- a/src/ui/App.swift +++ b/src/ui/App.swift @@ -230,6 +230,8 @@ class App: AppCenterApplication { } static func cycleSelection(_ direction: Direction, allowWrap: Bool = true) { + (TilesView.scrollView?.documentView as? TilesDocumentView)?.cancelDraggingTimer() + CursorEvents.resetDeadzone() if direction == .up || direction == .down { TilesView.navigateUpOrDown(direction, allowWrap: allowWrap) } else { diff --git a/src/ui/main-window/TilesView.swift b/src/ui/main-window/TilesView.swift index 4c2e5649..e3bfed59 100644 --- a/src/ui/main-window/TilesView.swift +++ b/src/ui/main-window/TilesView.swift @@ -736,13 +736,13 @@ class TilesDocumentView: FlippedView { resetDraggingState(true) return [] } - if dragTarget !== target { - dragTarget = target - restartDraggingTimer(location) - } else if shouldRestartDraggingTimer(location) { - restartDraggingTimer(location) - } if let window, CursorEvents.isAllowedToReactToPointerMovement(window.convertPoint(toScreen: location)) { + if dragTarget !== target { + dragTarget = target + restartDraggingTimer(location) + } else if shouldRestartDraggingTimer(location) { + restartDraggingTimer(location) + } target.mouseMovedCallback() } return .link @@ -764,6 +764,11 @@ class TilesDocumentView: FlippedView { if let dragAndDropTimer { RunLoop.main.add(dragAndDropTimer, forMode: .common) } } + func cancelDraggingTimer() { + dragAndDropTimer?.invalidate() + dragAndDropTimer = nil + } + private func resetDraggingState(_ resetHoveredWindow: Bool) { lastDragLocation = nil dragTarget = nil