mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 07:00:46 +00:00
More focus fixes
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@14800 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
b1e6dbc92e
commit
527fd35378
7 changed files with 77 additions and 37 deletions
21
ChangeLog
21
ChangeLog
|
@ -1,3 +1,24 @@
|
|||
2002-10-18 Adam Fedor <fedor@gnu.org>
|
||||
|
||||
* Documentation/announce.texi: Fix grammer.
|
||||
|
||||
* Try to fix focus interaction with WindowMaker.
|
||||
* Source/NSApplication.m ([NSIconWindow -canBecomeKeyWindow]):
|
||||
Revert 2002-10-08 change.
|
||||
(-appIconInit): Don't set input focus to app icon.
|
||||
(-_windowWillClose:): Idem.
|
||||
* Source/NSMenu.m: New class NSMenuPanel
|
||||
(_createWindow): Use it.
|
||||
* Source/NSWindow.m (-_lossOfKeyOrMainWindow): Make sure menu
|
||||
window doesn't get key except as a last resort.
|
||||
(-sendEvent: (GSAppKitWindowFocusIn)): Don't become key if app
|
||||
is hidden.
|
||||
|
||||
* Source/NSPanel.m (-sendEvent:): Same as change to NSWindow on
|
||||
2002-10-03.
|
||||
|
||||
* Source/NSDocument.m (-init): Set default file type.
|
||||
|
||||
Tue Oct 15 02:36:32 2002 Nicola Pero <n.pero@mi.flashnet.it>
|
||||
|
||||
* Source/NSApplication.m (initialize_gnustep_backend): Get the
|
||||
|
|
|
@ -44,7 +44,7 @@ the TIFF Graphics library version
|
|||
@value{GNUSTEP-GUI-LIBTIFF} is required.
|
||||
|
||||
It also requires a FoundationKit library as specified by the OpenStep
|
||||
specification. The FoundationKit libraries known to work are the GNUstep
|
||||
specification. The only FoundationKit library known to work is the GNUstep
|
||||
Base Library.
|
||||
|
||||
@section Where do I send bug reports?
|
||||
|
|
|
@ -266,7 +266,7 @@ NSApplication *NSApp = nil;
|
|||
|
||||
- (BOOL) canBecomeKeyWindow
|
||||
{
|
||||
return YES;
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL) worksWhenModal
|
||||
|
@ -1002,7 +1002,7 @@ static NSCell* tileCell = nil;
|
|||
[_listener updateServicesMenu];
|
||||
[_main_menu update];
|
||||
DESTROY(_runLoopPool);
|
||||
|
||||
|
||||
while (_app_is_running)
|
||||
{
|
||||
IF_NO_GC(_runLoopPool = [arpClass new]);
|
||||
|
@ -2468,8 +2468,6 @@ delegate.
|
|||
RELEASE(iv);
|
||||
|
||||
[_app_icon_window orderFrontRegardless];
|
||||
[GSServerForWindow(_app_icon_window)
|
||||
setinputfocus: [_app_icon_window windowNumber]];
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -2684,15 +2682,6 @@ delegate.
|
|||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* If the app has no key window - we must make sure the icon window
|
||||
* has keyboard focus, even though it doesn't actually use kb events.
|
||||
*/
|
||||
if ([self keyWindow] == nil)
|
||||
{
|
||||
[GSServerForWindow(_app_icon_window)
|
||||
setinputfocus: [_app_icon_window windowNumber]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -67,6 +67,9 @@
|
|||
[super init];
|
||||
_documentIndex = untitledCount++;
|
||||
_windowControllers = [[NSMutableArray alloc] init];
|
||||
|
||||
/* Set our default type */
|
||||
[self setFileType: [[[self class] writableTypes] objectAtIndex: 0]];
|
||||
return self;
|
||||
}
|
||||
|
||||
|
|
|
@ -55,6 +55,10 @@
|
|||
#include <AppKit/NSScreen.h>
|
||||
#include <AppKit/NSAttributedString.h>
|
||||
|
||||
/* Subclass of NSPanel since menus cannot become key */
|
||||
@interface NSMenuPanel : NSPanel
|
||||
@end
|
||||
|
||||
/* A menu's title is an instance of this class */
|
||||
@interface NSMenuWindowTitleView : NSView
|
||||
{
|
||||
|
@ -80,8 +84,18 @@ static NSString *NSMenuLocationsKey = @"NSMenuLocations";
|
|||
static NSNotificationCenter *nc;
|
||||
|
||||
@interface NSMenu (GNUstepPrivate)
|
||||
- (NSString*) _locationKey;
|
||||
- (NSPanel*) _createWindow;
|
||||
- (NSString *) _locationKey;
|
||||
- (NSMenuPanel *) _createWindow;
|
||||
@end
|
||||
|
||||
@implementation NSMenuPanel
|
||||
- (BOOL) canBecomeKeyWindow
|
||||
{
|
||||
/* This should be NO, but there's currently a bug in the interaction
|
||||
with WindowMaker that causes spurious deactivation of the app
|
||||
if the app icon is the only window that can become key */
|
||||
return YES;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation NSMenu (GNUstepPrivate)
|
||||
|
@ -111,9 +125,9 @@ static NSNotificationCenter *nc;
|
|||
}
|
||||
|
||||
/* Create a non autorelease window for this menu. */
|
||||
- (NSPanel*) _createWindow
|
||||
- (NSMenuPanel*) _createWindow
|
||||
{
|
||||
NSPanel *win = [[NSPanel alloc]
|
||||
NSMenuPanel *win = [[NSMenuPanel alloc]
|
||||
initWithContentRect: NSZeroRect
|
||||
styleMask: NSBorderlessWindowMask
|
||||
backing: NSBackingStoreBuffered
|
||||
|
|
|
@ -223,8 +223,8 @@ Code shared with [NSWindow -sendEvent:], remember to update both places.
|
|||
{
|
||||
[self makeFirstResponder: v];
|
||||
}
|
||||
if (_lastDragView)
|
||||
DESTROY(_lastDragView);
|
||||
if (_lastView)
|
||||
DESTROY(_lastView);
|
||||
if (wasKey == YES || [v acceptsFirstMouse: theEvent] == YES)
|
||||
{
|
||||
if ([NSHelpManager isContextHelpModeActive])
|
||||
|
@ -233,10 +233,7 @@ Code shared with [NSWindow -sendEvent:], remember to update both places.
|
|||
}
|
||||
else
|
||||
{
|
||||
/* Technically this should be just _lastView,
|
||||
but I don't think it's a problem reusing this
|
||||
ivar */
|
||||
ASSIGN(_lastDragView, v);
|
||||
ASSIGN(_lastView, v);
|
||||
[v mouseDown: theEvent];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -97,6 +97,23 @@ BOOL GSViewAcceptsDrag(NSView *v, id<NSDraggingInfo> dragInfo);
|
|||
{
|
||||
[self displayIfNeeded];
|
||||
}
|
||||
|
||||
/* We get here if we were ordered out or miniaturized. In this case if
|
||||
we were the key or main window, go through the list of all windows
|
||||
and try to find another window that can take our place as key
|
||||
and/or main. Automatically ignore windows that cannot become
|
||||
key/main and skip the main menu window (which is the only
|
||||
non-obvious window that can become key) unless we have no choice
|
||||
(i.e. all the candidate windows were ordered out.)
|
||||
|
||||
FIXME: It should be the appicon which can become key, not the main
|
||||
menu, but there is currently an unsolved problem with WindowMaker
|
||||
interaction that prevents me from doing this.
|
||||
|
||||
FIXME: It would really be better if we maintained a stack of the
|
||||
most recent key/main windows and went through in order of most
|
||||
recent to least recent. That's probably a lot of work, however.
|
||||
*/
|
||||
- (void) _lossOfKeyOrMainWindow
|
||||
{
|
||||
NSArray *windowList = GSAllWindows();
|
||||
|
@ -107,6 +124,7 @@ BOOL GSViewAcceptsDrag(NSView *v, id<NSDraggingInfo> dragInfo);
|
|||
|
||||
if ([self isKeyWindow])
|
||||
{
|
||||
NSWindow *menu_window= [[NSApp mainMenu] window];
|
||||
[self resignKeyWindow];
|
||||
i = pos + 1;
|
||||
if (i == c)
|
||||
|
@ -116,7 +134,7 @@ BOOL GSViewAcceptsDrag(NSView *v, id<NSDraggingInfo> dragInfo);
|
|||
while (i != pos)
|
||||
{
|
||||
w = [windowList objectAtIndex: i];
|
||||
if ([w isVisible] && [w canBecomeKeyWindow])
|
||||
if ([w isVisible] && [w canBecomeKeyWindow] && w != menu_window)
|
||||
{
|
||||
[w makeKeyWindow];
|
||||
break;
|
||||
|
@ -129,19 +147,14 @@ BOOL GSViewAcceptsDrag(NSView *v, id<NSDraggingInfo> dragInfo);
|
|||
}
|
||||
}
|
||||
/*
|
||||
* if we didn't find a possible key window - use the app icon or,
|
||||
* failing that, use the menu window.
|
||||
* if we didn't find a possible key window - use the main menu window
|
||||
*/
|
||||
if (i == pos)
|
||||
{
|
||||
w = [NSApp iconWindow];
|
||||
if (w == nil || [w isVisible] == NO)
|
||||
if (menu_window != nil)
|
||||
{
|
||||
w = [[NSApp mainMenu] window];
|
||||
}
|
||||
if (w != nil && [w isVisible] == YES)
|
||||
{
|
||||
[GSServerForWindow(w) setinputfocus: [w windowNumber]];
|
||||
[GSServerForWindow(menu_window) setinputfocus:
|
||||
[menu_window windowNumber]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2990,10 +3003,13 @@ Code shared with [NSPanel -sendEvent:], remember to update both places.
|
|||
/* Window Manager just deminiaturized us */
|
||||
[self _didDeminiaturize: self];
|
||||
}
|
||||
if (_f.visible == NO)
|
||||
if ([NSApp isHidden])
|
||||
{
|
||||
NSDebugLLog(@"Focus", @"WM take focus on hidden window %d",
|
||||
_windowNum);
|
||||
/* This often occurs when hidding an app, since a bunch
|
||||
of windows get hidden at once, and the WM is searching
|
||||
for a window to take focus after each one gets
|
||||
hidden. */
|
||||
NSDebugLLog(@"Focus", @"WM take focus while hiding");
|
||||
break;
|
||||
}
|
||||
if ([self canBecomeKeyWindow] == YES)
|
||||
|
|
Loading…
Reference in a new issue