Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save own2pwn/b101a059c566b3d70375f6e8e662559f to your computer and use it in GitHub Desktop.
Save own2pwn/b101a059c566b3d70375f6e8e662559f to your computer and use it in GitHub Desktop.
#import <Foundation/Foundation.h>
typedef uint64_t CGSSpace;
typedef uint64_t CGSManagedDisplay;
typedef int CGSConnection;
typedef enum _CGSSpaceSelector {
kCGSSpaceCurrent = 5,
kCGSSpaceOther = 6,
kCGSSpaceAll = 7
} CGSSpaceSelector;
extern CGSManagedDisplay kCGSPackagesMainDisplayIdentifier;
extern CFArrayRef CGSCopySpaces(const CGSConnection cid, CGSSpaceSelector type);
extern void CGSManagedDisplaySetCurrentSpace(const CGSConnection cid, CGSManagedDisplay display, CGSSpace space, CGSSpace space2);
extern int CGSManagedDisplayGetCurrentSpace(const CGSConnection cid, CGSManagedDisplay display);
extern void CGSShowSpaces(const CGSConnection cid, CFArrayRef spaces);
extern void CGSHideSpaces(const CGSConnection cid, CFArrayRef spaces);
extern CGSConnection _CGSDefaultConnection(void);
extern id CGSWillSwitchSpaces(const CGSConnection cid, CFArrayRef spaces);
int main(int argc, char *argv[]) {
@autoreleasepool {
NSLog(@"Current space: %d", CGSManagedDisplayGetCurrentSpace(_CGSDefaultConnection(), kCGSPackagesMainDisplayIdentifier));
NSArray *spaces = @[ ];
id result = CGSWillSwitchSpaces(_CGSDefaultConnection(), (__bridge CFArrayRef)spaces);
NSLog(@"Will change spaces result: %@", result);
CGSManagedDisplaySetCurrentSpace(_CGSDefaultConnection(), kCGSPackagesMainDisplayIdentifier, 3, 3);
spaces = @[ @1, @3 ];
CGSShowSpaces(_CGSDefaultConnection(), (__bridge CFArrayRef)spaces);
spaces = @[ @1 ];
CGSHideSpaces(_CGSDefaultConnection(), (__bridge CFArrayRef)spaces);
NSLog(@"Current space: %d", CGSManagedDisplayGetCurrentSpace(_CGSDefaultConnection(), kCGSPackagesMainDisplayIdentifier));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment