mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-02 15:20:59 +00:00
Variosu fixes
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@5253 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
bb674c32c0
commit
b27b0579e9
5 changed files with 165 additions and 87 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,7 +1,17 @@
|
||||||
Mon Nov 22 7:33:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
1999-11-21 Tim McIntosh <rockford@novia.net>
|
||||||
|
|
||||||
|
* Model/GMAppKit.m ([NSMenuItem -initWithModelUnarchiver:]),
|
||||||
|
([NSMenuItem -encodeWithModelArchiver:]): "menu" should not be a
|
||||||
|
persistent field. [NSMenu addItem:] will reject menu items for which
|
||||||
|
[NSMenuItem menu] returns non-nil.
|
||||||
|
|
||||||
|
Mon Nov 22 14:51:33:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||||
|
|
||||||
* Source/NSWindow.m: Tidied activation/deactivation code.
|
* Source/NSWindow.m: Tidied activation/deactivation code.
|
||||||
* Source/NSApplication.m: Fixed Windows menu for new menu API.
|
* Source/NSApplication.m: Fixed Windows menu for new menu API.
|
||||||
|
Changed to use arrays to store deactivated/hidden windows and to
|
||||||
|
keep track of key window when hidden. Watch window notifications
|
||||||
|
to keep track of which window is key/main.
|
||||||
|
|
||||||
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>
|
||||||
|
|
||||||
|
|
|
@ -62,8 +62,8 @@ extern NSString *NSEventTrackingRunLoopMode;
|
||||||
{
|
{
|
||||||
NSEvent *current_event;
|
NSEvent *current_event;
|
||||||
NSModalSession session;
|
NSModalSession session;
|
||||||
NSWindow *key_window;
|
NSWindow *_key_window;
|
||||||
NSWindow *main_window;
|
NSWindow *_main_window;
|
||||||
id delegate;
|
id delegate;
|
||||||
id listener;
|
id listener;
|
||||||
NSMenu *main_menu;
|
NSMenu *main_menu;
|
||||||
|
|
|
@ -734,7 +734,6 @@ void __dummy_GMAppKit_functionForLinking() {}
|
||||||
[archiver encodeInt:[self tag] withName:@"tag"];
|
[archiver encodeInt:[self tag] withName:@"tag"];
|
||||||
[archiver encodeBOOL:[self isEnabled] withName:@"isEnabled"];
|
[archiver encodeBOOL:[self isEnabled] withName:@"isEnabled"];
|
||||||
[archiver encodeBOOL:[self changesState] withName:@"changesState"];
|
[archiver encodeBOOL:[self changesState] withName:@"changesState"];
|
||||||
[archiver encodeConditionalObject:[self menu] withName:@"menu"];
|
|
||||||
[archiver encodeObject:[self submenu] withName:@"submenu"];
|
[archiver encodeObject:[self submenu] withName:@"submenu"];
|
||||||
[archiver encodeConditionalObject:[self representedObject]
|
[archiver encodeConditionalObject:[self representedObject]
|
||||||
withName:@"representedObject"];
|
withName:@"representedObject"];
|
||||||
|
@ -755,7 +754,7 @@ void __dummy_GMAppKit_functionForLinking() {}
|
||||||
[self setTag:[unarchiver decodeIntWithName:@"tag"]];
|
[self setTag:[unarchiver decodeIntWithName:@"tag"]];
|
||||||
[self setEnabled:[unarchiver decodeBOOLWithName:@"isEnabled"]];
|
[self setEnabled:[unarchiver decodeBOOLWithName:@"isEnabled"]];
|
||||||
[self setChangesState:[unarchiver decodeBOOLWithName:@"changesState"]];
|
[self setChangesState:[unarchiver decodeBOOLWithName:@"changesState"]];
|
||||||
[self setMenu:[unarchiver decodeObjectWithName:@"menu"]];
|
[self setMenu:nil];
|
||||||
[self setSubmenu:[unarchiver decodeObjectWithName:@"submenu"]];
|
[self setSubmenu:[unarchiver decodeObjectWithName:@"submenu"]];
|
||||||
[self setRepresentedObject:[unarchiver
|
[self setRepresentedObject:[unarchiver
|
||||||
decodeObjectWithName:@"representedObject"]];
|
decodeObjectWithName:@"representedObject"]];
|
||||||
|
|
|
@ -152,11 +152,11 @@ static NSCell* tileCell = nil;
|
||||||
kw = [self window];
|
kw = [self window];
|
||||||
|
|
||||||
[NSApp unhide: self];
|
[NSApp unhide: self];
|
||||||
if (kw)
|
if ([NSApp keyWindow] == nil && kw != nil)
|
||||||
{
|
{
|
||||||
NSGraphicsContext *context = GSCurrentContext();
|
NSGraphicsContext *context = GSCurrentContext();
|
||||||
|
|
||||||
[kw orderFrontRegardless];
|
[kw orderFrontRegardless];
|
||||||
[context flush];
|
|
||||||
DPSsetinputfocus(context, [kw windowNumber]);
|
DPSsetinputfocus(context, [kw windowNumber]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -290,6 +290,92 @@ static NSCell* tileCell = nil;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) _windowDidBecomeKey: (NSNotification*) notification
|
||||||
|
{
|
||||||
|
id obj = [notification object];
|
||||||
|
|
||||||
|
if (_key_window == nil && [obj isKindOfClass: [NSWindow class]])
|
||||||
|
{
|
||||||
|
_key_window = obj;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NSLog(@"Bogus attempt to set key window");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) _windowDidBecomeMain: (NSNotification*) notification
|
||||||
|
{
|
||||||
|
id obj = [notification object];
|
||||||
|
|
||||||
|
if (_main_window == nil && [obj isKindOfClass: [NSWindow class]])
|
||||||
|
{
|
||||||
|
_main_window = obj;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NSLog(@"Bogus attempt to set main window");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) _windowDidResignKey: (NSNotification*) notification
|
||||||
|
{
|
||||||
|
id obj = [notification object];
|
||||||
|
|
||||||
|
if (_key_window == obj)
|
||||||
|
{
|
||||||
|
_key_window = nil;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NSLog(@"Bogus attempt to resign key window");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) _windowDidResignMain: (NSNotification*) notification
|
||||||
|
{
|
||||||
|
id obj = [notification object];
|
||||||
|
|
||||||
|
if (_main_window == obj)
|
||||||
|
{
|
||||||
|
_main_window = nil;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NSLog(@"Bogus attempt to resign key window");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
- (void) _windowWillClose: (NSNotification*) notification
|
||||||
|
{
|
||||||
|
int count, wincount, realcount;
|
||||||
|
id win = [self windows];
|
||||||
|
wincount = [win count];
|
||||||
|
realcount = 0;
|
||||||
|
for(count = 0; count < wincount; count++)
|
||||||
|
{
|
||||||
|
if([[win objectAtIndex: count] canBecomeMainWindow])
|
||||||
|
{
|
||||||
|
realcount ++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If there's only one window left, and that's the one being closed,
|
||||||
|
then we ask the delegate if the app is to be terminated. */
|
||||||
|
if ((realcount <= 1) && [[notification object] isMainWindow])
|
||||||
|
{
|
||||||
|
NSLog(@"asking delegate whether to terminate app...");
|
||||||
|
if ([delegate respondsToSelector: @selector(applicationShouldTerminateAfterLastWindowClosed:)])
|
||||||
|
{
|
||||||
|
if([delegate applicationShouldTerminateAfterLastWindowClosed: self])
|
||||||
|
{
|
||||||
|
[self terminate: self];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (id) init
|
- (id) init
|
||||||
{
|
{
|
||||||
if (NSApp != nil && NSApp != self)
|
if (NSApp != nil && NSApp != self)
|
||||||
|
@ -366,11 +452,17 @@ static NSCell* tileCell = nil;
|
||||||
|
|
||||||
[self activateIgnoringOtherApps: YES];
|
[self activateIgnoringOtherApps: YES];
|
||||||
|
|
||||||
#ifndef STRICT_OPENSTEP
|
/* Register self as observer to window events. */
|
||||||
/* Register self as observer to every window closing. */
|
|
||||||
[nc addObserver: self selector: @selector(_windowWillClose:)
|
[nc addObserver: self selector: @selector(_windowWillClose:)
|
||||||
name: NSWindowWillCloseNotification object: nil];
|
name: NSWindowWillCloseNotification object: nil];
|
||||||
#endif
|
[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 */
|
/* finish the launching post notification that launching has finished */
|
||||||
[nc postNotificationName: NSApplicationDidFinishLaunchingNotification
|
[nc postNotificationName: NSApplicationDidFinishLaunchingNotification
|
||||||
|
@ -418,6 +510,8 @@ static NSCell* tileCell = nil;
|
||||||
/* Let ourselves know we are within dealloc */
|
/* Let ourselves know we are within dealloc */
|
||||||
gnustep_gui_app_is_in_dealloc = YES;
|
gnustep_gui_app_is_in_dealloc = YES;
|
||||||
|
|
||||||
|
[[NSNotificationCenter defaultCenter] removeObserver: self];
|
||||||
|
|
||||||
RELEASE(_hidden);
|
RELEASE(_hidden);
|
||||||
RELEASE(_inactive);
|
RELEASE(_inactive);
|
||||||
RELEASE(listener);
|
RELEASE(listener);
|
||||||
|
@ -650,8 +744,17 @@ static NSCell* tileCell = nil;
|
||||||
if ([theWindow isKindOfClass: [NSPanel class]])
|
if ([theWindow isKindOfClass: [NSPanel class]])
|
||||||
[theWindow center];
|
[theWindow center];
|
||||||
|
|
||||||
if ([self isActive])
|
if ([self isActive] == YES)
|
||||||
[theWindow makeKeyWindow];
|
{
|
||||||
|
if ([theWindow canBecomeKeyWindow] == YES)
|
||||||
|
{
|
||||||
|
[theWindow makeKeyWindow];
|
||||||
|
}
|
||||||
|
else if ([theWindow canBecomeMainWindow] == YES)
|
||||||
|
{
|
||||||
|
[theWindow makeMainWindow];
|
||||||
|
}
|
||||||
|
}
|
||||||
[theWindow orderFrontRegardless];
|
[theWindow orderFrontRegardless];
|
||||||
|
|
||||||
theSession = NULL;
|
theSession = NULL;
|
||||||
|
@ -699,7 +802,14 @@ static NSCell* tileCell = nil;
|
||||||
format: @"runModalSession: with wrong session"];
|
format: @"runModalSession: with wrong session"];
|
||||||
|
|
||||||
pool = [NSAutoreleasePool new];
|
pool = [NSAutoreleasePool new];
|
||||||
[theSession->window makeKeyAndOrderFront: self];
|
if ([theSession->window canBecomeKeyWindow] == YES)
|
||||||
|
{
|
||||||
|
[theSession->window makeKeyWindow];
|
||||||
|
}
|
||||||
|
else if ([theSession->window canBecomeMainWindow] == YES)
|
||||||
|
{
|
||||||
|
[theSession->window makeMainWindow];
|
||||||
|
}
|
||||||
|
|
||||||
ctxt = GSCurrentContext();
|
ctxt = GSCurrentContext();
|
||||||
|
|
||||||
|
@ -1142,7 +1252,10 @@ NSAssert([event retainCount] > 0, NSInternalInconsistencyException);
|
||||||
[_hidden removeAllObjects];
|
[_hidden removeAllObjects];
|
||||||
if ([[self windows] containsObject: _hidden_key])
|
if ([[self windows] containsObject: _hidden_key])
|
||||||
{
|
{
|
||||||
|
NSGraphicsContext *context = GSCurrentContext();
|
||||||
|
|
||||||
[_hidden_key makeKeyAndOrderFront: self];
|
[_hidden_key makeKeyAndOrderFront: self];
|
||||||
|
DPSsetinputfocus(context, [_hidden_key windowNumber]);
|
||||||
_hidden_key = nil;
|
_hidden_key = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1181,37 +1294,12 @@ NSAssert([event retainCount] > 0, NSInternalInconsistencyException);
|
||||||
*/
|
*/
|
||||||
- (NSWindow*) keyWindow
|
- (NSWindow*) keyWindow
|
||||||
{
|
{
|
||||||
NSArray *window_list = [self windows];
|
return _key_window;
|
||||||
unsigned c = [window_list count];
|
|
||||||
unsigned i;
|
|
||||||
|
|
||||||
for (i = 0; i < c; ++i)
|
|
||||||
{
|
|
||||||
NSWindow *w = [window_list objectAtIndex: i];
|
|
||||||
if ([w isKeyWindow])
|
|
||||||
{
|
|
||||||
return w;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSWindow*) mainWindow
|
- (NSWindow*) mainWindow
|
||||||
{
|
{
|
||||||
NSArray *window_list = [self windows];
|
return _main_window;
|
||||||
unsigned c = [window_list count];
|
|
||||||
unsigned i;
|
|
||||||
|
|
||||||
for (i = 0; i < c; ++i)
|
|
||||||
{
|
|
||||||
NSWindow *w = [window_list objectAtIndex: i];
|
|
||||||
|
|
||||||
if ([w isMainWindow])
|
|
||||||
{
|
|
||||||
return w;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSWindow*) makeWindowsPerform: (SEL)aSelector inOrder: (BOOL)flag
|
- (NSWindow*) makeWindowsPerform: (SEL)aSelector inOrder: (BOOL)flag
|
||||||
|
@ -1808,36 +1896,5 @@ NSAssert([event retainCount] > 0, NSInternalInconsistencyException);
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef STRICT_OPENSTEP
|
|
||||||
- (void) _windowWillClose: (NSNotification*) notification
|
|
||||||
{
|
|
||||||
int count, wincount, realcount;
|
|
||||||
id win = [self windows];
|
|
||||||
wincount = [win count];
|
|
||||||
realcount = 0;
|
|
||||||
for(count = 0; count < wincount; count++)
|
|
||||||
{
|
|
||||||
if([[win objectAtIndex: count] canBecomeMainWindow])
|
|
||||||
{
|
|
||||||
realcount ++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If there's only one window left, and that's the one being closed,
|
|
||||||
then we ask the delegate if the app is to be terminated. */
|
|
||||||
if ((realcount <= 1) && [[notification object] isMainWindow])
|
|
||||||
{
|
|
||||||
NSLog(@"asking delegate whether to terminate app...");
|
|
||||||
if ([delegate respondsToSelector: @selector(applicationShouldTerminateAfterLastWindowClosed:)])
|
|
||||||
{
|
|
||||||
if([delegate applicationShouldTerminateAfterLastWindowClosed: self])
|
|
||||||
{
|
|
||||||
[self terminate: self];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
@end /* NSApplication */
|
@end /* NSApplication */
|
||||||
|
|
||||||
|
|
|
@ -558,20 +558,26 @@ static NSMapTable* windowmaps = NULL;
|
||||||
*/
|
*/
|
||||||
- (void) becomeKeyWindow
|
- (void) becomeKeyWindow
|
||||||
{
|
{
|
||||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
if (_f.is_key == NO)
|
||||||
|
{
|
||||||
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||||
|
|
||||||
_f.is_key = YES;
|
_f.is_key = YES;
|
||||||
DPSsetinputfocus(GSCurrentContext(), [self windowNumber]);
|
DPSsetinputfocus(GSCurrentContext(), [self windowNumber]);
|
||||||
[self resetCursorRects];
|
[self resetCursorRects];
|
||||||
[nc postNotificationName: NSWindowDidBecomeKeyNotification object: self];
|
[nc postNotificationName: NSWindowDidBecomeKeyNotification object: self];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) becomeMainWindow
|
- (void) becomeMainWindow
|
||||||
{
|
{
|
||||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
if (_f.is_main == NO)
|
||||||
|
{
|
||||||
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||||
|
|
||||||
_f.is_main = YES;
|
_f.is_main = YES;
|
||||||
[nc postNotificationName: NSWindowDidBecomeMainNotification object: self];
|
[nc postNotificationName: NSWindowDidBecomeMainNotification object: self];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) canBecomeKeyWindow
|
- (BOOL) canBecomeKeyWindow
|
||||||
|
@ -672,19 +678,25 @@ static NSMapTable* windowmaps = NULL;
|
||||||
|
|
||||||
- (void) resignKeyWindow
|
- (void) resignKeyWindow
|
||||||
{
|
{
|
||||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
if (_f.is_key == YES)
|
||||||
|
{
|
||||||
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||||
|
|
||||||
_f.is_key = NO;
|
_f.is_key = NO;
|
||||||
[self discardCursorRects];
|
[self discardCursorRects];
|
||||||
[nc postNotificationName: NSWindowDidResignKeyNotification object: self];
|
[nc postNotificationName: NSWindowDidResignKeyNotification object: self];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) resignMainWindow
|
- (void) resignMainWindow
|
||||||
{
|
{
|
||||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
if (_f.is_main == YES)
|
||||||
|
{
|
||||||
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||||
|
|
||||||
_f.is_main = NO;
|
_f.is_main = NO;
|
||||||
[nc postNotificationName: NSWindowDidResignMainNotification object: self];
|
[nc postNotificationName: NSWindowDidResignMainNotification object: self];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setHidesOnDeactivate: (BOOL)flag
|
- (void) setHidesOnDeactivate: (BOOL)flag
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue