CGDisplayBounds vs NSSCreen visibleFrame
CGDisplayBounds vs NSSCreen visibleFrame
- Subject: CGDisplayBounds vs NSSCreen visibleFrame
- From: Trygve Inda <email@hidden>
- Date: Sat, 26 Jul 2008 23:36:35 +0000
- Thread-topic: CGDisplayBounds vs NSSCreen visibleFrame
I have a 23" Cinema as my main display and a 17" PB as my secondary. The
Cinema is arranged to the right of the PB.
When I call NSScreen -visibleFrame on the secondary screen, I get a y origin
of -774 but when calling CGDisplayBounds it is 924. The secondary screen
height is 1050 and the height of the main screen is 1200.
I understand this is a coordinate system issue, and think this is true:
visibleFrame places its global origin at the bottom left of the main display
with y increasing upwards and treats the bottom left of a display as the
origin. So for this call it shows 774px below the origin and thus 276px
above.
CGDisplayBounds places its global origin at the top left of the main display
with y increasing downwards and treats the top left of a display as the
origin.
Correct?
So, given a CGDirectDisplayID, I need to get the frame in a Quartz-like
coordinate system (global 0,0 at bottom left).
With a CGDirectDisplayID and CGDisplayBounds, and assuming the visibleFrame
way is the new, preferred way, is it safe to use this to covert origins?
mainScreenRect = CGDisplayBounds (CGMainDisplayID ());
mainHeight = mainScreenRect.size.height;
auxScreenRect = CGDisplayBounds (myScreen)
auxHeight = auxScreenRect.size.height;
NewY = OldY + auxHeight - mainHeight * -1;
-774 = 924 + 1050 - 1200 * -1
There doesn't seem to be a way to get an NSScreen from a CGDirectDisplayID
short of walking the list and looking for it... Maybe this is better - then
I can just call -visibleFrame?
Thoughts?
Thanks!
_______________________________________________
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