diff --git a/ChangeLog b/ChangeLog index 9834be6c3..70193ceaf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +Tue Dec 22 12:30:00 1998 Richard Frith-Macdonald + + * Source/GSServicesManager.m: ([-rebuildServicesMenu:]) release submenu + once it's added to main menu.a ([-update]) Don't force a display - + let the autodisplay mechanism do it. + * Source/NSMenu.m: ([-update]) Check to see if autoupdate is enabled + properly and don't force a redisplay unnecessarily. + * Source/NSApplication.m: ([-run]) update main menu items. + * Source/NSMenuItem.m: Fix memory leak when copying an item with a + submenu - the submenu was never released. + * Source/NSWindow.m: Don't add window to windows menu in + ([-initWithContentRect:styleMask:backing:defer:screen:]). + ([-setMiniwindowTitle:]) Don't change windows menu if excluded. + ([-makeKeyAndOrderFront:]) Make main window as well as key window. + ([-initWithCoder:]) Don't put in windows menu automatically. + * Source/NSpanel.m: Implemented ([canBecomeMainWindow]) to return NO. + Sat Dec 19 01:26:06 1998 Matthias Klose * Images/Makefile.postamble: Use macro MKDIRS. diff --git a/Source/GSServicesManager.m b/Source/GSServicesManager.m index 1a525e050..4ec8721d1 100644 --- a/Source/GSServicesManager.m +++ b/Source/GSServicesManager.m @@ -689,6 +689,7 @@ static NSString *disabledName = @".GNUstepDisabled"; menu = [[NSMenu alloc] initWithTitle: parentTitle]; [servicesMenu setSubmenu: menu forItem: item]; + [menu release]; } else { @@ -957,7 +958,7 @@ static NSString *disabledName = @".GNUstepDisabled"; /* * If there is no title mapping, this cell must be a - * submenu - so we chaeck the submenu cells. + * submenu - so we check the submenu cells. */ if (title == nil && [[cell target] isKindOfClass: [NSMenu class]]) { @@ -984,9 +985,6 @@ static NSString *disabledName = @".GNUstepDisabled"; [subMenuCells cellFrameAtRow: j]]; } } - /* FIXME - only doing this here 'cos auto-display doesn't work */ - if ([subMenuCells needsDisplay]) - [subMenuCells display]; } else shouldBeEnabled = [self validateMenuItem: cell]; @@ -997,9 +995,6 @@ static NSString *disabledName = @".GNUstepDisabled"; [menuCells setNeedsDisplayInRect: [menuCells cellFrameAtRow: i]]; } } - /* FIXME - only doing this here 'cos auto-display doesn't work */ - if ([menuCells needsDisplay]) - [menuCells display]; } } diff --git a/Source/NSApplication.m b/Source/NSApplication.m index 7eb47cbb3..f4236a1b6 100644 --- a/Source/NSApplication.m +++ b/Source/NSApplication.m @@ -286,11 +286,13 @@ NSAutoreleasePool* pool; if (e) [self sendEvent: e]; + [listener updateServicesMenu]; // update (en/disable) the + // services menu's items + [main_menu update]; + if (windows_need_update) // send an update message [self updateWindows]; // to all visible windows - [listener updateServicesMenu]; // update (en/disable) the - // services menu's items [pool release]; } while (!app_should_quit); diff --git a/Source/NSMenu.m b/Source/NSMenu.m index 8d25da05a..a71e9db78 100644 --- a/Source/NSMenu.m +++ b/Source/NSMenu.m @@ -440,13 +440,13 @@ static Class menuCellClass = nil; - (void)update { - // SUBCLASS to redisplay the menu + // SUBCLASS to redisplay the menu if necessary id cells; int i, count; id theApp = [NSApplication sharedApplication]; - if (![[theApp mainMenu] autoenablesItems]) + if (![self autoenablesItems]) return; cells = [menuCells itemArray]; @@ -509,15 +509,11 @@ static Class menuCellClass = nil; } } - /* Reenable displaying of menus */ - [self setMenuChangedMessagesEnabled:YES]; - if (menuHasChanged) [self sizeToFit]; - /* FIXME - only doing this here 'cos auto-display doesn't work */ - if ([menuCells needsDisplay]) - [menuCells display]; + /* Reenable displaying of menus */ + [self setMenuChangedMessagesEnabled:YES]; } - (void) performActionForItem: (id )cell @@ -531,11 +527,11 @@ static Class menuCellClass = nil; nc = [NSNotificationCenter defaultCenter]; d = [NSDictionary dictionaryWithObject: cell forKey: @"MenuItem"]; [nc postNotificationName: NSMenuWillSendActionNotification - object: self - userInfo: d]; + object: self + userInfo: d]; [[NSApplication sharedApplication] sendAction: [cell action] - to: [cell target] - from: cell]; + to: [cell target] + from: cell]; [nc postNotificationName: NSMenuDidSendActionNotification object: self userInfo: d]; diff --git a/Source/NSMenuItem.m b/Source/NSMenuItem.m index 7ce04c49f..2f63b7bde 100644 --- a/Source/NSMenuItem.m +++ b/Source/NSMenuItem.m @@ -72,17 +72,19 @@ static BOOL usesUserKeyEquivalents = YES; [super dealloc]; } -- (id)copyWithZone:(NSZone*)zone +- (id) copyWithZone: (NSZone*)zone { NSMenuItem* copy = [super copyWithZone:zone]; NSDebugLog (@"menu item '%@' copy", [self title]); copy->representedObject = [representedObject retain]; copy->hasSubmenu = hasSubmenu; - if (hasSubmenu) { // recursive call - id submenu = [target copyWithZone:zone]; // to create our - copy->target = [submenu retain]; // submenus - } + if (hasSubmenu) + { + // recursive call + id submenu = [target copyWithZone: zone]; + copy->target = submenu; + } return copy; } diff --git a/Source/NSPanel.m b/Source/NSPanel.m index 31c954586..a369b07b9 100644 --- a/Source/NSPanel.m +++ b/Source/NSPanel.m @@ -98,6 +98,11 @@ return self; } +- (BOOL) canBecomeKeyWindow +{ + return NO; +} + // // If we receive an escape, close. // diff --git a/Source/NSWindow.m b/Source/NSWindow.m index eddec3309..2bb391d67 100644 --- a/Source/NSWindow.m +++ b/Source/NSWindow.m @@ -193,9 +193,6 @@ NSRect cframe; cframe.size = frame.size; [self setContentView:[[[NSView alloc] initWithFrame:cframe] autorelease]]; - - [theApp addWindowsItem: self title: nil filename: NO]; - _flushRectangles = [[NSMutableArray alloc] initWithCapacity:10]; NSDebugLog(@"NSWindow end of init\n"); @@ -304,9 +301,10 @@ NSView *wv; title = window_title; if ([title isEqual: represented_filename]) isDoc = YES; - [[NSApplication sharedApplication] changeWindowsItem: self - title: title - filename: isDoc]; + if (menu_exclude == NO) + [[NSApplication sharedApplication] changeWindowsItem: self + title: title + filename: isDoc]; } // @@ -365,20 +363,25 @@ NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; - (void)makeKeyAndOrderFront:sender { - [self makeKeyWindow]; // Make self the key window - [self orderFront:sender]; // order self to the front + [self makeKeyWindow]; // Make self the key window + /* + * OPENSTEP makes a window the main window when it makes it the key window. + * So we do the same (though the documentation doesn't mention it). + */ + [self makeMainWindow]; + [self orderFront: sender]; // order self to the front } -- (void)makeKeyWindow +- (void) makeKeyWindow { -NSApplication *theApp = [NSApplication sharedApplication]; - // Can we become the key - if (![self canBecomeKeyWindow]) // window? - return; - // ask the current key - [[theApp keyWindow] resignKeyWindow]; // window to resign status + NSApplication *theApp = [NSApplication sharedApplication]; + // Can we become the key + if (![self canBecomeKeyWindow]) // window? + return; + // ask the current key + [[theApp keyWindow] resignKeyWindow]; // window to resign status - [self becomeKeyWindow]; // become the key window + [self becomeKeyWindow]; // become the key window } - (void)makeMainWindow @@ -524,17 +527,16 @@ NSPoint basePoint; } } -- (void)update +- (void) update { -NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; + NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; - if (is_autodisplay && needs_display) // if autodisplay is - { // enabled and window - [self displayIfNeeded]; // display - [self flushWindowIfNeeded]; - } - - [nc postNotificationName: NSWindowDidUpdateNotification object: self]; + if (is_autodisplay && needs_display) // if autodisplay is + { // enabled and window + [self displayIfNeeded]; // display + [self flushWindowIfNeeded]; + } + [nc postNotificationName: NSWindowDidUpdateNotification object: self]; } - (void)flushWindowIfNeeded @@ -1314,11 +1316,6 @@ id result = nil; [aDecoder decodeValueOfObjCType:@encode(BOOL) at: &hides_on_deactivate]; [aDecoder decodeValueOfObjCType:@encode(BOOL) at: &accepts_mouse_moved]; - // Register ourselves with the Application object - // +++ we shouldn't do this because coding may not be done? - // better to do it in the awakeFromCoder method - theApp = [NSApplication sharedApplication]; - [theApp addWindowsItem: self title: nil filename: NO]; NSDebugLog(@"NSWindow: finish decoding\n"); return self;