Skip to content

Commit

Permalink
Forgot to main thread when no windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Mnpn committed Sep 28, 2023
1 parent 1b13590 commit 39f92bd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Azayaka.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 30;
CURRENT_PROJECT_VERSION = 31;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = 35BSP6SUG9;
ENABLE_HARDENED_RUNTIME = YES;
Expand Down Expand Up @@ -315,7 +315,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 30;
CURRENT_PROJECT_VERSION = 31;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = 35BSP6SUG9;
ENABLE_HARDENED_RUNTIME = YES;
Expand Down
12 changes: 6 additions & 6 deletions Azayaka/Menu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,24 +74,24 @@ extension AppDelegate: NSMenuDelegate {
}

func refreshWindows() {
noneAvailable.isHidden = true
let validWindows = availableContent!.windows.filter { !excludedWindows.contains($0.owningApplication!.bundleIdentifier) && !$0.title!.contains("Item-0") && !$0.title!.isEmpty }
DispatchQueue.main.async { self.noneAvailable.isHidden = true }
// in sonoma, there is a new new purple thing overlaying the traffic lights, I don't really want this to show up.
// its title is simply "Window", but its bundle id is the same as the parent, so this seems like a strange bodge..
let validWindows = availableContent!.windows.filter { !excludedWindows.contains($0.owningApplication!.bundleIdentifier) && !$0.title!.contains("Item-0") && !$0.title!.isEmpty && $0.title != "Window" }

let programIDs = validWindows.compactMap { $0.windowID.description }
for window in menu.items.filter({ !programIDs.contains($0.title) && $0.identifier?.rawValue == "window" }) {
menu.removeItem(window)
}

if validWindows.isEmpty {
noneAvailable.isHidden = false
DispatchQueue.main.async { self.noneAvailable.isHidden = false }
return // nothing to add if no windows exist, so why bother
}

// add valid windows which are not yet in the list
let addedItems = menu.items.compactMap { $0.identifier?.rawValue == "window" ? $0.title : "" }
// in sonoma, there is a new new purple thing overlaying the traffic lights, I don't really want this to show up.
// its title is simply "Window", but its bundle id is the same as the parent, so this seems like a strange bodge..
for window in validWindows.filter({ !addedItems.contains($0.windowID.description) && $0.title != "Window" }) {
for window in validWindows.filter({ !addedItems.contains($0.windowID.description) }) {
newWindow(window: window)
}
}
Expand Down

0 comments on commit 39f92bd

Please sign in to comment.