Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: How to show window without having it come to the front?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to show window without having it come to the front?




On Jun 6, 2006, at 11:07 AM, David Niemeijer wrote:

At 8:07 -0700 6/6/06, Eric Schlegel wrote:
Yes, this is definitely a bug. The Window Manager (actually the CoreGraphics window server) is supposed to layer a newly visible window behind the active window of the active app, not in front. The bug is actually not in the application that is showing the window, but in the active application; somehow its active window is not being properly recorded and passed to the window server.

If you, or David, can reliable reproduce this problem, please file bugs and send me the bug numbers. We need repro cases to determine why the active window isn't being properly recorded.

It took me some time to figure out the exact conditions that cause the problem, because when I built a test app of course the problem first did not appear. But in the end I figured it out and build a test app and filed a bug. See bug: 4575443. The problem only occurs when the background app has a visible utility window. I guess that confuses the window ordering.

Ah, yes, I see the problem. When you show the new document window, the Window Manager tells the window server to position it behind the window that it is behind in your app's window list. That's the utility window. Since the utility window is at a higher window level than the document windows of the frontmost app, this causes your document to be positioned above the windows of the frontmost app.


I doubt this is causing all of the problems that Steve mentioned seeing, though. Steve, if you come up with any other reproducible cases, please let me know.

I have some ideas for how to fix this in the Window Manager for Leopard. As a workaround for pre-Leopard, I suggest disabling screen updates, hiding all of the visible windows in the utility window group, showing your document window, showing the windows in the utility group again, and then enabling screen updates. I tested this in your sample app and it worked. Here's my modifications to HandleNew ():

	WindowGroupRef		group;
	WindowRef*		windows;
	ItemCount		windowCount;
	ItemCount		i;

DisableScreenUpdates();

group = GetWindowGroupOfClass( kUtilityWindowClass );
windowCount = CountWindowGroupContents( group, kWindowGroupContentsReturnWindows | kWindowGroupContentsRecurse | kWindowGroupContentsVisible );
windows = (WindowRef*) alloca( sizeof( WindowRef ) * windowCount );
GetWindowGroupContents( group, kWindowGroupContentsReturnWindows | kWindowGroupContentsRecurse | kWindowGroupContentsVisible,
windowCount, &windowCount, (void**) windows );
for ( i = 0; i < windowCount; i++ )
ShowHide( windows[i], false );

// The window was created hidden, so show it
ShowWindow( window );


	for ( i = 0; i < windowCount; i++ )
		ShowHide( windows[i], true );

	EnableScreenUpdates();

-eric



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >How to show window without having it come to the front? (From: David Niemeijer <email@hidden>)
 >Re: How to show window without having it come to the front? (From: David Alger <email@hidden>)
 >Re: How to show window without having it come to the front? (From: David Niemeijer <email@hidden>)
 >Re: How to show window without having it come to the front? (From: "Steve Mills" <email@hidden>)
 >Re: How to show window without having it come to the front? (From: Eric Schlegel <email@hidden>)
 >Re: How to show window without having it come to the front? (From: David Niemeijer <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.