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

CGDisplayIOServicePort and SetFrontProcess deprecated on 10.9 #165

Closed
fatto opened this issue Oct 27, 2013 · 8 comments
Closed

CGDisplayIOServicePort and SetFrontProcess deprecated on 10.9 #165

fatto opened this issue Oct 27, 2013 · 8 comments
Assignees
Labels
enhancement Feature suggestions and PRs macOS
Milestone

Comments

@fatto
Copy link

fatto commented Oct 27, 2013

Starting from Mavericks 'CGDisplayIOServicePort' and 'SetFrontProcess' are deprecated
the warnings are from:

  • cocoa_monitor.m:48:42: info = IODisplayCreateInfoDictionary(CGDisplayIOServicePort(displayID)
  • cocoa_window.m:823:5: SetFrontProcess(&psn);
@ghost ghost assigned elmindreda Oct 27, 2013
@dmitshur
Copy link
Collaborator

What are the suggested replacements?

@elmindreda
Copy link
Member

@shurcooL I think there's a replacement for SetFrontProcess in NSApplication. No idea about the other one.

@fatto
Copy link
Author

fatto commented Oct 28, 2013

from here seems that there's no replacement for CGDisplayIOServicePort
for SetFrontProcess there's this answer from SO that should do the work:

NSRunningApplication* app = [NSRunningApplication runningApplicationWithProcessIdentifier: PID];
[app activateWithOptions: NSApplicationActivateAllWindows];

@elmindreda
Copy link
Member

There may not be a direct replacement for CGDisplayIOServicePort, but there must be some new way of retrieving the name of a display.

@elmindreda
Copy link
Member

SetFrontProcess has been replaced with ec5cb9c.

@elmindreda
Copy link
Member

  • SetFrontProcess
  • CGDisplayIOServicePort

@mhenr18
Copy link
Contributor

mhenr18 commented Dec 13, 2013

You can create a matching dictionary for IO services of class "IODisplayConnect" and then use IOServiceGetMatchingServices to iterate over the services - they will map to the connected displays.

I've written an implementation (pull request #192) that then compares the product and vendor IDs between the info dictionary for each of those displays and what the CG APIs are returning for the one we're interested in - that should get things right most of the time. I'd use the serial number too but it doesn't appear to be present for all displays.

(sorry if that pull request isn't perfectly lining up with the project's coding style - I needed to implement it personally while working on some custom functionality and figured I'd share)

@elmindreda
Copy link
Member

@mhenr18 Excellent. Will review.

elmindreda pushed a commit that referenced this issue Nov 16, 2016
This could be cleaned up and refined a bit by comparing more display
attributes when available, but it gets the job done.

Fixes #165.
Closes #192.
elmindreda pushed a commit that referenced this issue Nov 16, 2016
This replaces CGDisplayIOServicePort with manually finding a service
port with matching vendor and product IDs.  This may technically not be
the one corresponding to the display ID, but it is only used to retrieve
the human-readable make/model string.

This could be cleaned up and refined a bit by comparing more display
attributes when available, but it gets the job done.

Fixes #165.
Closes #192.
Closes #508.
Closes #511.
LWJGL-CI pushed a commit to LWJGL-CI/glfw that referenced this issue Dec 3, 2016
This replaces CGDisplayIOServicePort with manually finding a service
port with matching vendor and product IDs.  This may technically not be
the one corresponding to the display ID, but it is only used to retrieve
the human-readable make/model string.

This could be cleaned up and refined a bit by comparing more display
attributes when available, but it gets the job done.

Fixes glfw#165.
Closes glfw#192.
Closes glfw#508.
Closes glfw#511.
LWJGL-CI pushed a commit to LWJGL-CI/glfw that referenced this issue Dec 3, 2016
This replaces CGDisplayIOServicePort with manually finding a service
port with matching vendor and product IDs.  This may technically not be
the one corresponding to the display ID, but it is only used to retrieve
the human-readable make/model string.

This could be cleaned up and refined a bit by comparing more display
attributes when available, but it gets the job done.

Fixes glfw#165.
Closes glfw#192.
Closes glfw#508.
Closes glfw#511.
LWJGL-CI pushed a commit to LWJGL-CI/glfw that referenced this issue Dec 4, 2016
This replaces CGDisplayIOServicePort with manually finding a service
port with matching vendor and product IDs.  This may technically not be
the one corresponding to the display ID, but it is only used to retrieve
the human-readable make/model string.

This could be cleaned up and refined a bit by comparing more display
attributes when available, but it gets the job done.

Fixes glfw#165.
Closes glfw#192.
Closes glfw#508.
Closes glfw#511.
LWJGL-CI pushed a commit to LWJGL-CI/glfw that referenced this issue Dec 4, 2016
This replaces CGDisplayIOServicePort with manually finding a service
port with matching vendor and product IDs.  This may technically not be
the one corresponding to the display ID, but it is only used to retrieve
the human-readable make/model string.

This could be cleaned up and refined a bit by comparing more display
attributes when available, but it gets the job done.

Fixes glfw#165.
Closes glfw#192.
Closes glfw#508.
Closes glfw#511.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature suggestions and PRs macOS
Projects
None yet
Development

No branches or pull requests

4 participants