mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 19:50:48 +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>
|
Sat Nov 20 6:56:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||||
|
|
||||||
* Source/NSMenu.m: Implemented ([-initDefaults]) to set window level
|
* Source/NSMenu.m: Implemented ([-initDefaults]) to set window level
|
||||||
|
|
|
@ -136,6 +136,8 @@ extern NSSize NSTokenSize;
|
||||||
unsigned menu_exclude:1;
|
unsigned menu_exclude:1;
|
||||||
unsigned hides_on_deactivate:1;
|
unsigned hides_on_deactivate:1;
|
||||||
unsigned accepts_mouse_moved:1;
|
unsigned accepts_mouse_moved:1;
|
||||||
|
unsigned is_closed:1;
|
||||||
|
unsigned is_deactivated:1;
|
||||||
} _f;
|
} _f;
|
||||||
|
|
||||||
/* Reserved for back-end use */
|
/* Reserved for back-end use */
|
||||||
|
|
|
@ -464,6 +464,9 @@ static NSCell* tileCell = nil;
|
||||||
DPSsetinputfocus(context, [kw windowNumber]);
|
DPSsetinputfocus(context, [kw windowNumber]);
|
||||||
NSDebugLog(@"activateIgnoringOtherApps end.");
|
NSDebugLog(@"activateIgnoringOtherApps end.");
|
||||||
|
|
||||||
|
[main_menu update];
|
||||||
|
[main_menu display];
|
||||||
|
|
||||||
[nc postNotificationName: NSApplicationDidBecomeActiveNotification
|
[nc postNotificationName: NSApplicationDidBecomeActiveNotification
|
||||||
object: self];
|
object: self];
|
||||||
}
|
}
|
||||||
|
@ -1105,10 +1108,7 @@ NSAssert([event retainCount] > 0, NSInternalInconsistencyException);
|
||||||
&& ![win isKindOfClass: [NSMenuWindow class]]
|
&& ![win isKindOfClass: [NSMenuWindow class]]
|
||||||
&& ![win isKindOfClass: [NSIconWindow class]])
|
&& ![win isKindOfClass: [NSIconWindow class]])
|
||||||
{
|
{
|
||||||
if (win != key && [win isKindOfClass: [NSWindow class]])
|
[win orderFrontRegardless];
|
||||||
{
|
|
||||||
[win orderFrontRegardless];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
app_is_hidden = NO;
|
app_is_hidden = NO;
|
||||||
|
@ -1464,60 +1464,84 @@ NSAssert([event retainCount] > 0, NSInternalInconsistencyException);
|
||||||
|
|
||||||
- (void) setWindowsMenu: (NSMenu*)aMenu
|
- (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;
|
itemArray = [main_menu itemArray];
|
||||||
NSMenu *menu;
|
count = [itemArray count];
|
||||||
unsigned count;
|
for (i = 0; i < count; ++i)
|
||||||
unsigned i;
|
|
||||||
|
|
||||||
menu = [self windowsMenu];
|
|
||||||
if (menu == aMenu)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Remove all the windows from the old windows menu.
|
|
||||||
*/
|
|
||||||
if (menu)
|
|
||||||
{
|
{
|
||||||
NSArray *itemArray = [menu itemArray];
|
anItem = [itemArray objectAtIndex: i];
|
||||||
|
if ([[anItem title] compare: @"Windows"] == NSOrderedSame)
|
||||||
count = [itemArray count];
|
|
||||||
for (i = 0; i < count; i++)
|
|
||||||
{
|
{
|
||||||
id item = [itemArray objectAtIndex: i];
|
windows_menu = anItem;
|
||||||
id win = [item target];
|
break;
|
||||||
|
|
||||||
if ([win isKindOfClass: [NSWindow class]])
|
|
||||||
{
|
|
||||||
[menu removeItem: item];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (windows_menu == nil)
|
||||||
|
{
|
||||||
|
windows_menu = [main_menu insertItemWithTitle: @"Windows"
|
||||||
|
action: 0
|
||||||
|
keyEquivalent: @""
|
||||||
|
atIndex: count];
|
||||||
|
[main_menu sizeToFit];
|
||||||
|
[main_menu update];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
menu = [self windowsMenu];
|
||||||
* Now use [-changeWindowsItem:title:filename:] to build the new menu.
|
if (menu == aMenu)
|
||||||
*/
|
return;
|
||||||
[main_menu setSubmenu: aMenu forItem: (id<NSMenuItem>)windows_menu];
|
|
||||||
windows = [self windows];
|
/*
|
||||||
count = [windows count];
|
* 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++)
|
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];
|
[menu removeItem: anItem];
|
||||||
NSString *f = [win representedFilename];
|
|
||||||
|
|
||||||
[self changeWindowsItem: win
|
|
||||||
title: t
|
|
||||||
filename: [t isEqual: f]];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
[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
|
- (void) updateWindowsItem: (NSWindow*)aWindow
|
||||||
|
@ -1607,7 +1631,7 @@ NSAssert([event retainCount] > 0, NSInternalInconsistencyException);
|
||||||
- (NSMenu*) windowsMenu
|
- (NSMenu*) windowsMenu
|
||||||
{
|
{
|
||||||
if (windows_menu)
|
if (windows_menu)
|
||||||
return [windows_menu target];
|
return [windows_menu submenu];
|
||||||
else
|
else
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
|
@ -192,6 +192,31 @@ static NSMapTable* windowmaps = NULL;
|
||||||
return 8;
|
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
|
* Instance methods
|
||||||
*/
|
*/
|
||||||
|
@ -212,7 +237,10 @@ static NSMapTable* windowmaps = NULL;
|
||||||
|
|
||||||
- (void) dealloc
|
- (void) dealloc
|
||||||
{
|
{
|
||||||
NSGraphicsContext *context = GSCurrentContext();
|
NSGraphicsContext *context = GSCurrentContext();
|
||||||
|
|
||||||
|
[[NSNotificationCenter defaultCenter] removeObserver: self];
|
||||||
|
|
||||||
if (content_view)
|
if (content_view)
|
||||||
{
|
{
|
||||||
RELEASE([content_view superview]); /* Release the window view */
|
RELEASE([content_view superview]); /* Release the window view */
|
||||||
|
@ -264,9 +292,10 @@ static NSMapTable* windowmaps = NULL;
|
||||||
defer: (BOOL)flag
|
defer: (BOOL)flag
|
||||||
screen: (NSScreen*)aScreen
|
screen: (NSScreen*)aScreen
|
||||||
{
|
{
|
||||||
NSGraphicsContext *context = GSCurrentContext();
|
NSGraphicsContext *context = GSCurrentContext();
|
||||||
NSRect r = [[NSScreen mainScreen] frame];
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||||
NSRect cframe;
|
NSRect r = [[NSScreen mainScreen] frame];
|
||||||
|
NSRect cframe;
|
||||||
|
|
||||||
NSDebugLog(@"NSWindow default initializer\n");
|
NSDebugLog(@"NSWindow default initializer\n");
|
||||||
if (!NSApp)
|
if (!NSApp)
|
||||||
|
@ -325,6 +354,16 @@ static NSMapTable* windowmaps = NULL;
|
||||||
title: window_title
|
title: window_title
|
||||||
filename: isDoc];
|
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");
|
NSDebugLog(@"NSWindow end of init\n");
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -663,6 +702,11 @@ static NSMapTable* windowmaps = NULL;
|
||||||
- (void) orderWindow: (NSWindowOrderingMode)place relativeTo: (int)otherWin
|
- (void) orderWindow: (NSWindowOrderingMode)place relativeTo: (int)otherWin
|
||||||
{
|
{
|
||||||
DPSorderwindow(GSCurrentContext(), place, otherWin, [self windowNumber]);
|
DPSorderwindow(GSCurrentContext(), place, otherWin, [self windowNumber]);
|
||||||
|
if (place != NSWindowOut)
|
||||||
|
{
|
||||||
|
_f.is_deactivated = NO;
|
||||||
|
_f.is_closed = NO;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) resignKeyWindow
|
- (void) resignKeyWindow
|
||||||
|
@ -682,49 +726,10 @@ static NSMapTable* windowmaps = NULL;
|
||||||
[nc postNotificationName: NSWindowDidResignMainNotification object: self];
|
[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
|
- (void) setHidesOnDeactivate: (BOOL)flag
|
||||||
{
|
{
|
||||||
if (flag != _f.hides_on_deactivate)
|
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;
|
_f.hides_on_deactivate = flag;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue