Tidy focus changing for windows being ordered out

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@5320 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 1999-11-29 06:12:34 +00:00
parent ad29495859
commit 429d56ad48
5 changed files with 99 additions and 15 deletions

View file

@ -1,3 +1,11 @@
Mon Nov 29 6:05:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* Source/NSApplication.m: ([-iconWindow]) new (non-standard) method.
* Source/NSWindow.m: ([-orderWindow:relativeTo:]) added code to
resign key/main window status on ordering out. Also, set up a new
key/main window - if no suitable candidates are available, use the
app icon window or the main menu window.
Sun Nov 28 19:37:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* Source/NSOpenPanel.m: ([-filenames]) fix to handle multiple

View file

@ -79,7 +79,7 @@ extern NSString *NSEventTrackingRunLoopMode;
NSMutableArray *_hidden;
NSMutableArray *_inactive;
NSWindow *_hidden_key;
NSWindow *_app_icon_window;
BOOL inTrackingLoop;
// Reserved for back-end use
@ -256,6 +256,9 @@ extern NSString *NSEventTrackingRunLoopMode;
- (BOOL) writeSelectionToPasteboard: (NSPasteboard*)pboard
types: (NSArray*)types;
#ifndef NO_GNUSTEP
- (NSWindow*) iconWindow;
#endif
@end

View file

@ -168,7 +168,7 @@
@end
#ifndef NO_GNUSTEP
@interface NSMenu (GNUstepExtra)
- (BOOL)isFollowTransient;
- (NSWindow *)window;
@ -190,6 +190,7 @@
- (void)shiftOnScreen;
@end
#endif
/* A menu's title is an instance of this class */
@interface NSMenuWindowTitleView : NSView

View file

@ -86,7 +86,6 @@ struct _NSModalSession {
* Class variables
*/
static BOOL gnustep_gui_app_is_in_dealloc;
static NSIconWindow *app_icon_window;
static NSEvent *null_event;
static NSString *NSAbortModalException = @"NSAbortModalException";
@ -267,7 +266,7 @@ static NSCell* tileCell = nil;
if (app_icon == nil)
app_icon = [[NSImage imageNamed: @"GNUstep"] retain];
app_icon_window = [[NSIconWindow alloc] initWithContentRect:
_app_icon_window = [[NSIconWindow alloc] initWithContentRect:
NSMakeRect(0,0,64,64)
styleMask: NSBorderlessWindowMask
backing: NSBackingStoreRetained
@ -275,11 +274,11 @@ static NSCell* tileCell = nil;
screen: nil];
iv = [[NSAppIconView alloc] initWithFrame: NSMakeRect(0,0,64,64)];
[app_icon_window setContentView: iv];
[_app_icon_window setContentView: iv];
[iv setImage: app_icon];
[app_icon_window orderFrontRegardless];
DPSsetinputfocus(context, [app_icon_window windowNumber]);
[_app_icon_window orderFrontRegardless];
DPSsetinputfocus(context, [_app_icon_window windowNumber]);
return self;
}
@ -339,7 +338,6 @@ static NSCell* tileCell = nil;
}
}
- (void) _windowWillClose: (NSNotification*) notification
{
NSWindow *win = [notification object];
@ -490,7 +488,7 @@ static NSCell* tileCell = nil;
{
NSGraphicsContext *context = GSCurrentContext();
DPSsetinputfocus(context, [app_icon_window windowNumber]);
DPSsetinputfocus(context, [_app_icon_window windowNumber]);
}
}
}
@ -789,7 +787,7 @@ static NSCell* tileCell = nil;
{
continue; /* Already invisible */
}
if (win == app_icon_window)
if (win == _app_icon_window)
{
continue; /* can't hide the app icon. */
}
@ -1345,8 +1343,8 @@ NSAssert([event retainCount] > 0, NSInternalInconsistencyException);
[app_icon setName: nil];
[anImage setName: @"NSApplicationIcon"];
ASSIGN(app_icon, anImage);
[[app_icon_window contentView] setImage: anImage];
[[app_icon_window contentView] setNeedsDisplay: YES];
[[_app_icon_window contentView] setImage: anImage];
[[_app_icon_window contentView] setNeedsDisplay: YES];
}
- (NSImage*) applicationIconImage
@ -1354,6 +1352,11 @@ NSAssert([event retainCount] > 0, NSInternalInconsistencyException);
return app_icon;
}
- (NSWindow*) iconWindow
{
return _app_icon_window;
}
/*
* Hiding and arranging windows
*/
@ -1381,7 +1384,7 @@ NSAssert([event retainCount] > 0, NSInternalInconsistencyException);
{
continue; /* Already invisible */
}
if (win == app_icon_window)
if (win == _app_icon_window)
{
continue; /* can't hide the app icon. */
}

View file

@ -46,6 +46,7 @@
#include <AppKit/NSWindow.h>
#include <AppKit/NSWindowController.h>
#include <AppKit/NSApplication.h>
#include <AppKit/NSMenu.h>
#include <AppKit/NSImage.h>
#include <AppKit/NSTextFieldCell.h>
#include <AppKit/NSTextField.h>
@ -673,6 +674,76 @@ static NSMapTable* windowmaps = NULL;
- (void) orderWindow: (NSWindowOrderingMode)place relativeTo: (int)otherWin
{
if (place == NSWindowOut)
{
NSArray *windowList = [NSWindow _windowList];
unsigned pos = [windowList indexOfObjectIdenticalTo: self];
unsigned c = [windowList count];
unsigned i;
NSWindow *w;
if ([self isKeyWindow])
{
[self resignKeyWindow];
for (i = pos + 1; i != pos; i++)
{
if (i == c)
{
i = 0;
}
w = [windowList objectAtIndex: i];
if ([w isVisible] && [w canBecomeKeyWindow])
{
[w makeKeyWindow];
break;
}
}
/*
* if we didn't find a possible key window - use tha app icon or,
* failing that, use the menu window.
*/
if (i == pos)
{
w = [NSApp iconWindow];
if (w != nil && [w isVisible] == YES)
{
[GSCurrentContext() DPSsetinputfocus: [w windowNumber]];
}
else
{
w = [[NSApp mainMenu] window];
[GSCurrentContext() DPSsetinputfocus: [w windowNumber]];
}
}
}
if ([self isMainWindow])
{
NSWindow *w = [NSApp keyWindow];
[self resignMainWindow];
if (w != nil && [w canBecomeMainWindow])
{
[w makeKeyWindow];
}
else
{
for (i = pos + 1; i != pos; i++)
{
if (i == c)
{
i = 0;
}
w = [windowList objectAtIndex: i];
if ([w isVisible] && [w canBecomeMainWindow])
{
[w makeMainWindow];
break;
}
}
}
}
}
DPSorderwindow(GSCurrentContext(), place, otherWin, [self windowNumber]);
}
@ -1228,8 +1299,6 @@ resetCursorRectsForView(NSView *theView)
RETAIN(self);
[nc postNotificationName: NSWindowWillCloseNotification object: self];
[self resignKeyWindow];
[self resignMainWindow];
[NSApp removeWindowsItem: self];
[self orderOut: self];