Created
April 11, 2016 22:01
-
-
Save mmmulani/7a47f33db62bb040e495e3f11e12b6bd to your computer and use it in GitHub Desktop.
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
#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