Skip to content

Instantly share code, notes, and snippets.

@usagimaru
Created November 7, 2025 08:18
Show Gist options
  • Select an option

  • Save usagimaru/812b493ca27cac707e76917f7a9bf6a9 to your computer and use it in GitHub Desktop.

Select an option

Save usagimaru/812b493ca27cac707e76917f7a9bf6a9 to your computer and use it in GitHub Desktop.
Detect Mission Control / Exposé Mode in Swift (macOS 26 Tahoe)
func isMissionControlActive() -> Bool {
let windowList = (CGWindowListCopyWindowInfo([.optionOnScreenOnly], CGWindowID(0)) as? [[String: Any]]) ?? [[:]]
for windowInfo in windowList {
if let windowOwnerPID = windowInfo["kCGWindowOwnerPID"] as? pid_t,
let app = NSRunningApplication(processIdentifier: windowOwnerPID),
app.bundleIdentifier == "com.apple.dock"
{
if windowInfo["kCGWindowLayer"] as? Int == 18 && windowInfo["kCGWindowSharingState"] as? Bool == false {
if let bounds = windowInfo["kCGWindowBounds"] as? NSDictionary,
bounds["X"] as? Int == 0, bounds["Y"] as? Int == 0 {
return true
}
}
}
}
return false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment