diff --git a/ChangeLog b/ChangeLog index 8a80316d3..41c99377e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,24 @@ +2002-10-18 Adam Fedor + + * Documentation/announce.texi: Fix grammer. + + * Try to fix focus interaction with WindowMaker. + * Source/NSApplication.m ([NSIconWindow -canBecomeKeyWindow]): + Revert 2002-10-08 change. + (-appIconInit): Don't set input focus to app icon. + (-_windowWillClose:): Idem. + * Source/NSMenu.m: New class NSMenuPanel + (_createWindow): Use it. + * Source/NSWindow.m (-_lossOfKeyOrMainWindow): Make sure menu + window doesn't get key except as a last resort. + (-sendEvent: (GSAppKitWindowFocusIn)): Don't become key if app + is hidden. + + * Source/NSPanel.m (-sendEvent:): Same as change to NSWindow on + 2002-10-03. + + * Source/NSDocument.m (-init): Set default file type. + Tue Oct 15 02:36:32 2002 Nicola Pero * Source/NSApplication.m (initialize_gnustep_backend): Get the diff --git a/Documentation/announce.texi b/Documentation/announce.texi index 9420ae979..3ad3746bd 100644 --- a/Documentation/announce.texi +++ b/Documentation/announce.texi @@ -44,7 +44,7 @@ the TIFF Graphics library version @value{GNUSTEP-GUI-LIBTIFF} is required. It also requires a FoundationKit library as specified by the OpenStep -specification. The FoundationKit libraries known to work are the GNUstep +specification. The only FoundationKit library known to work is the GNUstep Base Library. @section Where do I send bug reports? diff --git a/Source/NSApplication.m b/Source/NSApplication.m index 1dd245fce..d1e415277 100644 --- a/Source/NSApplication.m +++ b/Source/NSApplication.m @@ -266,7 +266,7 @@ NSApplication *NSApp = nil; - (BOOL) canBecomeKeyWindow { - return YES; + return NO; } - (BOOL) worksWhenModal @@ -1002,7 +1002,7 @@ static NSCell* tileCell = nil; [_listener updateServicesMenu]; [_main_menu update]; DESTROY(_runLoopPool); - + while (_app_is_running) { IF_NO_GC(_runLoopPool = [arpClass new]); @@ -2468,8 +2468,6 @@ delegate. RELEASE(iv); [_app_icon_window orderFrontRegardless]; - [GSServerForWindow(_app_icon_window) - setinputfocus: [_app_icon_window windowNumber]]; return self; } @@ -2684,15 +2682,6 @@ delegate. } } } - /* - * If the app has no key window - we must make sure the icon window - * has keyboard focus, even though it doesn't actually use kb events. - */ - if ([self keyWindow] == nil) - { - [GSServerForWindow(_app_icon_window) - setinputfocus: [_app_icon_window windowNumber]]; - } } } diff --git a/Source/NSDocument.m b/Source/NSDocument.m index e7544aecc..5b7461b8b 100644 --- a/Source/NSDocument.m +++ b/Source/NSDocument.m @@ -67,6 +67,9 @@ [super init]; _documentIndex = untitledCount++; _windowControllers = [[NSMutableArray alloc] init]; + + /* Set our default type */ + [self setFileType: [[[self class] writableTypes] objectAtIndex: 0]]; return self; } diff --git a/Source/NSMenu.m b/Source/NSMenu.m index ee457cc35..0f9668317 100644 --- a/Source/NSMenu.m +++ b/Source/NSMenu.m @@ -55,6 +55,10 @@ #include #include +/* Subclass of NSPanel since menus cannot become key */ +@interface NSMenuPanel : NSPanel +@end + /* A menu's title is an instance of this class */ @interface NSMenuWindowTitleView : NSView { @@ -80,8 +84,18 @@ static NSString *NSMenuLocationsKey = @"NSMenuLocations"; static NSNotificationCenter *nc; @interface NSMenu (GNUstepPrivate) -- (NSString*) _locationKey; -- (NSPanel*) _createWindow; +- (NSString *) _locationKey; +- (NSMenuPanel *) _createWindow; +@end + +@implementation NSMenuPanel +- (BOOL) canBecomeKeyWindow +{ + /* This should be NO, but there's currently a bug in the interaction + with WindowMaker that causes spurious deactivation of the app + if the app icon is the only window that can become key */ + return YES; +} @end @implementation NSMenu (GNUstepPrivate) @@ -111,9 +125,9 @@ static NSNotificationCenter *nc; } /* Create a non autorelease window for this menu. */ -- (NSPanel*) _createWindow +- (NSMenuPanel*) _createWindow { - NSPanel *win = [[NSPanel alloc] + NSMenuPanel *win = [[NSMenuPanel alloc] initWithContentRect: NSZeroRect styleMask: NSBorderlessWindowMask backing: NSBackingStoreBuffered diff --git a/Source/NSPanel.m b/Source/NSPanel.m index 744fb1f4d..2a1ac8605 100644 --- a/Source/NSPanel.m +++ b/Source/NSPanel.m @@ -223,8 +223,8 @@ Code shared with [NSWindow -sendEvent:], remember to update both places. { [self makeFirstResponder: v]; } - if (_lastDragView) - DESTROY(_lastDragView); + if (_lastView) + DESTROY(_lastView); if (wasKey == YES || [v acceptsFirstMouse: theEvent] == YES) { if ([NSHelpManager isContextHelpModeActive]) @@ -233,10 +233,7 @@ Code shared with [NSWindow -sendEvent:], remember to update both places. } else { - /* Technically this should be just _lastView, - but I don't think it's a problem reusing this - ivar */ - ASSIGN(_lastDragView, v); + ASSIGN(_lastView, v); [v mouseDown: theEvent]; } } diff --git a/Source/NSWindow.m b/Source/NSWindow.m index e1955a9cf..6188680ea 100644 --- a/Source/NSWindow.m +++ b/Source/NSWindow.m @@ -97,6 +97,23 @@ BOOL GSViewAcceptsDrag(NSView *v, id dragInfo); { [self displayIfNeeded]; } + +/* We get here if we were ordered out or miniaturized. In this case if + we were the key or main window, go through the list of all windows + and try to find another window that can take our place as key + and/or main. Automatically ignore windows that cannot become + key/main and skip the main menu window (which is the only + non-obvious window that can become key) unless we have no choice + (i.e. all the candidate windows were ordered out.) + + FIXME: It should be the appicon which can become key, not the main + menu, but there is currently an unsolved problem with WindowMaker + interaction that prevents me from doing this. + + FIXME: It would really be better if we maintained a stack of the + most recent key/main windows and went through in order of most + recent to least recent. That's probably a lot of work, however. +*/ - (void) _lossOfKeyOrMainWindow { NSArray *windowList = GSAllWindows(); @@ -107,6 +124,7 @@ BOOL GSViewAcceptsDrag(NSView *v, id dragInfo); if ([self isKeyWindow]) { + NSWindow *menu_window= [[NSApp mainMenu] window]; [self resignKeyWindow]; i = pos + 1; if (i == c) @@ -116,7 +134,7 @@ BOOL GSViewAcceptsDrag(NSView *v, id dragInfo); while (i != pos) { w = [windowList objectAtIndex: i]; - if ([w isVisible] && [w canBecomeKeyWindow]) + if ([w isVisible] && [w canBecomeKeyWindow] && w != menu_window) { [w makeKeyWindow]; break; @@ -129,19 +147,14 @@ BOOL GSViewAcceptsDrag(NSView *v, id dragInfo); } } /* - * if we didn't find a possible key window - use the app icon or, - * failing that, use the menu window. + * if we didn't find a possible key window - use the main menu window */ if (i == pos) { - w = [NSApp iconWindow]; - if (w == nil || [w isVisible] == NO) + if (menu_window != nil) { - w = [[NSApp mainMenu] window]; - } - if (w != nil && [w isVisible] == YES) - { - [GSServerForWindow(w) setinputfocus: [w windowNumber]]; + [GSServerForWindow(menu_window) setinputfocus: + [menu_window windowNumber]]; } } } @@ -2990,10 +3003,13 @@ Code shared with [NSPanel -sendEvent:], remember to update both places. /* Window Manager just deminiaturized us */ [self _didDeminiaturize: self]; } - if (_f.visible == NO) + if ([NSApp isHidden]) { - NSDebugLLog(@"Focus", @"WM take focus on hidden window %d", - _windowNum); + /* This often occurs when hidding an app, since a bunch + of windows get hidden at once, and the WM is searching + for a window to take focus after each one gets + hidden. */ + NSDebugLLog(@"Focus", @"WM take focus while hiding"); break; } if ([self canBecomeKeyWindow] == YES)