Created
November 7, 2025 08:18
-
-
Save usagimaru/812b493ca27cac707e76917f7a9bf6a9 to your computer and use it in GitHub Desktop.
Detect Mission Control / Exposé Mode in Swift (macOS 26 Tahoe)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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