• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: CGDisplayIOServicePort deprecated in 10.9... IOServicePortFromCGDisplayID?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CGDisplayIOServicePort deprecated in 10.9... IOServicePortFromCGDisplayID?


  • Subject: Re: CGDisplayIOServicePort deprecated in 10.9... IOServicePortFromCGDisplayID?
  • From: Trygve Inda <email@hidden>
  • Date: Mon, 16 Jun 2014 06:04:10 -0700
  • Thread-topic: CGDisplayIOServicePort deprecated in 10.9... IOServicePortFromCGDisplayID?

> What do you need the IOServicePort for?

This GitHub comment provides the
> outline of a solution for getting
information about individual displays, which
> would seem to be more
verbose but safer than granting client apps access to
> the window
server's mach
> ports:
https://github.com/glfw/glfw/issues/165#issuecomment-30515700

On machines with dual GPUs and auto-switching (or even manual switching),
when the GPU changes, the CGDisplayID changes too, and not in a documented
way (although in pratice they seem to differ by 2)

The following code will obtain a string from a CGDisplayID that does not
change when the GPU changes, yet is different for each screen.


-(NSString *)ioDisplayKeyForCGDisplayID:(CGDirectDisplayID)cgDisplayID
{
  io_service_t    servicePort = CGDisplayIOServicePort (cgDisplayID);
  io_service_t    root = IODisplayForFramebuffer (servicePort, kNilOptions);
  NSDictionary*   ioRegistryDict = nil;
  NSString*       prefsKey = nil;

  IORegistryEntryCreateCFProperties (root, (CFMutableDictionaryRef*)
  &ioRegistryDict, kCFAllocatorDefault, kNilOptions);

  if (ioRegistryDict)
     prefsKey = [ioRegistryDict objectForKey:@"IODisplayPrefsKey"];


  return (prefsKey);
}

Ultimately, I am trying to identify a screen in a way that will not be
affected by the system changing GPUs, nor by the user rearranging the
screens.

Trygve






_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


References: 
 >Re: CGDisplayIOServicePort deprecated in 10.9... IOServicePortFromCGDisplayID? (From: Kyle Sluder <email@hidden>)

  • Prev by Date: Re: CGDisplayIOServicePort deprecated in 10.9... IOServicePortFromCGDisplayID?
  • Next by Date: Autolayout Animation in UITableViewCell
  • Previous by thread: Re: CGDisplayIOServicePort deprecated in 10.9... IOServicePortFromCGDisplayID?
  • Next by thread: Autolayout Animation in UITableViewCell
  • Index(es):
    • Date
    • Thread