Re: Trouble centering window after mode switch (solved)
Re: Trouble centering window after mode switch (solved)
- Subject: Re: Trouble centering window after mode switch (solved)
- From: "Matt R" <email@hidden>
- Date: Tue, 30 Jan 2007 16:00:01 -0800
Never got any replies to this, so I figured I'd post the solution, which I
finally found on the idevgames forum. [[NSScreen mainDisplay] frame]; will
return the wrong values unless you allow the app to return to the main event
loop first after switching modes. Still looking for specifics on why AppKit
doesn't mix well with fullscreen drawing. The bulk of my app was written
with appkit and cocoa classes before trying to implement this fullscreen
functionality, which was a bad move, but I didn't know any better. But
still, everyone seems to just spout out these generalized warnings but I
can't find any details on where the actual problems are between capturing
the display and appkit. The rest of my app, including all the drawing
routines, seem to be running great. Guess I'll keep my fingers crossed.
~matt
On 1/29/07, Matt R <email@hidden> wrote:
hi all cocoa gurus,
Could anyone give me some advice on the following issue? I have an app
that does the following:
1) fades monitor
2) captures display
3) switches display modes (resolution change)
4) sets up window in center of the screen
5) fades out
6) does its drawing
7) then restores original mode, releases display, and quits
The problem is that the code I had originally used to center the window:
//window is 800x600
screenRect = [[NSScreen mainScreen] frame];
[splashWindow setLevel:CGShieldingWindowLevel()];
[splashWindow setFrameTopLeftPoint:NSMakePoint( (
screenRect.size.width /2.0)-400,
(
screenRect.size.height/2.0)+300)];
Does not work properly and instead seems to retain its location as if the
monitor were still at the larger resolution size (ie, the window is moved
half offscreen to the bottom right). Funny thing is that if I switch the
code around so that I switch display modes before capturing the screen, the
same code as above works fine in the new resolution. The only problem with
that code is that once I've quit my app, I find all the windows in the other
running applications have been moved around since they adjusted their window
locations based on the switch as well.
To simplify: I'm having difficulty pinpointing how/when to adjust my
window properly. If I capture the display first before switching modes, and
try to center my window, it's almost as if I never switched at all, and I
can't seem to center the window properly. Doing the opposite, and switching
modes before capturing the display, allows me to use the same code as above
and the window is perfectly centered, but all my other apps on the system
get their window locations screwed up.
I'm sorry if I'm overlooking the obvious. I've been trying to squash this
bug for about 10 days, just can't figure out what I'm missing.
Any help or advice is much appreciated. thank you for your time.
-matt
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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