CGSInternal icon indicating copy to clipboard operation
CGSInternal copied to clipboard

Support for App Expose on Catalina?

Open vlad-cotfas opened this issue 5 years ago • 2 comments

Very nice about the project, I was able to detect when the mission control is active. Is there any support to check also when the App Expose is active? Thank you.

vlad-cotfas avatar May 17 '20 20:05 vlad-cotfas

Hi there @cotfas how did you manage to check whether Mission Control is active? It's something I'm also very interested in.

Thanks!

noah-nuebling avatar May 25 '21 15:05 noah-nuebling

Hello!

This one worked https://gist.github.com/puffnfresh/4054059

Readapted for my case:

`static bool isMissionControlActiveParam(CGSSpaceMask type) { printfSP("isMissionControlActiveParam %d\n", type);

CFArrayRef spaces = CGSCopySpaces(CGSDefaultConnection, type);
if (showSpacesLog) {
    NSLog(@"queried spaces: %@", spaces);
}

bool missionControlActive = false;

int i;
for(i = 0; i < CFArrayGetCount(spaces); i++) {
    
    NSNumber * val = (NSNumber *) CFArrayGetValueAtIndex(spaces, i);
    long long longValue = [val longLongValue];
    CGSSpace space = longValue;
    
    CFStringRef name = CGSSpaceCopyName(CGSDefaultConnection, space);
    if (showSpacesLog) {
        CFShow(name);
    }
    printfSP("Space ID: %lld\n", space);
    printfSP("Absolute level: %d\n", CGSSpaceGetAbsoluteLevel(CGSDefaultConnection, space));
    printfSP("Compat ID: %d\n", CGSSpaceGetCompatID(CGSDefaultConnection, space));
    printfSP("Type: %d\n", CGSSpaceGetType(CGSDefaultConnection, space));
    printfSP("\n");
    
    NSString *compareName = (NSString *)CFBridgingRelease(name);
    if ([compareName isEqualToString:@"mission-control"]) {
        printfSP("found mission-control returning true\n");
        missionControlActive = true;
    }
}
printfSP("-----------------\n");

return missionControlActive;

}`

//kCGSSpaceAll - onlyDesktop
//kCGSAllOSSpacesMask - returns mission-control on noMissionControl and also SpacesBarWindowController when yesMissionControl
//kCGSCurrentOSSpacesMask - returns mission-control/SpacesBarWindowController only on yesMissionControl

bool isActive = isMissionControlActiveParam(kCGSCurrentOSSpacesMask);

vlad-cotfas avatar Sep 18 '21 10:09 vlad-cotfas