Modal session and cursor fixes

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@12112 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
fedor 2002-01-15 16:43:13 +00:00
parent ebdd056b94
commit f32e8eb2d2
4 changed files with 70 additions and 3 deletions

View file

@ -1,3 +1,14 @@
2002-01-15 Adam Fedor <fedor@gnu.org>
* Source/NSApplication.m (-finishLaunching): Make main menu key
when there is no other key or main window.
(-runModalSession:): Update main menu.
(-targetForAction:): Search fixes. Return nil if in modal session
and key window does not respond to action.
* Source/NSWindow.m (-sendEvent:): Only check cursor rects
if isCursorRectsEnabled.
2002-01-10 Adam Fedor <fedor@gnu.org> 2002-01-10 Adam Fedor <fedor@gnu.org>
* Source/NSPopUpButton.m (-keyDown:): Handle obscure case of user * Source/NSPopUpButton.m (-keyDown:): Handle obscure case of user

View file

@ -633,6 +633,17 @@ static NSCell* tileCell = nil;
} }
} }
/*
* If there is no main or key window, we need to make the main menu key
* so it can respond to menu shortcuts and deactivate the app properly
* when it looses focus.
*/
if (_key_window == nil && _main_window == nil)
{
_key_window = [[self mainMenu] window];
[_key_window becomeKeyWindow];
}
/* /*
* If there was more than one window set as key or main, we must make sure * If there was more than one window set as key or main, we must make sure
* that the one we have recorded is the real one by making it become key/main * that the one we have recorded is the real one by making it become key/main
@ -1039,6 +1050,18 @@ static NSCell* tileCell = nil;
return code; return code;
} }
/**
<p>
Processes one event for a modal session described by the theSession
variable. Before processing the event, it makes the session window key
and orders the window front, so there is no need to do this
separately. When finished, it returns the state of the session (i.e.
whether it is still running or has been stopped, etc)
<p>
</p>
See Also: -runModalForWindow:
</p>
*/
- (int) runModalSession: (NSModalSession)theSession - (int) runModalSession: (NSModalSession)theSession
{ {
NSAutoreleasePool *pool; NSAutoreleasePool *pool;
@ -1120,8 +1143,17 @@ static NSCell* tileCell = nil;
if (found == YES) if (found == YES)
{ {
NSEventType type = [_current_event type];
[self sendEvent: _current_event]; [self sendEvent: _current_event];
// update (en/disable) the services menu's items
if (type != NSPeriodic && type != NSMouseMoved)
{
[_listener updateServicesMenu];
[_main_menu update];
}
/* /*
* Check to see if the window has gone away - if so, end session. * Check to see if the window has gone away - if so, end session.
*/ */
@ -1143,6 +1175,14 @@ static NSCell* tileCell = nil;
return theSession->runState; return theSession->runState;
} }
/**
<p>
Returns the window that is part of the current modal session, if any.
<p>
</p>
See -runModalForWindow:
</p>
*/
- (NSWindow *) modalWindow - (NSWindow *) modalWindow
{ {
if (_session != 0) if (_session != 0)
@ -1384,6 +1424,15 @@ IF_NO_GC(NSAssert([event retainCount] > 0, NSInternalInconsistencyException));
} }
} }
/**
<p>
Returns the target object that will respond to aSelector, if any. The
method first checks if any of the key window's first responders, the
key window or its delegate responds. Next it checks the main window in
the same way. Finally it checks the receiver (NSApplication) and it's
delegate.
</p>
*/
- (id) targetForAction: (SEL)aSelector - (id) targetForAction: (SEL)aSelector
{ {
NSWindow *keyWindow; NSWindow *keyWindow;
@ -1394,7 +1443,7 @@ IF_NO_GC(NSAssert([event retainCount] > 0, NSInternalInconsistencyException));
if (keyWindow != nil) if (keyWindow != nil)
{ {
resp = [keyWindow firstResponder]; resp = [keyWindow firstResponder];
while (resp != nil) while (resp != nil && resp != keyWindow)
{ {
if ([resp respondsToSelector: aSelector]) if ([resp respondsToSelector: aSelector])
{ {
@ -1413,11 +1462,14 @@ IF_NO_GC(NSAssert([event retainCount] > 0, NSInternalInconsistencyException));
} }
} }
if (_session != 0)
return nil;
mainWindow = [self mainWindow]; mainWindow = [self mainWindow];
if (keyWindow != mainWindow && mainWindow != nil) if (keyWindow != mainWindow && mainWindow != nil)
{ {
resp = [mainWindow firstResponder]; resp = [mainWindow firstResponder];
while (resp != nil) while (resp != nil && resp != mainWindow)
{ {
if ([resp respondsToSelector: aSelector]) if ([resp respondsToSelector: aSelector])
{ {

View file

@ -28,6 +28,7 @@
*/ */
#include <Foundation/NSArray.h> #include <Foundation/NSArray.h>
#include <Foundation/NSDebug.h>
#include <AppKit/NSColor.h> #include <AppKit/NSColor.h>
#include <AppKit/NSCursor.h> #include <AppKit/NSCursor.h>
#include <AppKit/NSGraphics.h> #include <AppKit/NSGraphics.h>
@ -123,6 +124,7 @@ static NSMutableDictionary *cursorDict = nil;
[gnustep_gui_cursor_stack removeLastObject]; [gnustep_gui_cursor_stack removeLastObject];
gnustep_gui_current_cursor = [gnustep_gui_cursor_stack lastObject]; gnustep_gui_current_cursor = [gnustep_gui_cursor_stack lastObject];
NSDebugLLog(@"NSCursor", @"Cursor pop");
[gnustep_gui_current_cursor set]; [gnustep_gui_current_cursor set];
} }
} }
@ -334,6 +336,7 @@ backgroundColorHint:(NSColor *)bg
{ {
[gnustep_gui_cursor_stack addObject: self]; [gnustep_gui_cursor_stack addObject: self];
[self set]; [self set];
NSDebugLLog(@"NSCursor", @"Cursor push %p", _cid);
} }
- (void) set - (void) set

View file

@ -2735,7 +2735,8 @@ resetCursorRectsForView(NSView *theView)
* a cursor rectangle then we need to determine if we should send a * a cursor rectangle then we need to determine if we should send a
* cursor update event. * cursor update event.
*/ */
(*ccImp)(self, ccSel, _contentView, theEvent); if (_f.cursor_rects_enabled)
(*ccImp)(self, ccSel, _contentView, theEvent);
} }
_lastPoint = [theEvent locationInWindow]; _lastPoint = [theEvent locationInWindow];