CGDisplaySetDisplayMode only working properly after calling twice in a row
CGDisplaySetDisplayMode only working properly after calling twice in a row
- Subject: CGDisplaySetDisplayMode only working properly after calling twice in a row
- From: Matthias Dörfelt <email@hidden>
- Date: Wed, 21 May 2014 14:05:33 -0700
Hey,
I am experiencing some really weird behavior with CGDisplaySetDisplayMode behavior on osx 10.9.3 on a late 2013 retina mbp.
if I call CGDisplaySetDisplayMode only once, it seems to end up in weird display modes, that are not even listed through CGDisplayCopyAllDisplayModes i.e. oftentimes 16 bit modes. If I call CGDisplaySetDisplayMode again right afterwards, it goes to the desired mode. Here is a very simple example:
if I do:
GDisplayModeRef originalMode = CGDisplayCopyDisplayMode(CGMainDisplayID());
CGDisplaySetDisplayMode(CGMainDisplayID(), originalMode, NULL);
CGDisplayModeRelease(originalMode);
It goes from the current mode (1440x900,32 bit hidpi) to the same mode in 16 bit!!
If I do:
GDisplayModeRef originalMode = CGDisplayCopyDisplayMode(CGMainDisplayID());
CGDisplaySetDisplayMode(CGMainDisplayID(), originalMode, NULL);
CGDisplaySetDisplayMode(CGMainDisplayID(), originalMode, NULL);
CGDisplayModeRelease(originalMode);
it arrives at the correct mode.
This is the simplest test case I could come up with as I was getting similar garbage when using CGDisplayCopyAllDisplayModes
to select a specific mode, i.e:
CFArrayRef allModes = CGDisplayCopyAllDisplayModes(_id, NULL);
if(allModes)
{
for(int i = 0; i < CFArrayGetCount(allModes); i++)
{
CGDisplayModeRef mode = (CGDisplayModeRef)CFArrayGetValueAtIndex(allModes, i);
Size width = CGDisplayModeGetWidth(mode);
Size height = CGDisplayModeGetHeight(mode);
if(width == 800 && height == 600)
{
CGDisplaySetDisplayMode((CGDirectDisplayID)_id, mode, NULL);
//CGDisplaySetDisplayMode((CGDirectDisplayID)_id, mode, NULL);
break;
}
}
CFRelease(allModes);
}
Only properly goes to 800x600 if I uncomment the second call to CGDisplaySetDisplayMode this seems really odd…
Any ideas?
thanks,
Matthias
_______________________________________________
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