fix: highlight right thumbnail when no window is focused (closes #1044)
This commit is contained in:
1 parent
4623e5b7c4
commit
f4d3db790e
4 files changed
+33
-2
No files matched your search
@@ -14,6 +14,7 @@ class Application: NSObject {
|
|||||||
var dockLabel: String?
|
var dockLabel: String?
|
||||||
var pid: pid_t { runningApplication.processIdentifier }
|
var pid: pid_t { runningApplication.processIdentifier }
|
||||||
var wasLaunchedBeforeAltTab = false
|
var wasLaunchedBeforeAltTab = false
|
||||||
|
var focusedWindow: Window? = nil
|
||||||
|
|
||||||
static func notifications(_ app: NSRunningApplication) -> [String] {
|
static func notifications(_ app: NSRunningApplication) -> [String] {
|
||||||
let n = [
|
let n = [
|
||||||
|
|||||||
@@ -24,6 +24,29 @@ class Windows {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static func setInitialFocusedWindowIndex() {
|
||||||
|
if let app = Applications.list.first { $0.pid == NSWorkspace.shared.frontmostApplication?.processIdentifier },
|
||||||
|
app.focusedWindow == nil,
|
||||||
|
let lastFocusedWindowIndex = getLastFocusedWindowIndex() {
|
||||||
|
updateFocusedWindowIndex(lastFocusedWindowIndex)
|
||||||
|
} else {
|
||||||
|
updateFocusedWindowIndex(0)
|
||||||
|
cycleFocusedWindowIndex(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static func getLastFocusedWindowIndex() -> Int? {
|
||||||
|
var index: Int? = nil
|
||||||
|
var lastFocusOrderMin = Int.max
|
||||||
|
Windows.list.enumerated().forEach {
|
||||||
|
if !$0.element.isWindowlessApp && $0.element.lastFocusOrder < lastFocusOrderMin {
|
||||||
|
lastFocusOrderMin = $0.element.lastFocusOrder
|
||||||
|
index = $0.offset
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return index
|
||||||
|
}
|
||||||
|
|
||||||
static func appendAndUpdateFocus(_ window: Window) {
|
static func appendAndUpdateFocus(_ window: Window) {
|
||||||
list.forEach {
|
list.forEach {
|
||||||
$0.lastFocusOrder += 1
|
$0.lastFocusOrder += 1
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ fileprivate func applicationActivated(_ element: AXUIElement, _ pid: pid_t) thro
|
|||||||
app.hasBeenActiveOnce = true
|
app.hasBeenActiveOnce = true
|
||||||
}
|
}
|
||||||
let window = (appFocusedWindow != nil && wid != nil) ? Windows.updateLastFocus(appFocusedWindow!, wid!)?.first : nil
|
let window = (appFocusedWindow != nil && wid != nil) ? Windows.updateLastFocus(appFocusedWindow!, wid!)?.first : nil
|
||||||
|
app.focusedWindow = window
|
||||||
App.app.checkIfShortcutsShouldBeDisabled(window, app.runningApplication)
|
App.app.checkIfShortcutsShouldBeDisabled(window, app.runningApplication)
|
||||||
App.app.refreshOpenUi(window != nil ? [window!] : nil)
|
App.app.refreshOpenUi(window != nil ? [window!] : nil)
|
||||||
}
|
}
|
||||||
@@ -123,6 +124,13 @@ fileprivate func focusedWindowChanged(_ element: AXUIElement, _ pid: pid_t) thro
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
Applications.list.first { $0.pid == pid }?.focusedWindow = Windows.list.first { $0.isEqualRobust(element, wid) }
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
Applications.list.first { $0.pid == pid }?.focusedWindow = nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-2
@@ -252,8 +252,7 @@ class App: AppCenterApplication, NSApplicationDelegate {
|
|||||||
Windows.refreshWhichWindowsToShowTheUser(screen)
|
Windows.refreshWhichWindowsToShowTheUser(screen)
|
||||||
Windows.reorderList()
|
Windows.reorderList()
|
||||||
if (!Windows.list.contains { $0.shouldShowTheUser }) { hideUi(); return }
|
if (!Windows.list.contains { $0.shouldShowTheUser }) { hideUi(); return }
|
||||||
Windows.updateFocusedWindowIndex(0)
|
Windows.setInitialFocusedWindowIndex()
|
||||||
Windows.cycleFocusedWindowIndex(1)
|
|
||||||
delayedDisplayScheduled += 1
|
delayedDisplayScheduled += 1
|
||||||
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + Preferences.windowDisplayDelay) { () -> () in
|
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + Preferences.windowDisplayDelay) { () -> () in
|
||||||
if self.delayedDisplayScheduled == 1 {
|
if self.delayedDisplayScheduled == 1 {
|
||||||
|
|||||||
Reference in new issue
Block a user