Skip to content

Commit

Permalink
fix: Update datetime only for the focused window
Browse files Browse the repository at this point in the history
Currently, when an app is activated or focused, the datetime
of all its windows is updated. This causes all app windows
to be sorted to the front in the window switcher, making it
confusing and harder to use.

Now, only the focused window’s datetime is updated, providing
a more intuitive experience and aligning with Windows OS behavior.

Partially fixes ejbills#479
  • Loading branch information
bestbandari committed Feb 15, 2025
1 parent fd789f2 commit c65e2da
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions DockDoor/Utilities/Window Management/WindowUtil.swift
Original file line number Diff line number Diff line change
Expand Up @@ -320,15 +320,13 @@ enum WindowUtil {
return
}
let appElement = AXUIElementCreateApplication(app.processIdentifier)
if let windows = try? appElement.windows() {
for window in windows {
if let cgWindowId = try? window.cgWindowId(), let index = windowSet.firstIndex(where: { $0.id == cgWindowId }) {
var updatedWindow = windowSet[index]
updatedWindow.date = Date()
windowSet.remove(at: index)
windowSet.insert(updatedWindow)
return
}
if let window = try? appElement.focusedWindow() {
if let cgWindowId = try? window.cgWindowId(), let index = windowSet.firstIndex(where: { $0.id == cgWindowId }) {
var updatedWindow = windowSet[index]
updatedWindow.date = Date()
windowSet.remove(at: index)
windowSet.insert(updatedWindow)
return
}
}
}
Expand Down

0 comments on commit c65e2da

Please sign in to comment.