diff --git a/ChangeLog b/ChangeLog index 6a945fcf1..f79a3b177 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon Nov 22 14:51:33:00 1999 Richard Frith-Macdonald + + * Source/NSApplication.m: Start listening for window notifications + in initialisation. + 1999-11-21 Tim McIntosh * Model/GMAppKit.m ([NSMenuItem -initWithModelUnarchiver:]), diff --git a/Source/NSApplication.m b/Source/NSApplication.m index 4bf8a334c..d31b9c58e 100644 --- a/Source/NSApplication.m +++ b/Source/NSApplication.m @@ -378,6 +378,8 @@ static NSCell* tileCell = nil; - (id) init { + NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; + if (NSApp != nil && NSApp != self) { RELEASE(self); @@ -410,6 +412,19 @@ static NSCell* tileCell = nil; /* We are the end of responder chain */ [self setNextResponder: nil]; + + /* Register self as observer to window events. */ + [nc addObserver: self selector: @selector(_windowWillClose:) + name: NSWindowWillCloseNotification object: nil]; + [nc addObserver: self selector: @selector(_windowDidBecomeKey:) + name: NSWindowDidBecomeKeyNotification object: nil]; + [nc addObserver: self selector: @selector(_windowDidBecomeMain:) + name: NSWindowDidBecomeMainNotification object: nil]; + [nc addObserver: self selector: @selector(_windowDidResignKey:) + name: NSWindowDidResignKeyNotification object: nil]; + [nc addObserver: self selector: @selector(_windowDidResignMain:) + name: NSWindowDidResignMainNotification object: nil]; + return self; } @@ -452,18 +467,6 @@ static NSCell* tileCell = nil; [self activateIgnoringOtherApps: YES]; - /* Register self as observer to window events. */ - [nc addObserver: self selector: @selector(_windowWillClose:) - name: NSWindowWillCloseNotification object: nil]; - [nc addObserver: self selector: @selector(_windowDidBecomeKey:) - name: NSWindowDidBecomeKeyNotification object: nil]; - [nc addObserver: self selector: @selector(_windowDidBecomeMain:) - name: NSWindowDidBecomeMainNotification object: nil]; - [nc addObserver: self selector: @selector(_windowDidResignKey:) - name: NSWindowDidResignKeyNotification object: nil]; - [nc addObserver: self selector: @selector(_windowDidResignMain:) - name: NSWindowDidResignMainNotification object: nil]; - /* finish the launching post notification that launching has finished */ [nc postNotificationName: NSApplicationDidFinishLaunchingNotification object: self]; diff --git a/Source/NSWindow.m b/Source/NSWindow.m index 70e8e73a0..16d731235 100644 --- a/Source/NSWindow.m +++ b/Source/NSWindow.m @@ -673,6 +673,10 @@ static NSMapTable* windowmaps = NULL; - (void) orderWindow: (NSWindowOrderingMode)place relativeTo: (int)otherWin { + if (_f.is_key == YES && place == NSWindowOut) + { + [self resignKeyWindow]; + } DPSorderwindow(GSCurrentContext(), place, otherWin, [self windowNumber]); }