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> Sun Nov 28 19:37:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* Source/NSOpenPanel.m: ([-filenames]) fix to handle multiple * Source/NSOpenPanel.m: ([-filenames]) fix to handle multiple

View file

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

View file

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

View file

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

View file

@ -46,6 +46,7 @@
#include <AppKit/NSWindow.h> #include <AppKit/NSWindow.h>
#include <AppKit/NSWindowController.h> #include <AppKit/NSWindowController.h>
#include <AppKit/NSApplication.h> #include <AppKit/NSApplication.h>
#include <AppKit/NSMenu.h>
#include <AppKit/NSImage.h> #include <AppKit/NSImage.h>
#include <AppKit/NSTextFieldCell.h> #include <AppKit/NSTextFieldCell.h>
#include <AppKit/NSTextField.h> #include <AppKit/NSTextField.h>
@ -673,6 +674,76 @@ static NSMapTable* windowmaps = NULL;
- (void) orderWindow: (NSWindowOrderingMode)place relativeTo: (int)otherWin - (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]); DPSorderwindow(GSCurrentContext(), place, otherWin, [self windowNumber]);
} }
@ -1228,8 +1299,6 @@ resetCursorRectsForView(NSView *theView)
RETAIN(self); RETAIN(self);
[nc postNotificationName: NSWindowWillCloseNotification object: self]; [nc postNotificationName: NSWindowWillCloseNotification object: self];
[self resignKeyWindow];
[self resignMainWindow];
[NSApp removeWindowsItem: self]; [NSApp removeWindowsItem: self];
[self orderOut: self]; [self orderOut: self];