mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-22 13:10: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
f5ab35ff5d
commit
ab191734b3
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/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>
|
||||
|
||||
|
|
|
@ -62,8 +62,8 @@ extern NSString *NSEventTrackingRunLoopMode;
|
|||
{
|
||||
NSEvent *current_event;
|
||||
NSModalSession session;
|
||||
NSWindow *key_window;
|
||||
NSWindow *main_window;
|
||||
NSWindow *_key_window;
|
||||
NSWindow *_main_window;
|
||||
id delegate;
|
||||
id listener;
|
||||
NSMenu *main_menu;
|
||||
|
|
|
@ -734,7 +734,6 @@ void __dummy_GMAppKit_functionForLinking() {}
|
|||
[archiver encodeInt:[self tag] withName:@"tag"];
|
||||
[archiver encodeBOOL:[self isEnabled] withName:@"isEnabled"];
|
||||
[archiver encodeBOOL:[self changesState] withName:@"changesState"];
|
||||
[archiver encodeConditionalObject:[self menu] withName:@"menu"];
|
||||
[archiver encodeObject:[self submenu] withName:@"submenu"];
|
||||
[archiver encodeConditionalObject:[self representedObject]
|
||||
withName:@"representedObject"];
|
||||
|
@ -755,7 +754,7 @@ void __dummy_GMAppKit_functionForLinking() {}
|
|||
[self setTag:[unarchiver decodeIntWithName:@"tag"]];
|
||||
[self setEnabled:[unarchiver decodeBOOLWithName:@"isEnabled"]];
|
||||
[self setChangesState:[unarchiver decodeBOOLWithName:@"changesState"]];
|
||||
[self setMenu:[unarchiver decodeObjectWithName:@"menu"]];
|
||||
[self setMenu:nil];
|
||||
[self setSubmenu:[unarchiver decodeObjectWithName:@"submenu"]];
|
||||
[self setRepresentedObject:[unarchiver
|
||||
decodeObjectWithName:@"representedObject"]];
|
||||
|
|
|
@ -152,11 +152,11 @@ static NSCell* tileCell = nil;
|
|||
kw = [self window];
|
||||
|
||||
[NSApp unhide: self];
|
||||
if (kw)
|
||||
if ([NSApp keyWindow] == nil && kw != nil)
|
||||
{
|
||||
NSGraphicsContext *context = GSCurrentContext();
|
||||
NSGraphicsContext *context = GSCurrentContext();
|
||||
|
||||
[kw orderFrontRegardless];
|
||||
[context flush];
|
||||
DPSsetinputfocus(context, [kw windowNumber]);
|
||||
}
|
||||
}
|
||||
|
@ -290,6 +290,92 @@ static NSCell* tileCell = nil;
|
|||
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
|
||||
{
|
||||
if (NSApp != nil && NSApp != self)
|
||||
|
@ -366,11 +452,17 @@ static NSCell* tileCell = nil;
|
|||
|
||||
[self activateIgnoringOtherApps: YES];
|
||||
|
||||
#ifndef STRICT_OPENSTEP
|
||||
/* Register self as observer to every window closing. */
|
||||
/* Register self as observer to window events. */
|
||||
[nc addObserver: self selector: @selector(_windowWillClose:)
|
||||
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 */
|
||||
[nc postNotificationName: NSApplicationDidFinishLaunchingNotification
|
||||
|
@ -418,6 +510,8 @@ static NSCell* tileCell = nil;
|
|||
/* Let ourselves know we are within dealloc */
|
||||
gnustep_gui_app_is_in_dealloc = YES;
|
||||
|
||||
[[NSNotificationCenter defaultCenter] removeObserver: self];
|
||||
|
||||
RELEASE(_hidden);
|
||||
RELEASE(_inactive);
|
||||
RELEASE(listener);
|
||||
|
@ -650,8 +744,17 @@ static NSCell* tileCell = nil;
|
|||
if ([theWindow isKindOfClass: [NSPanel class]])
|
||||
[theWindow center];
|
||||
|
||||
if ([self isActive])
|
||||
[theWindow makeKeyWindow];
|
||||
if ([self isActive] == YES)
|
||||
{
|
||||
if ([theWindow canBecomeKeyWindow] == YES)
|
||||
{
|
||||
[theWindow makeKeyWindow];
|
||||
}
|
||||
else if ([theWindow canBecomeMainWindow] == YES)
|
||||
{
|
||||
[theWindow makeMainWindow];
|
||||
}
|
||||
}
|
||||
[theWindow orderFrontRegardless];
|
||||
|
||||
theSession = NULL;
|
||||
|
@ -699,7 +802,14 @@ static NSCell* tileCell = nil;
|
|||
format: @"runModalSession: with wrong session"];
|
||||
|
||||
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();
|
||||
|
||||
|
@ -1142,7 +1252,10 @@ NSAssert([event retainCount] > 0, NSInternalInconsistencyException);
|
|||
[_hidden removeAllObjects];
|
||||
if ([[self windows] containsObject: _hidden_key])
|
||||
{
|
||||
NSGraphicsContext *context = GSCurrentContext();
|
||||
|
||||
[_hidden_key makeKeyAndOrderFront: self];
|
||||
DPSsetinputfocus(context, [_hidden_key windowNumber]);
|
||||
_hidden_key = nil;
|
||||
}
|
||||
|
||||
|
@ -1181,37 +1294,12 @@ NSAssert([event retainCount] > 0, NSInternalInconsistencyException);
|
|||
*/
|
||||
- (NSWindow*) keyWindow
|
||||
{
|
||||
NSArray *window_list = [self windows];
|
||||
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;
|
||||
return _key_window;
|
||||
}
|
||||
|
||||
- (NSWindow*) mainWindow
|
||||
{
|
||||
NSArray *window_list = [self windows];
|
||||
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;
|
||||
return _main_window;
|
||||
}
|
||||
|
||||
- (NSWindow*) makeWindowsPerform: (SEL)aSelector inOrder: (BOOL)flag
|
||||
|
@ -1808,36 +1896,5 @@ NSAssert([event retainCount] > 0, NSInternalInconsistencyException);
|
|||
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 */
|
||||
|
||||
|
|
|
@ -558,20 +558,26 @@ static NSMapTable* windowmaps = NULL;
|
|||
*/
|
||||
- (void) becomeKeyWindow
|
||||
{
|
||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||
if (_f.is_key == NO)
|
||||
{
|
||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||
|
||||
_f.is_key = YES;
|
||||
DPSsetinputfocus(GSCurrentContext(), [self windowNumber]);
|
||||
[self resetCursorRects];
|
||||
[nc postNotificationName: NSWindowDidBecomeKeyNotification object: self];
|
||||
_f.is_key = YES;
|
||||
DPSsetinputfocus(GSCurrentContext(), [self windowNumber]);
|
||||
[self resetCursorRects];
|
||||
[nc postNotificationName: NSWindowDidBecomeKeyNotification object: self];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) becomeMainWindow
|
||||
{
|
||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||
if (_f.is_main == NO)
|
||||
{
|
||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||
|
||||
_f.is_main = YES;
|
||||
[nc postNotificationName: NSWindowDidBecomeMainNotification object: self];
|
||||
_f.is_main = YES;
|
||||
[nc postNotificationName: NSWindowDidBecomeMainNotification object: self];
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL) canBecomeKeyWindow
|
||||
|
@ -672,19 +678,25 @@ static NSMapTable* windowmaps = NULL;
|
|||
|
||||
- (void) resignKeyWindow
|
||||
{
|
||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||
if (_f.is_key == YES)
|
||||
{
|
||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||
|
||||
_f.is_key = NO;
|
||||
[self discardCursorRects];
|
||||
[nc postNotificationName: NSWindowDidResignKeyNotification object: self];
|
||||
_f.is_key = NO;
|
||||
[self discardCursorRects];
|
||||
[nc postNotificationName: NSWindowDidResignKeyNotification object: self];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) resignMainWindow
|
||||
{
|
||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||
if (_f.is_main == YES)
|
||||
{
|
||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||
|
||||
_f.is_main = NO;
|
||||
[nc postNotificationName: NSWindowDidResignMainNotification object: self];
|
||||
_f.is_main = NO;
|
||||
[nc postNotificationName: NSWindowDidResignMainNotification object: self];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) setHidesOnDeactivate: (BOOL)flag
|
||||
|
|
Loading…
Reference in a new issue