Focus fixes

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@5647 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
richard 2000-01-02 20:24:56 +00:00
parent ac9555aca8
commit c4db0e07a6
3 changed files with 63 additions and 65 deletions

View file

@ -1,3 +1,8 @@
Sun Jan 2 20:20:00 2000 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* Source/NSApplication.m: Fixes for focusm handling.
* Source/NSWindow.m: ditto
Fri Dec 31 17:28:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk> Fri Dec 31 17:28:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* Source/NSSlider.m: ([drawRect:]) minor drawing fix to ensure that * Source/NSSlider.m: ([drawRect:]) minor drawing fix to ensure that

View file

@ -262,7 +262,6 @@ static NSCell* tileCell = nil;
- _appIconInit - _appIconInit
{ {
NSAppIconView *iv; NSAppIconView *iv;
NSGraphicsContext *context = GSCurrentContext();
if (app_icon == nil) if (app_icon == nil)
app_icon = [[NSImage imageNamed: @"GNUstep"] retain]; app_icon = [[NSImage imageNamed: @"GNUstep"] retain];
@ -279,7 +278,7 @@ static NSCell* tileCell = nil;
[iv setImage: app_icon]; [iv setImage: app_icon];
[_app_icon_window orderFrontRegardless]; [_app_icon_window orderFrontRegardless];
DPSsetinputfocus(context, [_app_icon_window windowNumber]); DPSsetinputfocus(GSCurrentContext(), [_app_icon_window windowNumber]);
return self; return self;
} }
@ -487,9 +486,7 @@ static NSCell* tileCell = nil;
*/ */
if ([self keyWindow] == nil) if ([self keyWindow] == nil)
{ {
NSGraphicsContext *context = GSCurrentContext(); DPSsetinputfocus(GSCurrentContext(), [_app_icon_window windowNumber]);
DPSsetinputfocus(context, [_app_icon_window windowNumber]);
} }
} }
} }
@ -716,7 +713,6 @@ static NSCell* tileCell = nil;
{ {
if (app_is_active == NO) if (app_is_active == NO)
{ {
NSWindow *kw;
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
unsigned count = [_inactive count]; unsigned count = [_inactive count];
unsigned i; unsigned i;
@ -729,17 +725,20 @@ static NSCell* tileCell = nil;
object: self]; object: self];
NSDebugLog(@"activateIgnoringOtherApps start."); NSDebugLog(@"activateIgnoringOtherApps start.");
app_is_active = YES; app_is_active = YES;
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
{ {
[[_inactive objectAtIndex: i] orderFrontRegardless]; [[_inactive objectAtIndex: i] orderFrontRegardless];
} }
if ([self keyWindow] == nil && [_inactive containsObject: _hidden_key]) [_inactive removeAllObjects];
if (_hidden_key != nil
&& [[self windows] indexOfObjectIdenticalTo: _hidden_key] != NSNotFound)
{ {
[_hidden_key makeKeyWindow]; [_hidden_key makeKeyWindow];
_hidden_key = nil;
} }
[_inactive removeAllObjects];
[main_menu update]; [main_menu update];
[main_menu display]; [main_menu display];
@ -749,14 +748,6 @@ static NSCell* tileCell = nil;
[self unhide: nil]; [self unhide: nil];
} }
kw = [self keyWindow];
if (kw != nil)
{
[kw resignKeyWindow];
[kw orderFront: self];
[kw makeKeyWindow];
}
NSDebugLog(@"activateIgnoringOtherApps end."); NSDebugLog(@"activateIgnoringOtherApps end.");
[nc postNotificationName: NSApplicationDidBecomeActiveNotification [nc postNotificationName: NSApplicationDidBecomeActiveNotification
@ -776,9 +767,13 @@ static NSCell* tileCell = nil;
[nc postNotificationName: NSApplicationWillResignActiveNotification [nc postNotificationName: NSApplicationWillResignActiveNotification
object: self]; object: self];
app_is_active = NO;
if ([self keyWindow] != nil) if ([self keyWindow] != nil)
{ {
_hidden_key = [self keyWindow]; _hidden_key = [self keyWindow];
[_hidden_key resignKeyWindow];
DPSsetinputfocus(GSCurrentContext(), [_app_icon_window windowNumber]);
} }
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
{ {
@ -799,8 +794,6 @@ static NSCell* tileCell = nil;
} }
} }
app_is_active = NO;
[nc postNotificationName: NSApplicationDidResignActiveNotification [nc postNotificationName: NSApplicationDidResignActiveNotification
object: self]; object: self];
} }
@ -1391,6 +1384,8 @@ NSAssert([event retainCount] > 0, NSInternalInconsistencyException);
if ([self keyWindow] != nil) if ([self keyWindow] != nil)
{ {
_hidden_key = [self keyWindow]; _hidden_key = [self keyWindow];
[_hidden_key resignKeyWindow];
DPSsetinputfocus(GSCurrentContext(), [_app_icon_window windowNumber]);
} }
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
{ {
@ -1451,26 +1446,26 @@ NSAssert([event retainCount] > 0, NSInternalInconsistencyException);
if (app_is_hidden == YES) if (app_is_hidden == YES)
{ {
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
unsigned count = [_hidden count]; unsigned count;
unsigned i; unsigned i;
[nc postNotificationName: NSApplicationWillUnhideNotification [nc postNotificationName: NSApplicationWillUnhideNotification
object: self]; object: self];
app_is_hidden = NO; count = [_hidden count];
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
{ {
[[_hidden objectAtIndex: i] orderFrontRegardless]; [[_hidden objectAtIndex: i] orderFrontRegardless];
} }
if ([self keyWindow] == nil && [_hidden containsObject: _hidden_key]) [_hidden removeAllObjects];
if (_hidden_key != nil
&& [[self windows] indexOfObjectIdenticalTo: _hidden_key] != NSNotFound)
{ {
NSGraphicsContext *context = GSCurrentContext();
[_hidden_key makeKeyAndOrderFront: self]; [_hidden_key makeKeyAndOrderFront: self];
DPSsetinputfocus(context, [_hidden_key windowNumber]);
_hidden_key = nil; _hidden_key = nil;
} }
[_hidden removeAllObjects];
app_is_hidden = NO;
[nc postNotificationName: NSApplicationDidUnhideNotification [nc postNotificationName: NSApplicationDidUnhideNotification
object: self]; object: self];

View file

@ -549,10 +549,7 @@ static NSMapTable* windowmaps = NULL;
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
_f.is_key = YES; _f.is_key = YES;
if ([self isVisible] == YES) DPSsetinputfocus(GSCurrentContext(), [self windowNumber]);
{
DPSsetinputfocus(GSCurrentContext(), [self windowNumber]);
}
[self resetCursorRects]; [self resetCursorRects];
[nc postNotificationName: NSWindowDidBecomeKeyNotification object: self]; [nc postNotificationName: NSWindowDidBecomeKeyNotification object: self];
} }
@ -670,6 +667,7 @@ static NSMapTable* windowmaps = NULL;
unsigned i; unsigned i;
NSWindow *w; NSWindow *w;
_f.visible = NO;
if (_rFlags.needs_display == YES) if (_rFlags.needs_display == YES)
{ {
/* /*
@ -697,19 +695,18 @@ static NSMapTable* windowmaps = NULL;
} }
} }
/* /*
* if we didn't find a possible key window - use tha app icon or, * if we didn't find a possible key window - use the app icon or,
* failing that, use the menu window. * failing that, use the menu window.
*/ */
if (i == pos) if (i == pos)
{ {
w = [NSApp iconWindow]; w = [NSApp iconWindow];
if (w != nil && [w isVisible] == YES) if (w == nil || [w isVisible] == NO)
{
[GSCurrentContext() DPSsetinputfocus: [w windowNumber]];
}
else
{ {
w = [[NSApp mainMenu] window]; w = [[NSApp mainMenu] window];
}
if (w != nil && [w isVisible] == YES)
{
[GSCurrentContext() DPSsetinputfocus: [w windowNumber]]; [GSCurrentContext() DPSsetinputfocus: [w windowNumber]];
} }
} }
@ -721,7 +718,7 @@ static NSMapTable* windowmaps = NULL;
[self resignMainWindow]; [self resignMainWindow];
if (w != nil && [w canBecomeMainWindow]) if (w != nil && [w canBecomeMainWindow])
{ {
[w makeKeyWindow]; [w makeMainWindow];
} }
else else
{ {
@ -1819,35 +1816,36 @@ resetCursorRectsForView(NSView *theView)
switch (type) switch (type)
{ {
case NSLeftMouseDown: // Left mouse down case NSLeftMouseDown: // Left mouse down
v = [content_view hitTest: [theEvent locationInWindow]]; {
if (first_responder != v) BOOL wasKey = _f.is_key;
{
[self makeFirstResponder: v]; if ([NSApp isActive] == NO && self != [NSApp iconWindow])
if (_f.is_key || [v acceptsFirstMouse: theEvent] == YES) {
{ [NSApp activateIgnoringOtherApps: YES];
if([NSHelpManager isContextHelpModeActive]) }
{ if (_f.is_key == NO)
[v helpRequested: theEvent]; {
} [self makeKeyAndOrderFront: self];
else }
{ v = [content_view hitTest: [theEvent locationInWindow]];
[v mouseDown: theEvent]; if (first_responder != v)
} {
} [self makeFirstResponder: v];
} }
else if (wasKey == YES || [v acceptsFirstMouse: theEvent] == YES)
{ {
if([NSHelpManager isContextHelpModeActive]) if ([NSHelpManager isContextHelpModeActive])
{ {
[v helpRequested: theEvent]; [v helpRequested: theEvent];
} }
else else
{ {
[v mouseDown: theEvent]; [v mouseDown: theEvent];
} }
} }
last_point = [theEvent locationInWindow]; last_point = [theEvent locationInWindow];
break; break;
}
case NSLeftMouseUp: // Left mouse up case NSLeftMouseUp: // Left mouse up
v = first_responder; /* Send to the view that got the mouse down. */ v = first_responder; /* Send to the view that got the mouse down. */