fix: mouse hover during scroll bounce produced visual jank (closes #259)
This commit is contained in:
1 parent
da574975ac
commit
c7e5daa357
2 files changed
+32
-8
No files matched your search
@@ -98,12 +98,6 @@ class ThumbnailView: NSStackView {
|
|||||||
assignIfDifferent(&subviews.first!.frame.size, frame.size)
|
assignIfDifferent(&subviews.first!.frame.size, frame.size)
|
||||||
self.mouseDownCallback = { () -> Void in App.app.focusSelectedWindow(element) }
|
self.mouseDownCallback = { () -> Void in App.app.focusSelectedWindow(element) }
|
||||||
self.mouseMovedCallback = { () -> Void in Windows.updateFocusedWindowIndex(index) }
|
self.mouseMovedCallback = { () -> Void in Windows.updateFocusedWindowIndex(index) }
|
||||||
if trackingAreas.count == 0 {
|
|
||||||
addTrackingArea(NSTrackingArea(rect: bounds, options: [.mouseMoved, .activeAlways], owner: self, userInfo: nil))
|
|
||||||
} else if trackingAreas.count > 0 && trackingAreas[0].rect != bounds {
|
|
||||||
removeTrackingArea(trackingAreas[0])
|
|
||||||
addTrackingArea(NSTrackingArea(rect: bounds, options: [.mouseMoved, .activeAlways], owner: self, userInfo: nil))
|
|
||||||
}
|
|
||||||
// force a display to avoid flickering; see https://github.com/lwouis/alt-tab-macos/issues/197
|
// force a display to avoid flickering; see https://github.com/lwouis/alt-tab-macos/issues/197
|
||||||
// quirk: display() should be called last as it resets thumbnail.frame.size somehow
|
// quirk: display() should be called last as it resets thumbnail.frame.size somehow
|
||||||
if labelChanged {
|
if labelChanged {
|
||||||
@@ -144,8 +138,8 @@ class ThumbnailView: NSStackView {
|
|||||||
return open != nil
|
return open != nil
|
||||||
}
|
}
|
||||||
|
|
||||||
override func mouseMoved(with event: NSEvent) {
|
func mouseMoved() {
|
||||||
if Preferences.mouseHoverEnabled {
|
if !isHighlighted {
|
||||||
mouseMovedCallback()
|
mouseMovedCallback()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,6 +117,10 @@ class ThumbnailsView: NSVisualEffectView {
|
|||||||
scrollView.documentView!.subviews.forEach { $0.frame.origin.x -= croppedWidth }
|
scrollView.documentView!.subviews.forEach { $0.frame.origin.x -= croppedWidth }
|
||||||
}
|
}
|
||||||
scrollView.documentView!.frame.size = NSSize(width: maxX, height: maxY)
|
scrollView.documentView!.frame.size = NSSize(width: maxX, height: maxY)
|
||||||
|
if let existingTrackingArea = scrollView.trackingAreas.first {
|
||||||
|
scrollView.documentView!.removeTrackingArea(existingTrackingArea)
|
||||||
|
}
|
||||||
|
scrollView.addTrackingArea(NSTrackingArea(rect: scrollView.bounds, options: [.mouseMoved, .activeAlways], owner: scrollView, userInfo: nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
func centerRows(_ maxX: CGFloat) {
|
func centerRows(_ maxX: CGFloat) {
|
||||||
@@ -163,6 +167,8 @@ class ScrollView: NSScrollView {
|
|||||||
// overriding scrollWheel() turns this false; we force it to be true to enable responsive scrolling
|
// overriding scrollWheel() turns this false; we force it to be true to enable responsive scrolling
|
||||||
override class var isCompatibleWithResponsiveScrolling: Bool { true }
|
override class var isCompatibleWithResponsiveScrolling: Bool { true }
|
||||||
|
|
||||||
|
var isCurrentlyScrolling = false
|
||||||
|
|
||||||
convenience init() {
|
convenience init() {
|
||||||
self.init(frame: .zero)
|
self.init(frame: .zero)
|
||||||
documentView = FlippedView(frame: .zero)
|
documentView = FlippedView(frame: .zero)
|
||||||
@@ -173,6 +179,30 @@ class ScrollView: NSScrollView {
|
|||||||
horizontalScrollElasticity = .none
|
horizontalScrollElasticity = .none
|
||||||
usesPredominantAxisScrolling = true
|
usesPredominantAxisScrolling = true
|
||||||
forceOverlayStyle()
|
forceOverlayStyle()
|
||||||
|
observeScrollingEvents()
|
||||||
|
}
|
||||||
|
|
||||||
|
private func observeScrollingEvents() {
|
||||||
|
NotificationCenter.default.addObserver(forName: NSScrollView.didEndLiveScrollNotification, object: nil, queue: nil) { [weak self] _ in
|
||||||
|
self?.isCurrentlyScrolling = false
|
||||||
|
}
|
||||||
|
NotificationCenter.default.addObserver(forName: NSScrollView.willStartLiveScrollNotification, object: nil, queue: nil) { [weak self] _ in
|
||||||
|
self?.isCurrentlyScrolling = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override func mouseMoved(with event: NSEvent) {
|
||||||
|
// disable mouse hover during scrolling as it creates jank during elastic bounces at the start/end of the scrollview
|
||||||
|
if !Preferences.mouseHoverEnabled || isCurrentlyScrolling { return }
|
||||||
|
if let hit = hitTest(App.app.thumbnailsPanel.mouseLocationOutsideOfEventStream) {
|
||||||
|
var target: NSView? = hit
|
||||||
|
while !(target is ThumbnailView) && target != nil {
|
||||||
|
target = target!.superview
|
||||||
|
}
|
||||||
|
if let target = target, target is ThumbnailView {
|
||||||
|
(target as! ThumbnailView).mouseMoved()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// holding shift and using the scrolling wheel will generate a horizontal movement
|
// holding shift and using the scrolling wheel will generate a horizontal movement
|
||||||
|
|||||||
Reference in new issue
Block a user