mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-30 14:50:38 +00:00
Some window fixes
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@5250 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
94bb4d75c1
commit
ae30b120ff
4 changed files with 125 additions and 89 deletions
|
@ -1,3 +1,8 @@
|
|||
Mon Nov 22 7:33:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
|
||||
* Source/NSWindow.m: Tidied activation/deactivation code.
|
||||
* Source/NSApplication.m: Fixed Windows menu for new menu API.
|
||||
|
||||
Sat Nov 20 6:56:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
|
||||
* Source/NSMenu.m: Implemented ([-initDefaults]) to set window level
|
||||
|
|
|
@ -136,6 +136,8 @@ extern NSSize NSTokenSize;
|
|||
unsigned menu_exclude:1;
|
||||
unsigned hides_on_deactivate:1;
|
||||
unsigned accepts_mouse_moved:1;
|
||||
unsigned is_closed:1;
|
||||
unsigned is_deactivated:1;
|
||||
} _f;
|
||||
|
||||
/* Reserved for back-end use */
|
||||
|
|
|
@ -464,6 +464,9 @@ static NSCell* tileCell = nil;
|
|||
DPSsetinputfocus(context, [kw windowNumber]);
|
||||
NSDebugLog(@"activateIgnoringOtherApps end.");
|
||||
|
||||
[main_menu update];
|
||||
[main_menu display];
|
||||
|
||||
[nc postNotificationName: NSApplicationDidBecomeActiveNotification
|
||||
object: self];
|
||||
}
|
||||
|
@ -1105,10 +1108,7 @@ NSAssert([event retainCount] > 0, NSInternalInconsistencyException);
|
|||
&& ![win isKindOfClass: [NSMenuWindow class]]
|
||||
&& ![win isKindOfClass: [NSIconWindow class]])
|
||||
{
|
||||
if (win != key && [win isKindOfClass: [NSWindow class]])
|
||||
{
|
||||
[win orderFrontRegardless];
|
||||
}
|
||||
[win orderFrontRegardless];
|
||||
}
|
||||
}
|
||||
app_is_hidden = NO;
|
||||
|
@ -1464,60 +1464,84 @@ NSAssert([event retainCount] > 0, NSInternalInconsistencyException);
|
|||
|
||||
- (void) setWindowsMenu: (NSMenu*)aMenu
|
||||
{
|
||||
if (windows_menu)
|
||||
NSMenuItem *anItem;
|
||||
NSArray *windows;
|
||||
NSArray *itemArray;
|
||||
NSMenu *menu;
|
||||
unsigned count;
|
||||
unsigned i;
|
||||
|
||||
if (windows_menu == nil)
|
||||
{
|
||||
NSArray *windows;
|
||||
NSMenu *menu;
|
||||
unsigned count;
|
||||
unsigned i;
|
||||
|
||||
menu = [self windowsMenu];
|
||||
if (menu == aMenu)
|
||||
return;
|
||||
|
||||
/*
|
||||
* Remove all the windows from the old windows menu.
|
||||
*/
|
||||
if (menu)
|
||||
itemArray = [main_menu itemArray];
|
||||
count = [itemArray count];
|
||||
for (i = 0; i < count; ++i)
|
||||
{
|
||||
NSArray *itemArray = [menu itemArray];
|
||||
|
||||
count = [itemArray count];
|
||||
for (i = 0; i < count; i++)
|
||||
anItem = [itemArray objectAtIndex: i];
|
||||
if ([[anItem title] compare: @"Windows"] == NSOrderedSame)
|
||||
{
|
||||
id item = [itemArray objectAtIndex: i];
|
||||
id win = [item target];
|
||||
|
||||
if ([win isKindOfClass: [NSWindow class]])
|
||||
{
|
||||
[menu removeItem: item];
|
||||
}
|
||||
windows_menu = anItem;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (windows_menu == nil)
|
||||
{
|
||||
windows_menu = [main_menu insertItemWithTitle: @"Windows"
|
||||
action: 0
|
||||
keyEquivalent: @""
|
||||
atIndex: count];
|
||||
[main_menu sizeToFit];
|
||||
[main_menu update];
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Now use [-changeWindowsItem:title:filename:] to build the new menu.
|
||||
*/
|
||||
[main_menu setSubmenu: aMenu forItem: (id<NSMenuItem>)windows_menu];
|
||||
windows = [self windows];
|
||||
count = [windows count];
|
||||
menu = [self windowsMenu];
|
||||
if (menu == aMenu)
|
||||
return;
|
||||
|
||||
/*
|
||||
* Remove all the windows from the old windows menu.
|
||||
*/
|
||||
if (menu)
|
||||
{
|
||||
id win;
|
||||
|
||||
itemArray = [menu itemArray];
|
||||
count = [itemArray count];
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
NSWindow *win = [windows objectAtIndex: i];
|
||||
anItem = [itemArray objectAtIndex: i];
|
||||
win = [anItem target];
|
||||
|
||||
if ([win isExcludedFromWindowsMenu] == NO)
|
||||
if ([win isKindOfClass: [NSWindow class]])
|
||||
{
|
||||
NSString *t = [win title];
|
||||
NSString *f = [win representedFilename];
|
||||
|
||||
[self changeWindowsItem: win
|
||||
title: t
|
||||
filename: [t isEqual: f]];
|
||||
[menu removeItem: anItem];
|
||||
}
|
||||
}
|
||||
[aMenu sizeToFit];
|
||||
[aMenu update];
|
||||
}
|
||||
|
||||
/*
|
||||
* Now use [-changeWindowsItem:title:filename:] to build the new menu.
|
||||
*/
|
||||
[main_menu setSubmenu: aMenu forItem: (id<NSMenuItem>)windows_menu];
|
||||
windows = [self windows];
|
||||
count = [windows count];
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
NSWindow *win = [windows objectAtIndex: i];
|
||||
|
||||
if ([win isExcludedFromWindowsMenu] == NO)
|
||||
{
|
||||
NSString *t = [win title];
|
||||
NSString *f = [win representedFilename];
|
||||
|
||||
[self changeWindowsItem: win
|
||||
title: t
|
||||
filename: [t isEqual: f]];
|
||||
}
|
||||
}
|
||||
[aMenu sizeToFit];
|
||||
[aMenu update];
|
||||
}
|
||||
|
||||
- (void) updateWindowsItem: (NSWindow*)aWindow
|
||||
|
@ -1607,7 +1631,7 @@ NSAssert([event retainCount] > 0, NSInternalInconsistencyException);
|
|||
- (NSMenu*) windowsMenu
|
||||
{
|
||||
if (windows_menu)
|
||||
return [windows_menu target];
|
||||
return [windows_menu submenu];
|
||||
else
|
||||
return nil;
|
||||
}
|
||||
|
|
|
@ -192,6 +192,31 @@ static NSMapTable* windowmaps = NULL;
|
|||
return 8;
|
||||
}
|
||||
|
||||
- (void) _appNotification: (NSNotification*)aNotification
|
||||
{
|
||||
NSString *name = [aNotification name];
|
||||
|
||||
if ([name isEqualToString: NSApplicationWillBecomeActiveNotification])
|
||||
{
|
||||
if (_f.is_deactivated == YES && _f.is_closed == NO)
|
||||
{
|
||||
[self orderFrontRegardless];
|
||||
}
|
||||
}
|
||||
else if ([name isEqualToString: NSApplicationWillResignActiveNotification])
|
||||
{
|
||||
if (_f.hides_on_deactivate == YES && _f.visible == YES)
|
||||
{
|
||||
_f.is_deactivated = YES;
|
||||
[self orderOut: self];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"Unexpected notification - %@", aNotification);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Instance methods
|
||||
*/
|
||||
|
@ -212,7 +237,10 @@ static NSMapTable* windowmaps = NULL;
|
|||
|
||||
- (void) dealloc
|
||||
{
|
||||
NSGraphicsContext *context = GSCurrentContext();
|
||||
NSGraphicsContext *context = GSCurrentContext();
|
||||
|
||||
[[NSNotificationCenter defaultCenter] removeObserver: self];
|
||||
|
||||
if (content_view)
|
||||
{
|
||||
RELEASE([content_view superview]); /* Release the window view */
|
||||
|
@ -264,9 +292,10 @@ static NSMapTable* windowmaps = NULL;
|
|||
defer: (BOOL)flag
|
||||
screen: (NSScreen*)aScreen
|
||||
{
|
||||
NSGraphicsContext *context = GSCurrentContext();
|
||||
NSRect r = [[NSScreen mainScreen] frame];
|
||||
NSRect cframe;
|
||||
NSGraphicsContext *context = GSCurrentContext();
|
||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||
NSRect r = [[NSScreen mainScreen] frame];
|
||||
NSRect cframe;
|
||||
|
||||
NSDebugLog(@"NSWindow default initializer\n");
|
||||
if (!NSApp)
|
||||
|
@ -325,6 +354,16 @@ static NSMapTable* windowmaps = NULL;
|
|||
title: window_title
|
||||
filename: isDoc];
|
||||
}
|
||||
|
||||
[nc addObserver: self
|
||||
selector: @selector(_appNotification:)
|
||||
name: NSApplicationWillBecomeActiveNotification
|
||||
object: NSApp];
|
||||
[nc addObserver: self
|
||||
selector: @selector(_appNotification:)
|
||||
name: NSApplicationWillResignActiveNotification
|
||||
object: NSApp];
|
||||
|
||||
NSDebugLog(@"NSWindow end of init\n");
|
||||
return self;
|
||||
}
|
||||
|
@ -663,6 +702,11 @@ static NSMapTable* windowmaps = NULL;
|
|||
- (void) orderWindow: (NSWindowOrderingMode)place relativeTo: (int)otherWin
|
||||
{
|
||||
DPSorderwindow(GSCurrentContext(), place, otherWin, [self windowNumber]);
|
||||
if (place != NSWindowOut)
|
||||
{
|
||||
_f.is_deactivated = NO;
|
||||
_f.is_closed = NO;
|
||||
}
|
||||
}
|
||||
|
||||
- (void) resignKeyWindow
|
||||
|
@ -682,49 +726,10 @@ static NSMapTable* windowmaps = NULL;
|
|||
[nc postNotificationName: NSWindowDidResignMainNotification object: self];
|
||||
}
|
||||
|
||||
- (void) _appWillBecomeActive: (NSNotification*)aNotification
|
||||
{
|
||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||
|
||||
[nc removeObserver: self
|
||||
name: NSApplicationWillBecomeActiveNotification
|
||||
object: NSApp];
|
||||
[self orderFrontRegardless];
|
||||
}
|
||||
|
||||
- (void) _appWillResignActive: (NSNotification*)aNotification
|
||||
{
|
||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||
|
||||
if (_f.visible)
|
||||
{
|
||||
[nc addObserver: self
|
||||
selector: @selector(_appWillBecomeActive:)
|
||||
name: NSApplicationWillBecomeActiveNotification
|
||||
object: NSApp];
|
||||
[self orderOut: self];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) setHidesOnDeactivate: (BOOL)flag
|
||||
{
|
||||
if (flag != _f.hides_on_deactivate)
|
||||
{
|
||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||
|
||||
if (flag == YES)
|
||||
{
|
||||
[nc addObserver: self
|
||||
selector: @selector(_appWillResignActive:)
|
||||
name: NSApplicationWillResignActiveNotification
|
||||
object: NSApp];
|
||||
}
|
||||
else
|
||||
{
|
||||
[nc removeObserver: self
|
||||
name: NSApplicationWillResignActiveNotification
|
||||
object: NSApp];
|
||||
}
|
||||
_f.hides_on_deactivate = flag;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue