Re: Wrong placement with -[NSWindow initWithContentRect:styleMask:backing:defer:screen:]
Re: Wrong placement with -[NSWindow initWithContentRect:styleMask:backing:defer:screen:]
- Subject: Re: Wrong placement with -[NSWindow initWithContentRect:styleMask:backing:defer:screen:]
- From: Graham Cox <email@hidden>
- Date: Sun, 7 Feb 2010 17:17:46 +1100
On 06/02/2010, at 9:49 AM, Jack Repenning wrote:
> initWithContentRect:NSMakeRect( 928, 1390, 640, 480 )
[]
> With this arrangement, the visibleFrame of the secondary screen is:
> - origin.x: -593
> - origin.y: 900
> - size.width: 2560
> - size.height: 1600
So you're hard-coding the position of a window based on intimate knowledge of how your personal system happens to be set up. Presumably you can see why that might not be a good idea.
Initially placing windows can be a bit of an art, precisely because the exact size, number and placement of screens in the real world varies enormously. It's probably best to place any window initially somewhere guaranteed to exist, which means asking NSScreen for information about the screens, and placing the window somewhere valid. Then, allow the user to move it somewhere else, and remember that location. NSWindow takes care of most of that for you. You could place the window on the secondary screen initially provided that you find out a) whether it actually exists and b) where it is, and also provide a fallback case for when a) is false.
I'm not sure why you're seeing what you're seeing, given that in your case you have special knowledge that suggests the rect is valid. It might be something to do with detecting the so-called 'standard' and 'user' states of the window which are based on being 'close to' the screen's available rect, for some definition of 'close to'. But you'll have to change this code anyway to not hard code the position, so by doing it sooner rather than later you'll deal with both issues.
--Graham
_______________________________________________
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