[NSWindow center] not centering

Member
Posts: 129
Joined: 2005.02
Post: #1
I've come to find that if I switch capture displays, switch resolutions, and then switch and uncapture back to my desktop settings, my center: method will not center my windows. Also, if I specifically createa NSWindow with a specified origin, it will only validate the x origin but not the y origin.

This only happens if I start my game in full screen and switch back in forth.

However, if I start the game in windowed mode, and switch back and forth, it centers properly.


Anyone run into this problem, or know of any work arounds?

EDIT: I mixed up my switch and uncapture.
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #2
maaaaark Wrote:I switch capture displays, switch resolutions, and then uncapture and switch back to my desktop settings

The correct order is:
1) capture display
2) switch resolution
3) <do stuff>
4) switch resolution back to original
5) uncapture display

if you're uncapturing before switching back, you're breaking other apps.
Quote this message in a reply
Member
Posts: 129
Joined: 2005.02
Post: #3
Sorry, that is what I do... (I edited my original post to reflect).

I do the correct order... AppKit just doesn't want to center my window.
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #4
maaaaark Wrote:my center: method will not center my windows.
What does it do instead?

When are you going fullscreen during app startup? appWillFinishLaunching is too early.
Quote this message in a reply
Member
Posts: 129
Joined: 2005.02
Post: #5
I think I am calling my C++ engine in appWillFInishLaunching. Why is that too early, thats very interesting.
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #6
The window manager hasn't finished setting up your menu bar and whatnot by appWillFinishLaunching. I've found this to cause problems with fullscreen. Try appDidFinish... instead.
Quote this message in a reply
Member
Posts: 129
Joined: 2005.02
Post: #7
I'm sorry, I have my mind on auto-complete tonight... Smile

It WAS applicationDidFinishLaunching... I just read the app..........FnishLaunching and filled in the blank. So I'm still at a blank. I THINK i'm not gonna create new windows, but just resize them (if need be) on screen changes... and initially create the window but not show.. until it reads the defaults and decides to go fullscreen or stay in windowed.
Quote this message in a reply
Member
Posts: 129
Joined: 2005.02
Post: #8
If anyone cares, or runs into the same problem I did...
If you do not return to the main event loop after you switch your display. [[NSScreen maindisplay] frame]; WILL RETURN WRONG VALUES.

For example, if I am in 1600x1200, and switch to 640x480, and then back to 1600x1200, NSScreen will report that I am still in 640x480, making setting window coordinates a small pain. You just have to compensate by adjusting origin.y.

This only seems to be a problem if you initallly create your window in fullscreen mode... as opposed to a windowed mode, and toggle between window/fullscreen.

Ninja
Quote this message in a reply
Member
Posts: 469
Joined: 2002.10
Post: #9
CocoaBlitz has code to compensate for this bug.
http://variableaspect.com/experiments/Co...aBlitz.zip

in CBView.m see -enterFullScreen;

---Kelvin--
15.4" MacBook Pro revA
1.83GHz/2GB/250GB
Quote this message in a reply
Member
Posts: 129
Joined: 2005.02
Post: #10
Yeah, my last post concluded from the CocoaBlitz code--the author answered my original question on the Mac-games-dev mailing list, and I was just posting the solution here Smile
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  finding a training center - Heeeelp Glauter 1 2,942 Dec 26, 2011 12:30 PM
Last Post: zenkimoto
  centering a sprite in the middle of the screen convertToWorldSpace / NodeSpace sefiroths 0 3,006 Dec 21, 2011 01:25 AM
Last Post: sefiroths
  NSWindow frame message not returning correct values after moving the window Svarog 6 4,822 Jan 7, 2007 06:41 PM
Last Post: OneSadCookie
  Generating Corner points of Rectangular Box using center point and forward vector 3DPat 6 5,728 Nov 13, 2006 09:40 PM
Last Post: 3DPat
  Camera work. centering mouse FreeKQuency23 5 3,938 Apr 14, 2006 01:14 AM
Last Post: akb825