I am creating a window switcher for macOS.
I am using CGWindowListCopyWindowInfo to get the list of open windows.
let windows = CGWindowListCopyWindowInfo([.excludeDesktopElements], kCGNullWindowID)
I am not using the optionOnScreenOnly option along with CGWindowListCopyWindowInfo because that excludes off-space windows.
However, this leads to certain dummy windows also getting included in the list of windows. For example, there is a window present for each open tab on Xcode. There is also an additional invisible window for VLC player apart from the actual window. These windows aren't present if I use optionOnScreenOnly.
Is there a way to separate these dummy windows from actual windows?
I have explored the kCGWindowLayer and kCGWindowStoreType keys in the dictionaries returned by CGWindowListCopyWindowInfo but couldn't tell the windows apart.
Edit:
I am open to both Swift and Objective-C solutions, as well as private API calls.
Edit 2:
I know this is possible to do because the app Witch handles these cases correctly.