mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 19:00:47 +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
6d3f7f9d38
commit
feaf4828d5
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>
|
Tue Oct 15 02:36:32 2002 Nicola Pero <n.pero@mi.flashnet.it>
|
||||||
|
|
||||||
* Source/NSApplication.m (initialize_gnustep_backend): Get the
|
* Source/NSApplication.m (initialize_gnustep_backend): Get the
|
||||||
|
|
|
@ -44,7 +44,7 @@ the TIFF Graphics library version
|
||||||
@value{GNUSTEP-GUI-LIBTIFF} is required.
|
@value{GNUSTEP-GUI-LIBTIFF} is required.
|
||||||
|
|
||||||
It also requires a FoundationKit library as specified by the OpenStep
|
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.
|
Base Library.
|
||||||
|
|
||||||
@section Where do I send bug reports?
|
@section Where do I send bug reports?
|
||||||
|
|
|
@ -266,7 +266,7 @@ NSApplication *NSApp = nil;
|
||||||
|
|
||||||
- (BOOL) canBecomeKeyWindow
|
- (BOOL) canBecomeKeyWindow
|
||||||
{
|
{
|
||||||
return YES;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) worksWhenModal
|
- (BOOL) worksWhenModal
|
||||||
|
@ -1002,7 +1002,7 @@ static NSCell* tileCell = nil;
|
||||||
[_listener updateServicesMenu];
|
[_listener updateServicesMenu];
|
||||||
[_main_menu update];
|
[_main_menu update];
|
||||||
DESTROY(_runLoopPool);
|
DESTROY(_runLoopPool);
|
||||||
|
|
||||||
while (_app_is_running)
|
while (_app_is_running)
|
||||||
{
|
{
|
||||||
IF_NO_GC(_runLoopPool = [arpClass new]);
|
IF_NO_GC(_runLoopPool = [arpClass new]);
|
||||||
|
@ -2468,8 +2468,6 @@ delegate.
|
||||||
RELEASE(iv);
|
RELEASE(iv);
|
||||||
|
|
||||||
[_app_icon_window orderFrontRegardless];
|
[_app_icon_window orderFrontRegardless];
|
||||||
[GSServerForWindow(_app_icon_window)
|
|
||||||
setinputfocus: [_app_icon_window windowNumber]];
|
|
||||||
return self;
|
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];
|
[super init];
|
||||||
_documentIndex = untitledCount++;
|
_documentIndex = untitledCount++;
|
||||||
_windowControllers = [[NSMutableArray alloc] init];
|
_windowControllers = [[NSMutableArray alloc] init];
|
||||||
|
|
||||||
|
/* Set our default type */
|
||||||
|
[self setFileType: [[[self class] writableTypes] objectAtIndex: 0]];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,10 @@
|
||||||
#include <AppKit/NSScreen.h>
|
#include <AppKit/NSScreen.h>
|
||||||
#include <AppKit/NSAttributedString.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 */
|
/* A menu's title is an instance of this class */
|
||||||
@interface NSMenuWindowTitleView : NSView
|
@interface NSMenuWindowTitleView : NSView
|
||||||
{
|
{
|
||||||
|
@ -80,8 +84,18 @@ static NSString *NSMenuLocationsKey = @"NSMenuLocations";
|
||||||
static NSNotificationCenter *nc;
|
static NSNotificationCenter *nc;
|
||||||
|
|
||||||
@interface NSMenu (GNUstepPrivate)
|
@interface NSMenu (GNUstepPrivate)
|
||||||
- (NSString*) _locationKey;
|
- (NSString *) _locationKey;
|
||||||
- (NSPanel*) _createWindow;
|
- (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
|
@end
|
||||||
|
|
||||||
@implementation NSMenu (GNUstepPrivate)
|
@implementation NSMenu (GNUstepPrivate)
|
||||||
|
@ -111,9 +125,9 @@ static NSNotificationCenter *nc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create a non autorelease window for this menu. */
|
/* Create a non autorelease window for this menu. */
|
||||||
- (NSPanel*) _createWindow
|
- (NSMenuPanel*) _createWindow
|
||||||
{
|
{
|
||||||
NSPanel *win = [[NSPanel alloc]
|
NSMenuPanel *win = [[NSMenuPanel alloc]
|
||||||
initWithContentRect: NSZeroRect
|
initWithContentRect: NSZeroRect
|
||||||
styleMask: NSBorderlessWindowMask
|
styleMask: NSBorderlessWindowMask
|
||||||
backing: NSBackingStoreBuffered
|
backing: NSBackingStoreBuffered
|
||||||
|
|
|
@ -223,8 +223,8 @@ Code shared with [NSWindow -sendEvent:], remember to update both places.
|
||||||
{
|
{
|
||||||
[self makeFirstResponder: v];
|
[self makeFirstResponder: v];
|
||||||
}
|
}
|
||||||
if (_lastDragView)
|
if (_lastView)
|
||||||
DESTROY(_lastDragView);
|
DESTROY(_lastView);
|
||||||
if (wasKey == YES || [v acceptsFirstMouse: theEvent] == YES)
|
if (wasKey == YES || [v acceptsFirstMouse: theEvent] == YES)
|
||||||
{
|
{
|
||||||
if ([NSHelpManager isContextHelpModeActive])
|
if ([NSHelpManager isContextHelpModeActive])
|
||||||
|
@ -233,10 +233,7 @@ Code shared with [NSWindow -sendEvent:], remember to update both places.
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Technically this should be just _lastView,
|
ASSIGN(_lastView, v);
|
||||||
but I don't think it's a problem reusing this
|
|
||||||
ivar */
|
|
||||||
ASSIGN(_lastDragView, v);
|
|
||||||
[v mouseDown: theEvent];
|
[v mouseDown: theEvent];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,6 +97,23 @@ BOOL GSViewAcceptsDrag(NSView *v, id<NSDraggingInfo> dragInfo);
|
||||||
{
|
{
|
||||||
[self displayIfNeeded];
|
[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
|
- (void) _lossOfKeyOrMainWindow
|
||||||
{
|
{
|
||||||
NSArray *windowList = GSAllWindows();
|
NSArray *windowList = GSAllWindows();
|
||||||
|
@ -107,6 +124,7 @@ BOOL GSViewAcceptsDrag(NSView *v, id<NSDraggingInfo> dragInfo);
|
||||||
|
|
||||||
if ([self isKeyWindow])
|
if ([self isKeyWindow])
|
||||||
{
|
{
|
||||||
|
NSWindow *menu_window= [[NSApp mainMenu] window];
|
||||||
[self resignKeyWindow];
|
[self resignKeyWindow];
|
||||||
i = pos + 1;
|
i = pos + 1;
|
||||||
if (i == c)
|
if (i == c)
|
||||||
|
@ -116,7 +134,7 @@ BOOL GSViewAcceptsDrag(NSView *v, id<NSDraggingInfo> dragInfo);
|
||||||
while (i != pos)
|
while (i != pos)
|
||||||
{
|
{
|
||||||
w = [windowList objectAtIndex: i];
|
w = [windowList objectAtIndex: i];
|
||||||
if ([w isVisible] && [w canBecomeKeyWindow])
|
if ([w isVisible] && [w canBecomeKeyWindow] && w != menu_window)
|
||||||
{
|
{
|
||||||
[w makeKeyWindow];
|
[w makeKeyWindow];
|
||||||
break;
|
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,
|
* if we didn't find a possible key window - use the main menu window
|
||||||
* failing that, use the menu window.
|
|
||||||
*/
|
*/
|
||||||
if (i == pos)
|
if (i == pos)
|
||||||
{
|
{
|
||||||
w = [NSApp iconWindow];
|
if (menu_window != nil)
|
||||||
if (w == nil || [w isVisible] == NO)
|
|
||||||
{
|
{
|
||||||
w = [[NSApp mainMenu] window];
|
[GSServerForWindow(menu_window) setinputfocus:
|
||||||
}
|
[menu_window windowNumber]];
|
||||||
if (w != nil && [w isVisible] == YES)
|
|
||||||
{
|
|
||||||
[GSServerForWindow(w) setinputfocus: [w windowNumber]];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2990,10 +3003,13 @@ Code shared with [NSPanel -sendEvent:], remember to update both places.
|
||||||
/* Window Manager just deminiaturized us */
|
/* Window Manager just deminiaturized us */
|
||||||
[self _didDeminiaturize: self];
|
[self _didDeminiaturize: self];
|
||||||
}
|
}
|
||||||
if (_f.visible == NO)
|
if ([NSApp isHidden])
|
||||||
{
|
{
|
||||||
NSDebugLLog(@"Focus", @"WM take focus on hidden window %d",
|
/* This often occurs when hidding an app, since a bunch
|
||||||
_windowNum);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
if ([self canBecomeKeyWindow] == YES)
|
if ([self canBecomeKeyWindow] == YES)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue