Index: Source/NSApplication.m =================================================================== RCS file: /cvsroot/gnustep/gnustep/core/gui/Source/NSApplication.m,v retrieving revision 1.272 diff -u -a -r1.272 NSApplication.m --- Source/NSApplication.m 21 Jan 2005 20:39:18 -0000 1.272 +++ Source/NSApplication.m 26 Jan 2005 04:41:17 -0000 @@ -1219,6 +1219,11 @@ [NSException raise: NSAbortModalException format: @"abortModal"]; } +/** + * Set up modal session for theWindow, and, if it is not visible already, + * puts it up on screen, centering it if it is an NSPanel. It is then + * ordered front and made key or main window. + */ - (NSModalSession) beginModalSessionForWindow: (NSWindow*)theWindow { NSModalSession theSession; @@ -1232,13 +1237,15 @@ _session = theSession; /* - * The NSWindow documentation says runModalForWindow centers panels. - * Here would seem the best place to do it. + * This seems to match the behavior on OS X (Panther). */ - if ([theWindow isKindOfClass: [NSPanel class]]) + if ([theWindow isVisible] == NO) { - [theWindow center]; - [theWindow setLevel: NSModalPanelWindowLevel]; + if ([theWindow isKindOfClass: [NSPanel class]]) + { + [theWindow center]; + [theWindow setLevel: NSModalPanelWindowLevel]; + } } [theWindow orderFrontRegardless]; if ([self isActive] == YES) @@ -1294,6 +1301,12 @@ NSZoneFree(NSDefaultMallocZone(), theSession); } +/** + * Starts modal event loop for given window, after centering it in front on + * screen and making key. Loop is broken only by stopModal: , + * -stopModalWithCode: , or -abortModal: , at which time -endModalSession: + * is called. + */ - (int) runModalForWindow: (NSWindow*)theWindow { NSModalSession theSession = 0; @@ -1348,15 +1361,19 @@ /**

Processes any events for a modal session described by the theSession -variable. Before processing the events, it makes the session window key -and orders the window front, so there is no need to do this -separately. When finished, it returns the state of the session (i.e. +variable. When finished, it returns the state of the session (i.e. whether it is still running or has been stopped, etc)

If there are no pending events for the session, this method returns immediately.

+ Although Apple's docs state that, before processing the events, it makes the + session window key and orders the window front, this method does not attempt + to do this (due to excessive overhead). Therefore you should do it yourself + beforehand, if needed. +

+

See Also: -runModalForWindow:

*/