Skip to content

Commit

Permalink
fix: ignore trigger shortcuts if mission control is active
Browse files Browse the repository at this point in the history
  • Loading branch information
louis.pontoise authored and lwouis committed Mar 10, 2020
1 parent 547311e commit b03b0aa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 9 additions & 0 deletions alt-tab-macos/api-wrappers/CGWindow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ extension CGWindow {
return CGWindowListCopyWindowInfo([.excludeDesktopElements, option], kCGNullWindowID) as! [CGWindow]
}

static func isMissionControlActive() -> Bool {
// when Mission Control is active, the Dock process spawns some windows. We observe this side-effect and infer
for window in windows(.optionOnScreenOnly) {
guard window.ownerName() == "Dock" else { continue }
return true
}
return false
}

// workaround: filtering this criteria seems to remove non-windows UI elements
func isNotMenubarOrOthers() -> Bool {
return layer() == 0
Expand Down
3 changes: 2 additions & 1 deletion alt-tab-macos/ui/App.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class App: NSApplication, NSApplicationDelegate, NSWindowDelegate {
if isFirstSummon {
debugPrint("showUiOrCycleSelection: isFirstSummon")
isFirstSummon = false
if Windows.listRecentlyUsedFirst.count == 0 {
if Windows.listRecentlyUsedFirst.count == 0 || CGWindow.isMissionControlActive() {
appIsBeingUsed = false
isFirstSummon = true
return
Expand Down Expand Up @@ -112,6 +112,7 @@ class App: NSApplication, NSApplicationDelegate, NSWindowDelegate {

func focusSelectedWindow(_ window: Window?) {
hideUi()
guard !CGWindow.isMissionControlActive() else { return }
window?.focus()
}
}

0 comments on commit b03b0aa

Please sign in to comment.