Created
November 11, 2012 07:19
-
-
Save puffnfresh/4054059 to your computer and use it in GitHub Desktop.
Demo of Spaces API discovered via reverse engineering
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
#include <Carbon/Carbon.h> | |
typedef uint64_t CGSConnection; | |
extern CGSConnection _CGSDefaultConnection(void); | |
#define CGSDefaultConnection _CGSDefaultConnection() | |
typedef uint64_t CGSSpace; | |
typedef enum _CGSSpaceType { | |
kCGSSpaceUser, | |
kCGSSpaceFullscreen, | |
kCGSSpaceSystem, | |
kCGSSpaceUnknown | |
} CGSSpaceType; | |
typedef enum _CGSSpaceSelector { | |
kCGSSpaceCurrent = 5, | |
kCGSSpaceAll = 7 | |
} CGSSpaceSelector; | |
extern CFArrayRef CGSCopySpaces(const CGSConnection cid, CGSSpaceSelector type); | |
extern CFArrayRef CGSSpaceCopyOwners(const CGSConnection cid, CGSSpace space); | |
extern int CGSSpaceGetAbsoluteLevel(const CGSConnection cid, CGSSpace space); | |
extern void CGSSpaceSetAbsoluteLevel(const CGSConnection cid, CGSSpace space, int level); | |
extern int CGSSpaceGetCompatID(const CGSConnection cid, CGSSpace space); | |
extern void CGSSpaceSetCompatID(const CGSConnection cid, CGSSpace space, int compatID); | |
extern CGSSpaceType CGSSpaceGetType(const CGSConnection cid, CGSSpace space); | |
extern void CGSSpaceSetType(const CGSConnection cid, CGSSpace space, CGSSpaceType type); | |
extern CFStringRef CGSSpaceCopyName(const CGSConnection cid, CGSSpace space); | |
extern void CGSSpaceSetName(const CGSConnection cid, CGSSpace space, CFStringRef name); | |
extern CFArrayRef CGSSpaceCopyValues(const CGSConnection cid, CGSSpace space); | |
extern void CGSSpaceSetValues(const CGSConnection cid, CGSSpace space, CFArrayRef values); | |
typedef uint64_t CGSManagedDisplay; | |
extern CFArrayRef CGSCopyManagedDisplaySpaces(const CGSConnection cid); | |
extern bool CGSManagedDisplayIsAnimating(const CGSConnection cid, CGSManagedDisplay display); | |
extern void CGSManagedDisplaySetIsAnimating(const CGSConnection cid, CGSManagedDisplay display, bool isAnimating); | |
extern CGSSpace PKGManagedDisplayGetCurrentSpace(const CGSConnection cid, CGSManagedDisplay display); | |
extern void CGSManagedDisplaySetCurrentSpace(const CGSConnection cid, CGSManagedDisplay display, CGSSpace space); | |
extern CGSManagedDisplay kCGSPackagesMainDisplayIdentifier; | |
int main(int argc, char *argv[]) { | |
while(1) { | |
CFArrayRef spaces = CGSCopySpaces(CGSDefaultConnection, kCGSSpaceAll); | |
int i; | |
for(i = 0; i < CFArrayGetCount(spaces); i++) { | |
CGSSpace space = [CFArrayGetValueAtIndex(spaces, i) intValue]; | |
CFShow(CGSSpaceCopyName(CGSDefaultConnection, space)); | |
printf("Space ID: %lld\n", space); | |
printf("Absolute level: %d\n", CGSSpaceGetAbsoluteLevel(CGSDefaultConnection, space)); | |
printf("Compat ID: %d\n", CGSSpaceGetCompatID(CGSDefaultConnection, space)); | |
printf("Type: %d\n", CGSSpaceGetType(CGSDefaultConnection, space)); | |
printf("\n"); | |
} | |
printf("-----------------\n"); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment