fix: small issues when mouse hover is set to select (closes #5292)
This commit is contained in:
1 parent
ea51d57d3d
commit
b9e0344da4
3 files changed
+19
-4
No files matched your search
@@ -331,6 +331,9 @@ class Windows {
|
||||
index = hoveredWindowIndex
|
||||
lastWindowActivityType = .hover
|
||||
}
|
||||
if !fromMouse {
|
||||
App.app.tilesPanel.tilesView.thumbnailOverView.resetHoveredWindow()
|
||||
}
|
||||
if (!fromMouse || Preferences.mouseHoverEnabled)
|
||||
&& (newIndex != selectedWindowIndex || lastWindowActivityType == .hover) {
|
||||
let oldIndex = selectedWindowIndex
|
||||
|
||||
@@ -167,6 +167,6 @@ class CursorEvents {
|
||||
}
|
||||
let deltaX = event.locationInWindow.x - deadZoneInitialPosition.x
|
||||
let deltaY = event.locationInWindow.y - deadZoneInitialPosition.y
|
||||
isAllowedToMouseHover = hypot(deltaX, deltaY) > 25
|
||||
if hypot(deltaX, deltaY) > 25 { isAllowedToMouseHover = true }
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ class TileView: FlippedView {
|
||||
var mouseMovedCallback: (() -> Void)!
|
||||
var dragAndDropTimer: Timer?
|
||||
var indexInRecycledViews: Int!
|
||||
private var lastDragLocation: NSPoint?
|
||||
|
||||
var isFirstInRow = false
|
||||
var isLastInRow = false
|
||||
@@ -34,28 +35,39 @@ class TileView: FlippedView {
|
||||
override func wantsPeriodicDraggingUpdates() -> Bool { false }
|
||||
|
||||
override func draggingUpdated(_ sender: NSDraggingInfo) -> NSDragOperation {
|
||||
mouseMovedCallback()
|
||||
setDraggingTimer()
|
||||
let location = sender.draggingLocation
|
||||
if location != lastDragLocation {
|
||||
lastDragLocation = location
|
||||
mouseMovedCallback()
|
||||
}
|
||||
return .link
|
||||
}
|
||||
|
||||
override func draggingEntered(_ sender: NSDraggingInfo) -> NSDragOperation {
|
||||
lastDragLocation = sender.draggingLocation
|
||||
mouseMovedCallback()
|
||||
setDraggingTimer()
|
||||
return .link
|
||||
}
|
||||
|
||||
private func setDraggingTimer() {
|
||||
dragAndDropTimer?.invalidate()
|
||||
dragAndDropTimer = Timer.scheduledTimer(withTimeInterval: 2, repeats: false, block: { _ in
|
||||
dragAndDropTimer = Timer(timeInterval: 2, repeats: false, block: { [weak self] _ in
|
||||
guard let self else { return }
|
||||
// the user can tab to focus the next thumbnail, while still dragging. We don't want to perform drag then
|
||||
if Windows.selectedWindowIndex == Windows.hoveredWindowIndex {
|
||||
self.mouseUpCallback()
|
||||
}
|
||||
})
|
||||
dragAndDropTimer?.tolerance = 0.2
|
||||
if let dragAndDropTimer {
|
||||
// we need to target .common since dragging is running in .eventTracking on trackpad
|
||||
RunLoop.main.add(dragAndDropTimer, forMode: .common)
|
||||
}
|
||||
}
|
||||
|
||||
override func draggingExited(_ sender: NSDraggingInfo?) {
|
||||
lastDragLocation = nil
|
||||
dragAndDropTimer?.invalidate()
|
||||
dragAndDropTimer = nil
|
||||
App.app.tilesPanel.tilesView.thumbnailOverView.resetHoveredWindow()
|
||||
|
||||
Reference in new issue
Block a user