fix: bring back mouse hover selection (closes #2317)
This commit is contained in:
1 parent
f9bb33c49b
commit
abe2e0b73b
4 files changed
+26
-23
No files matched your search
@@ -29,7 +29,7 @@ class Preferences {
|
|||||||
"quitAppShortcut": "Q",
|
"quitAppShortcut": "Q",
|
||||||
"hideShowAppShortcut": "H",
|
"hideShowAppShortcut": "H",
|
||||||
"arrowKeysEnabled": "true",
|
"arrowKeysEnabled": "true",
|
||||||
"mouseHoverEnabled": "true",
|
"mouseHoverEnabled": "false",
|
||||||
"cursorFollowFocusEnabled": "false",
|
"cursorFollowFocusEnabled": "false",
|
||||||
"showMinimizedWindows": ShowHowPreference.show.rawValue,
|
"showMinimizedWindows": ShowHowPreference.show.rawValue,
|
||||||
"showMinimizedWindows2": ShowHowPreference.show.rawValue,
|
"showMinimizedWindows2": ShowHowPreference.show.rawValue,
|
||||||
|
|||||||
+11
-10
@@ -36,11 +36,11 @@ class Windows {
|
|||||||
if let app = Applications.find(NSWorkspace.shared.frontmostApplication?.processIdentifier),
|
if let app = Applications.find(NSWorkspace.shared.frontmostApplication?.processIdentifier),
|
||||||
app.focusedWindow == nil,
|
app.focusedWindow == nil,
|
||||||
let lastFocusedWindowIndex = getLastFocusedWindowIndex() {
|
let lastFocusedWindowIndex = getLastFocusedWindowIndex() {
|
||||||
updateFocusedWindowIndex(lastFocusedWindowIndex)
|
updateHoveredAndFocusedWindowIndexes(lastFocusedWindowIndex)
|
||||||
} else {
|
} else {
|
||||||
cycleFocusedWindowIndex(1)
|
cycleFocusedWindowIndex(1)
|
||||||
if focusedWindowIndex == 0 {
|
if focusedWindowIndex == 0 {
|
||||||
updateFocusedWindowIndex(0)
|
updateHoveredAndFocusedWindowIndexes(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -99,22 +99,23 @@ class Windows {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
static func updateFocusedWindowIndex(_ newIndex: Int, _ fromMouse: Bool = false) {
|
static func updateHoveredAndFocusedWindowIndexes(_ newIndex: Int, _ fromMouse: Bool = false) {
|
||||||
if (fromMouse && newIndex == hoveredWindowIndex) || (!fromMouse && newIndex == focusedWindowIndex) {
|
var index: Int?
|
||||||
return
|
if fromMouse && newIndex != hoveredWindowIndex {
|
||||||
}
|
|
||||||
if fromMouse {
|
|
||||||
let oldIndex = hoveredWindowIndex
|
let oldIndex = hoveredWindowIndex
|
||||||
hoveredWindowIndex = newIndex
|
hoveredWindowIndex = newIndex
|
||||||
if let oldIndex = oldIndex {
|
if let oldIndex = oldIndex {
|
||||||
ThumbnailsView.highlight(oldIndex)
|
ThumbnailsView.highlight(oldIndex)
|
||||||
}
|
}
|
||||||
} else {
|
index = hoveredWindowIndex
|
||||||
|
}
|
||||||
|
if (!fromMouse || Preferences.mouseHoverEnabled) && newIndex != focusedWindowIndex {
|
||||||
let oldIndex = focusedWindowIndex
|
let oldIndex = focusedWindowIndex
|
||||||
focusedWindowIndex = newIndex
|
focusedWindowIndex = newIndex
|
||||||
ThumbnailsView.highlight(oldIndex)
|
ThumbnailsView.highlight(oldIndex)
|
||||||
|
index = focusedWindowIndex
|
||||||
}
|
}
|
||||||
let index = fromMouse ? hoveredWindowIndex! : focusedWindowIndex
|
guard let index = index else { return }
|
||||||
ThumbnailsView.highlight(index)
|
ThumbnailsView.highlight(index)
|
||||||
let focusedView = ThumbnailsView.recycledViews[index]
|
let focusedView = ThumbnailsView.recycledViews[index]
|
||||||
App.app.thumbnailsPanel.thumbnailsView.scrollView.contentView.scrollToVisible(focusedView.frame)
|
App.app.thumbnailsPanel.thumbnailsView.scrollView.contentView.scrollToVisible(focusedView.frame)
|
||||||
@@ -143,7 +144,7 @@ class Windows {
|
|||||||
(KeyRepeatTimer.isARepeat || KeyRepeatTimer.timer?.isValid ?? false) {
|
(KeyRepeatTimer.isARepeat || KeyRepeatTimer.timer?.isValid ?? false) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
updateFocusedWindowIndex(nextIndex)
|
updateHoveredAndFocusedWindowIndexes(nextIndex)
|
||||||
}
|
}
|
||||||
|
|
||||||
static func windowIndexAfterCycling(_ step: Int) -> Int {
|
static func windowIndexAfterCycling(_ step: Int) -> Int {
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ class ThumbnailView: NSStackView {
|
|||||||
windowlessIcon.needsDisplay = true
|
windowlessIcon.needsDisplay = true
|
||||||
}
|
}
|
||||||
self.mouseUpCallback = { () -> Void in App.app.focusSelectedWindow(element) }
|
self.mouseUpCallback = { () -> Void in App.app.focusSelectedWindow(element) }
|
||||||
self.mouseMovedCallback = { () -> Void in Windows.updateFocusedWindowIndex(index, true) }
|
self.mouseMovedCallback = { () -> Void in Windows.updateHoveredAndFocusedWindowIndexes(index, true) }
|
||||||
[quitIcon, closeIcon, minimizeIcon, maximizeIcon].forEach { $0.window_ = element }
|
[quitIcon, closeIcon, minimizeIcon, maximizeIcon].forEach { $0.window_ = element }
|
||||||
showOrHideWindowControls(false)
|
showOrHideWindowControls(false)
|
||||||
// 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
|
||||||
@@ -263,9 +263,7 @@ class ThumbnailView: NSStackView {
|
|||||||
|
|
||||||
func mouseMoved() {
|
func mouseMoved() {
|
||||||
showOrHideWindowControls(true)
|
showOrHideWindowControls(true)
|
||||||
if Preferences.mouseHoverEnabled {
|
mouseMovedCallback()
|
||||||
mouseMovedCallback()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override func mouseUp(with event: NSEvent) {
|
override func mouseUp(with event: NSEvent) {
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ class ThumbnailsView: NSVisualEffectView {
|
|||||||
return leadingSide ? NSMinX($0.frame) < originCenter : NSMaxX($0.frame) > originCenter
|
return leadingSide ? NSMinX($0.frame) < originCenter : NSMaxX($0.frame) > originCenter
|
||||||
} ?? iterable.last!
|
} ?? iterable.last!
|
||||||
let targetIndex = ThumbnailsView.recycledViews.firstIndex(of: targetView)!
|
let targetIndex = ThumbnailsView.recycledViews.firstIndex(of: targetView)!
|
||||||
Windows.updateFocusedWindowIndex(targetIndex)
|
Windows.updateHoveredAndFocusedWindowIndexes(targetIndex)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,6 +228,14 @@ class ScrollView: NSScrollView {
|
|||||||
self?.isCurrentlyScrolling = true
|
self?.isCurrentlyScrolling = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func resetHoveredWindow() {
|
||||||
|
if let oldIndex = Windows.hoveredWindowIndex {
|
||||||
|
Windows.hoveredWindowIndex = nil
|
||||||
|
ThumbnailsView.highlight(oldIndex)
|
||||||
|
ThumbnailsView.recycledViews[oldIndex].showOrHideWindowControls(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override func mouseMoved(with event: NSEvent) {
|
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
|
// disable mouse hover during scrolling as it creates jank during elastic bounces at the start/end of the scrollview
|
||||||
@@ -245,19 +253,15 @@ class ScrollView: NSScrollView {
|
|||||||
let target = target as! ThumbnailView
|
let target = target as! ThumbnailView
|
||||||
target.mouseMoved()
|
target.mouseMoved()
|
||||||
} else {
|
} else {
|
||||||
previousTarget?.showOrHideWindowControls(false)
|
resetHoveredWindow()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
previousTarget?.showOrHideWindowControls(false)
|
resetHoveredWindow()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override func mouseExited(with event: NSEvent) {
|
override func mouseExited(with event: NSEvent) {
|
||||||
if let oldIndex = Windows.hoveredWindowIndex {
|
resetHoveredWindow()
|
||||||
Windows.hoveredWindowIndex = nil
|
|
||||||
ThumbnailsView.highlight(oldIndex)
|
|
||||||
ThumbnailsView.recycledViews[oldIndex].showOrHideWindowControls(false)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 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