Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IOServicePortFromCGDisplayID is deprecated and crashing. #17

Open
Izzatbek opened this issue Feb 18, 2017 · 1 comment
Open

IOServicePortFromCGDisplayID is deprecated and crashing. #17

Izzatbek opened this issue Feb 18, 2017 · 1 comment

Comments

@Izzatbek
Copy link
Collaborator

IOServicePortFromCGDisplayID inside osxDisplayDeviceManager is crashing on my machine (10.11.6). We need to replace it.

@rob-smallshire
Copy link

I found this page while debugging my own code which uses code similar to IOServicePortFromCGDisplayID. I found you need to call CGGetOnlineDisplayList first, otherwise various calls in the implementation will hang.

Try something like this:

    const int MAX_DISPLAYS = 16;
    CGDisplayCount    displayCount, i;
    CGDisplayCount    maxDisplays = MAX_DISPLAYS;
    CGDirectDisplayID onlineDisplays[MAX_DISPLAYS];
    CGDisplayErr err = CGGetOnlineDisplayList(maxDisplays, onlineDisplays, &displayCount);
    if (err != kCGErrorSuccess) {
        fprintf(stderr, "CGGetOnlineDisplayList: error %d.\n", err);
        exit(1);
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants