Last active
December 29, 2022 13:01
-
-
Save sdsykes/5c2c0c2a41396aead3b7 to your computer and use it in GitHub Desktop.
Windows on a space (using private CGS)
This file contains 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
/// header | |
id CGSCopyManagedDisplaySpaces(int conn); | |
int _CGSDefaultConnection(); | |
id CGSCopyWindowsWithOptionsAndTags(int conn, unsigned owner, NSArray *spids, unsigned options, unsigned long long *setTags, unsigned long long *clearTags); | |
// code | |
int spaceNumber = 0; // the space you want to get the windows for. numbering starts at 0. | |
int conn = _CGSDefaultConnection(); | |
NSArray *info = CGSCopyManagedDisplaySpaces(conn); | |
NSLog(@"space info: %@", info); | |
unsigned long long setTags = 0, clearTags = 0x4000000000; | |
int displayNumber = 0; | |
NSNumber *spaceID = info[displayNumber][@"Spaces"][spaceNumber][@"id64"]; | |
NSArray *windows = CGSCopyWindowsWithOptionsAndTags(conn, 0, @[spaceID], 2, &setTags, &clearTags); | |
NSLog(@"windows on space %d are %@", spaceNumber, windows); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment