mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-01 12:21:55 +00:00
Leave the focus transfer when a window closes to the window not the
application and improve the code there. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@25420 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
ddf32956fb
commit
eef9e991e9
3 changed files with 311 additions and 387 deletions
|
@ -1,3 +1,10 @@
|
|||
2007-08-28 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSApplication.m (-_windowWillClose:): Don't call
|
||||
resignKey on the window. Reorganise the code some more and add comments.
|
||||
* Source/NSWindow.m (-_lossOfKeyOrMainWindow): Check all windows
|
||||
whether they could take key or main status.
|
||||
|
||||
2007-08-28 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSCell.m (#initialize): Increase version number.
|
||||
|
|
|
@ -519,7 +519,6 @@ static NSSize scaledIconSizeForSize(NSSize imageSize)
|
|||
|
||||
while ((aWin = [iter nextObject]))
|
||||
{
|
||||
|
||||
if ([aWin isVisible] == YES && [aWin isMiniaturized] == NO
|
||||
&& aWin != [NSApp keyWindow] && aWin != [NSApp mainWindow]
|
||||
&& aWin != [self window]
|
||||
|
@ -1221,7 +1220,6 @@ static NSSize scaledIconSizeForSize(NSSize imageSize)
|
|||
[nc postNotificationName: NSApplicationWillResignActiveNotification
|
||||
object: self];
|
||||
|
||||
|
||||
_app_is_active = NO;
|
||||
|
||||
if ([self keyWindow] != nil)
|
||||
|
@ -3611,15 +3609,19 @@ struct _DelegateWrapper
|
|||
- (void) _windowWillClose: (NSNotification*) notification
|
||||
{
|
||||
NSWindow *win = [notification object];
|
||||
BOOL wasMain = [win isMainWindow];
|
||||
|
||||
if (_app_is_running)
|
||||
{
|
||||
NSArray *windows_list = GSOrderedWindows();
|
||||
unsigned count = [windows_list count];
|
||||
unsigned i;
|
||||
NSMutableArray *list = [NSMutableArray arrayWithCapacity: count];
|
||||
BOOL wasKey = [win isKeyWindow];
|
||||
BOOL wasMain = [win isMainWindow];
|
||||
NSEnumerator *iter = [windows_list objectEnumerator];
|
||||
NSMutableArray *list = [NSMutableArray arrayWithCapacity: count];
|
||||
NSWindow *tmp;
|
||||
|
||||
/* FIXME: Why are non-visible windows not counted? When there are
|
||||
minimized windows left over, this would still terminate the application.
|
||||
*/
|
||||
while ((tmp = [iter nextObject]))
|
||||
{
|
||||
if ([tmp canBecomeMainWindow] == YES && [tmp isVisible] == YES)
|
||||
|
@ -3632,7 +3634,7 @@ struct _DelegateWrapper
|
|||
|
||||
/* If there's only one window left, and that's the one being closed,
|
||||
then we ask the delegate if the app is to be terminated. */
|
||||
if (wasMain && count == 0 && _app_is_running)
|
||||
if (wasMain && count == 0)
|
||||
{
|
||||
if ([_delegate respondsToSelector:
|
||||
@selector(applicationShouldTerminateAfterLastWindowClosed:)])
|
||||
|
@ -3643,112 +3645,6 @@ struct _DelegateWrapper
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (wasMain == YES)
|
||||
{
|
||||
[win resignMainWindow];
|
||||
}
|
||||
if (wasKey == YES)
|
||||
{
|
||||
[win resignKeyWindow];
|
||||
}
|
||||
|
||||
if (_app_is_running)
|
||||
{
|
||||
/*
|
||||
* If we are not quitting, we may need to find a new key/main window.
|
||||
*/
|
||||
if (wasKey == YES && [self keyWindow] == nil)
|
||||
{
|
||||
win = [self mainWindow];
|
||||
if (win != nil && [win canBecomeKeyWindow] == YES)
|
||||
{
|
||||
/*
|
||||
* We have a main window that can become key, so do it.
|
||||
*/
|
||||
[win makeKeyAndOrderFront: self];
|
||||
}
|
||||
else if (win != nil)
|
||||
{
|
||||
/*
|
||||
* We have a main window that can't become key, so we just
|
||||
* find a new window to make into our key window.
|
||||
*/
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
win = [list objectAtIndex: i];
|
||||
|
||||
if ([win canBecomeKeyWindow] == YES)
|
||||
{
|
||||
[win makeKeyAndOrderFront: self];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* Find a window that can be made key and main - and do it.
|
||||
*/
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
win = [list objectAtIndex: i];
|
||||
if ([win canBecomeKeyWindow] && [win canBecomeMainWindow])
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i < count)
|
||||
{
|
||||
[win makeMainWindow];
|
||||
[win makeKeyAndOrderFront: self];
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* No window we can use, so just find any candidate to
|
||||
* be main window and another to be key window.
|
||||
*/
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
win = [list objectAtIndex: i];
|
||||
if ([win canBecomeMainWindow] == YES)
|
||||
{
|
||||
[win makeMainWindow];
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
win = [list objectAtIndex: i];
|
||||
if ([win canBecomeKeyWindow] == YES)
|
||||
{
|
||||
[win makeKeyAndOrderFront: self];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ([self mainWindow] == nil)
|
||||
{
|
||||
win = [self keyWindow];
|
||||
if ([win canBecomeMainWindow] == YES)
|
||||
{
|
||||
[win makeMainWindow];
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
win = [list objectAtIndex: i];
|
||||
if ([win canBecomeMainWindow] == YES)
|
||||
{
|
||||
[win makeMainWindow];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -237,35 +237,49 @@ has blocked and waited for events.
|
|||
NSArray *windowList = GSOrderedWindows();
|
||||
unsigned pos = [windowList indexOfObjectIdenticalTo: self];
|
||||
unsigned c = [windowList count];
|
||||
unsigned i,ti;
|
||||
NSWindow *w;
|
||||
unsigned i;
|
||||
|
||||
// Don't bother when application is closing.
|
||||
if ([NSApp isRunning] == NO)
|
||||
return;
|
||||
|
||||
if (!c)
|
||||
return;
|
||||
|
||||
i = pos + 1;
|
||||
if (pos >= c || pos + 1 == c)
|
||||
if (pos == NSNotFound)
|
||||
{
|
||||
pos = c - 1;
|
||||
i = 0;
|
||||
pos = c;
|
||||
}
|
||||
ti = i;
|
||||
|
||||
if ([self isKeyWindow])
|
||||
{
|
||||
NSWindow *menu_window = [[NSApp mainMenu] window];
|
||||
NSWindow *w = [NSApp mainWindow];
|
||||
|
||||
[self resignKeyWindow];
|
||||
if (w != nil && w != self
|
||||
&& [w canBecomeKeyWindow])
|
||||
{
|
||||
[w makeKeyWindow];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSWindow *menu_window = [[NSApp mainMenu] window];
|
||||
|
||||
for (; i != pos && i < c; i++)
|
||||
// try all windows front to back except self and menu
|
||||
for (i = 0; i < c; i++)
|
||||
{
|
||||
if (i != pos)
|
||||
{
|
||||
w = [windowList objectAtIndex: i];
|
||||
if ([w isVisible] && [w canBecomeKeyWindow] && w != menu_window)
|
||||
if ([w isVisible] && [w canBecomeKeyWindow]
|
||||
&& w != menu_window)
|
||||
{
|
||||
[w makeKeyWindow];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* if we didn't find a possible key window - use the main menu window
|
||||
*/
|
||||
|
@ -273,11 +287,14 @@ has blocked and waited for events.
|
|||
{
|
||||
if (menu_window != nil)
|
||||
{
|
||||
// FIXME: Why this call and not makeKeyWindow?
|
||||
[GSServerForWindow(menu_window) setinputfocus:
|
||||
[menu_window windowNumber]];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ([self isMainWindow])
|
||||
{
|
||||
NSWindow *w = [NSApp keyWindow];
|
||||
|
@ -289,7 +306,10 @@ has blocked and waited for events.
|
|||
}
|
||||
else
|
||||
{
|
||||
for (i = ti; i != pos && i < c; i++)
|
||||
// try all windows front to back except self
|
||||
for (i = 0; i < c; i++)
|
||||
{
|
||||
if (i != pos)
|
||||
{
|
||||
w = [windowList objectAtIndex: i];
|
||||
if ([w isVisible] && [w canBecomeMainWindow])
|
||||
|
@ -301,6 +321,7 @@ has blocked and waited for events.
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (NSView *) _windowView
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue