feat: switcher will show faster (closes #3845)
This commit is contained in:
1 parent
a083b06de0
commit
b694c837b4
3 files changed
+4
-13
No files matched your search
+1
-10
@@ -4,8 +4,6 @@ class Windows {
|
|||||||
static var list = [Window]()
|
static var list = [Window]()
|
||||||
static var focusedWindowIndex = Int(0)
|
static var focusedWindowIndex = Int(0)
|
||||||
static var hoveredWindowIndex: Int?
|
static var hoveredWindowIndex: Int?
|
||||||
// the first few thumbnails are the most commonly looked at; we pay special attention to them
|
|
||||||
static let criticalFirstThumbnails = 3
|
|
||||||
static var lastWindowActivityType = WindowActivityType.none
|
static var lastWindowActivityType = WindowActivityType.none
|
||||||
|
|
||||||
/// reordered list based on preferences, keeping the original index
|
/// reordered list based on preferences, keeping the original index
|
||||||
@@ -265,14 +263,7 @@ class Windows {
|
|||||||
Windows.list = sortedTuples.map { $0.1 }
|
Windows.list = sortedTuples.map { $0.1 }
|
||||||
}
|
}
|
||||||
|
|
||||||
static func refreshFirstFewThumbnailsSync() {
|
static func refreshThumbnailsAsync(_ screen: NSScreen, _ currentIndex: Int) {
|
||||||
if Appearance.hideThumbnails { return }
|
|
||||||
list.filter { $0.shouldShowTheUser }
|
|
||||||
.prefix(criticalFirstThumbnails)
|
|
||||||
.forEachAsync { window in window.refreshThumbnail() }
|
|
||||||
}
|
|
||||||
|
|
||||||
static func refreshThumbnailsAsync(_ screen: NSScreen, _ currentIndex: Int = criticalFirstThumbnails) {
|
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
if !App.app.appIsBeingUsed || Appearance.hideThumbnails { return }
|
if !App.app.appIsBeingUsed || Appearance.hideThumbnails { return }
|
||||||
BackgroundWork.mainQueueConcurrentWorkQueue.async {
|
BackgroundWork.mainQueueConcurrentWorkQueue.async {
|
||||||
|
|||||||
@@ -121,6 +121,8 @@ class KeyboardEvents {
|
|||||||
|
|
||||||
fileprivate let cgEventFlagsChangedHandler: CGEventTapCallBack = {_, type, cgEvent, _ in
|
fileprivate let cgEventFlagsChangedHandler: CGEventTapCallBack = {_, type, cgEvent, _ in
|
||||||
if type == .flagsChanged {
|
if type == .flagsChanged {
|
||||||
|
// TODO: it would be great to shortcut matching and trigger on the background thread
|
||||||
|
// it would enable us to set App.app.isBeingUsed here, and could stop tasks on main when they check the flag
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
let modifiers = NSEvent.ModifierFlags(rawValue: UInt(cgEvent.flags.rawValue))
|
let modifiers = NSEvent.ModifierFlags(rawValue: UInt(cgEvent.flags.rawValue))
|
||||||
// TODO: ideally, we want to absorb all modifier keys except holdShortcut
|
// TODO: ideally, we want to absorb all modifier keys except holdShortcut
|
||||||
|
|||||||
+1
-3
@@ -310,8 +310,6 @@ class App: AppCenterApplication, NSApplicationDelegate {
|
|||||||
guard appIsBeingUsed else { return }
|
guard appIsBeingUsed else { return }
|
||||||
Appearance.update()
|
Appearance.update()
|
||||||
guard appIsBeingUsed else { return }
|
guard appIsBeingUsed else { return }
|
||||||
Windows.refreshFirstFewThumbnailsSync()
|
|
||||||
guard appIsBeingUsed else { return }
|
|
||||||
thumbnailsPanel.makeKeyAndOrderFront(nil) // workaround: without this, switching between 2 screens make thumbnailPanel invisible
|
thumbnailsPanel.makeKeyAndOrderFront(nil) // workaround: without this, switching between 2 screens make thumbnailPanel invisible
|
||||||
guard appIsBeingUsed else { return }
|
guard appIsBeingUsed else { return }
|
||||||
refreshOpenUi()
|
refreshOpenUi()
|
||||||
@@ -319,7 +317,7 @@ class App: AppCenterApplication, NSApplicationDelegate {
|
|||||||
thumbnailsPanel.show()
|
thumbnailsPanel.show()
|
||||||
Windows.previewFocusedWindowIfNeeded()
|
Windows.previewFocusedWindowIfNeeded()
|
||||||
guard appIsBeingUsed else { return }
|
guard appIsBeingUsed else { return }
|
||||||
Windows.refreshThumbnailsAsync(screen)
|
Windows.refreshThumbnailsAsync(screen, 0)
|
||||||
guard appIsBeingUsed else { return }
|
guard appIsBeingUsed else { return }
|
||||||
Applications.refreshBadges()
|
Applications.refreshBadges()
|
||||||
KeyRepeatTimer.toggleRepeatingKeyNextWindow()
|
KeyRepeatTimer.toggleRepeatingKeyNextWindow()
|
||||||
|
|||||||
Reference in new issue
Block a user