* Source/NSWindow.m: Don't use the flags for key/main window tracking.

These flags are getting out of sync due to different behavior on
	different backends.  Also, it's better to keep the state in one place
	instead of keeping them in sync.  I changed all of the instances of
	_f.is_key to [self isKeyWindow] and all of the instances of _f.is_main
	to [self isMainWindow] and those methods now check with NSApp to 
	determine if the current window is main.   I realize this is slower
	than the previous method of using flags, but it is also more resilient
	and reliable when the backend sends extra events.  This corrects the
	issue on Windows where we were losing the main window and had two 
	windows marked as "main".


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@29295 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Gregory John Casamento 2010-01-16 19:56:27 +00:00
parent f616b91157
commit 6a9dfe8d61
2 changed files with 33 additions and 25 deletions

View file

@ -1,3 +1,17 @@
2010-01-16 14:55-EST Gregory John Casamento <greg.casamento@gmail.com>
* Source/NSWindow.m: Don't use the flags for key/main window tracking.
These flags are getting out of sync due to different behavior on
different backends. Also, it's better to keep the state in one place
instead of keeping them in sync. I changed all of the instances of
_f.is_key to [self isKeyWindow] and all of the instances of _f.is_main
to [self isMainWindow] and those methods now check with NSApp to
determine if the current window is main. I realize this is slower
than the previous method of using flags, but it is also more resilient
and reliable when the backend sends extra events. This corrects the
issue on Windows where we were losing the main window and had two
windows marked as "main".
2010-01-16 Quentin Mathe <quentin.mathe@gmail.com>
Finished to implement the NSTable/OutlineView sort descriptor support.
@ -25,6 +39,7 @@
* Source/NSImage.m: Changes to fix bug #28580.
>>>>>>> .r29294
2010-01-15 13:08-EST Gregory John Casamento <greg.casamento@gmail.com>
* Headers/Additions/GNUstepGUI/GSTheme.h: Added method to call

View file

@ -869,8 +869,6 @@ many times.
: _backingType
: _styleMask
: [_screen screenNumber]];
if (_windowNum == 0)
[NSException raise:@"No Window" format:@"Failed to obtain window from the back end"];
[srv setwindowlevel: [self level] : _windowNum];
if (_parent != nil)
[srv setParentWindow: [_parent windowNumber]
@ -1442,10 +1440,8 @@ many times.
*/
- (void) becomeKeyWindow
{
if (_f.is_key == NO)
if ([self isKeyWindow])
{
_f.is_key = YES;
if ((!_firstResponder) || (_firstResponder == self))
{
if (_initialFirstResponder)
@ -1471,10 +1467,9 @@ many times.
- (void) becomeMainWindow
{
if (_f.is_main == NO)
if ([self isMainWindow] == NO)
{
_f.is_main = YES;
if (_f.is_key == NO)
if ([self isKeyWindow] == NO)
{
[_wv setInputState: GSTitleBarMain];
}
@ -1527,12 +1522,12 @@ many times.
- (BOOL) isKeyWindow
{
return _f.is_key;
return ([NSApp keyWindow] == self);
}
- (BOOL) isMainWindow
{
return _f.is_main;
return ([NSApp mainWindow] == self);
}
- (BOOL) isMiniaturized
@ -1570,7 +1565,7 @@ many times.
- (void) makeKeyWindow
{
if (!_f.visible || _f.is_miniaturized || _f.is_key == YES)
if (!_f.visible || _f.is_miniaturized || [self isKeyWindow])
{
return;
}
@ -1583,10 +1578,11 @@ many times.
- (void) makeMainWindow
{
if (!_f.visible || _f.is_miniaturized || _f.is_main == YES)
if (!_f.visible || _f.is_miniaturized || [self isMainWindow])
{
return;
}
if (![self canBecomeMainWindow])
return;
[[NSApp mainWindow] resignMainWindow];
@ -1766,15 +1762,13 @@ many times.
- (void) resignKeyWindow
{
if (_f.is_key == YES)
if ([self isKeyWindow])
{
if ((_firstResponder != self)
&& [_firstResponder respondsToSelector: @selector(resignKeyWindow)])
[_firstResponder resignKeyWindow];
_f.is_key = NO;
if (_f.is_main == YES)
if ([self isMainWindow])
{
[_wv setInputState: GSTitleBarMain];
}
@ -1790,10 +1784,9 @@ many times.
- (void) resignMainWindow
{
if (_f.is_main == YES)
if ([self isMainWindow])
{
_f.is_main = NO;
if (_f.is_key == YES)
if ([self isKeyWindow])
{
[_wv setInputState: GSTitleBarKey];
}
@ -2572,7 +2565,7 @@ discardCursorRectsForView(NSView *theView)
if (_f.cursor_rects_valid)
{
if (_f.is_key && _f.cursor_rects_enabled)
if ([self isKeyWindow] && _f.cursor_rects_enabled)
{
NSEvent *e = [NSEvent otherEventWithType: NSAppKitDefined
location: NSMakePoint(-1, -1)
@ -2623,7 +2616,7 @@ resetCursorRectsForView(NSView *theView)
resetCursorRectsForView(_wv);
_f.cursor_rects_valid = YES;
if (_f.is_key && _f.cursor_rects_enabled)
if ([self isKeyWindow] && _f.cursor_rects_enabled)
{
NSPoint loc = [self mouseLocationOutsideOfEventStream];
if (NSMouseInRect(loc, [_wv bounds], NO))
@ -3587,12 +3580,12 @@ resetCursorRectsForView(NSView *theView)
{
case NSLeftMouseDown:
{
BOOL wasKey = _f.is_key;
BOOL wasKey = [self isKeyWindow];
if (_f.has_closed == NO)
{
v = [_wv hitTest: [theEvent locationInWindow]];
if (_f.is_key == NO && _windowLevel != NSDesktopWindowLevel)
if ([self isKeyWindow] == NO && _windowLevel != NSDesktopWindowLevel)
{
/* NSPanel modification: check becomesKeyOnlyIfNeeded. */
if (![self becomesKeyOnlyIfNeeded]
@ -3744,7 +3737,7 @@ resetCursorRectsForView(NSView *theView)
*/
(*ctImp)(self, ctSel, _wv, theEvent);
if (_f.is_key)
if ([self isKeyWindow])
{
/*
* We need to go through all of the views, and if there is any with
@ -3959,7 +3952,7 @@ resetCursorRectsForView(NSView *theView)
* determine if we should send a NSMouseExited event. */
(*ctImp)(self, ctSel, _wv, theEvent);
if (_f.is_key)
if ([self isKeyWindow])
{
/*
* We need to go through all of the views, and if