* Headers/AppKit/NSGraphics.h: Add GSOrderedWindows function.

* Source/NSApplication.m (NSAppIconView -mouseDown:): Use
        GSOrderedWindows.
        (NSApplication -deactivate): Ditto.
        (-hide:): Ditto.
        (-unhideWithoutActivation:): Ditto.
        (-makeWindowsPerform:inOrder): Ditto.
        (-orderedWindows:): Ditto.
        (-windowWillClose:): Ditto.
        * Source/GSDisplayServer.m: Implement -windowlist.
        * Source/NSWindow.m (NSCountWindowList,NSWindowList): Use 
	-windowlist.
        (GSOrderedWindows): Initial implementation.



git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@23936 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
ratmice 2006-10-21 19:13:42 +00:00
parent 72d2de4f8a
commit 009bdc8dd3
5 changed files with 122 additions and 56 deletions

View file

@ -1,3 +1,18 @@
2006-10-21 Matt Rice <ratmice@yahoo.com>
* Headers/AppKit/NSGraphics.h: Add GSOrderedWindows function.
* Source/NSApplication.m (NSAppIconView -mouseDown:): Use
GSOrderedWindows.
(NSApplication -deactivate): Ditto.
(-hide:): Ditto.
(-unhideWithoutActivation:): Ditto.
(-makeWindowsPerform:inOrder): Ditto.
(-orderedWindows:): Ditto.
(-windowWillClose:): Ditto.
* Source/GSDisplayServer.m: Implement -windowlist.
* Source/NSWindow.m (NSCountWindowList,NSWindowList): Use -windowlist.
(GSOrderedWindows): Initial implementation.
2006-10-21 11:30-EDT Matt Rice <ratmice@yahoo.com> 2006-10-21 11:30-EDT Matt Rice <ratmice@yahoo.com>
* Source/NSTableView.m: If the tableview is smaller than * Source/NSTableView.m: If the tableview is smaller than

View file

@ -215,6 +215,7 @@ GSWViewIsFlipped(NSGraphicsContext *ctxt)
@class NSArray; @class NSArray;
@class NSWindow; @class NSWindow;
APPKIT_EXPORT NSArray* GSOrderedWindows(void);
APPKIT_EXPORT NSArray* GSAllWindows(void); APPKIT_EXPORT NSArray* GSAllWindows(void);
APPKIT_EXPORT NSWindow* GSWindowWithNumber(int num); APPKIT_EXPORT NSWindow* GSWindowWithNumber(int num);
#endif #endif

View file

@ -33,6 +33,7 @@
#include <Foundation/NSThread.h> #include <Foundation/NSThread.h>
#include <Foundation/NSGeometry.h> #include <Foundation/NSGeometry.h>
#include "AppKit/NSApplication.h"
#include "AppKit/NSEvent.h" #include "AppKit/NSEvent.h"
#include "AppKit/NSImage.h" #include "AppKit/NSImage.h"
#include "AppKit/NSWindow.h" #include "AppKit/NSWindow.h"
@ -664,11 +665,25 @@ GSCurrentServer(void)
return 0; return 0;
} }
/** Returns the list of windows that the server controls */ /** Backends can override this method to return an array of window numbers
ordered front to back. The front most window being the first object
in the array.
The default implementation returns the visible windows in an
unspecified order.
*/
- (NSArray *) windowlist - (NSArray *) windowlist
{ {
[self subclassResponsibility: _cmd]; NSMutableArray *list = [NSMutableArray arrayWithArray:[NSApp windows]];
return nil; int c = [list count];
while (c-- > 0)
{
if (![[list objectAtIndex:c] isVisible])
{
[list removeObjectAtIndex:c];
}
}
return [list valueForKey:@"windowNumber"];
} }
/** Returns the depth of the window */ /** Returns the depth of the window */

View file

@ -522,12 +522,12 @@ static NSSize scaledIconSizeForSize(NSSize imageSize)
*/ */
if ([NSApp isHidden] == NO) if ([NSApp isHidden] == NO)
{ {
int i; NSArray *windows = RETAIN(GSOrderedWindows());
NSArray *windows = RETAIN([NSApp windows]); NSWindow *aWin;
NSEnumerator *iter = [windows reverseObjectEnumerator];
for (i = 0; i < [windows count]; i++)
while ((aWin = [iter nextObject]))
{ {
NSWindow *aWin = [windows objectAtIndex:i];
if ([aWin isVisible] == YES && [aWin isMiniaturized] == NO if ([aWin isVisible] == YES && [aWin isMiniaturized] == NO
&& aWin != [NSApp keyWindow] && aWin != [NSApp mainWindow] && aWin != [NSApp keyWindow] && aWin != [NSApp mainWindow]
@ -561,8 +561,10 @@ static NSSize scaledIconSizeForSize(NSSize imageSize)
RELEASE(windows); RELEASE(windows);
} }
else
[NSApp unhide: self]; {
[NSApp unhide: self];
}
} }
else else
{ {
@ -1167,6 +1169,12 @@ static NSSize scaledIconSizeForSize(NSSize imageSize)
[[_inactive objectAtIndex: i] orderFrontRegardless]; [[_inactive objectAtIndex: i] orderFrontRegardless];
} }
[_inactive removeAllObjects]; [_inactive removeAllObjects];
if (_unhide_on_activation)
{
[self unhide: nil];
}
if ([self keyWindow] == nil && _hidden_key != nil if ([self keyWindow] == nil && _hidden_key != nil
&& [[self windows] indexOfObjectIdenticalTo: _hidden_key] != NSNotFound) && [[self windows] indexOfObjectIdenticalTo: _hidden_key] != NSNotFound)
{ {
@ -1174,11 +1182,6 @@ static NSSize scaledIconSizeForSize(NSSize imageSize)
_hidden_key = nil; _hidden_key = nil;
} }
if (_unhide_on_activation)
{
[self unhide: nil];
}
if ([self keyWindow] != nil) if ([self keyWindow] != nil)
{ {
[[self keyWindow] orderFront: self]; [[self keyWindow] orderFront: self];
@ -1216,13 +1219,14 @@ static NSSize scaledIconSizeForSize(NSSize imageSize)
{ {
if (_app_is_active == YES) if (_app_is_active == YES)
{ {
NSArray *windows_list = [self windows]; NSArray *windows_list;
unsigned count = [windows_list count];
unsigned i;
NSDictionary *info; NSDictionary *info;
NSWindow *win;
NSEnumerator *iter;
[nc postNotificationName: NSApplicationWillResignActiveNotification [nc postNotificationName: NSApplicationWillResignActiveNotification
object: self]; object: self];
_app_is_active = NO; _app_is_active = NO;
@ -1235,11 +1239,14 @@ static NSSize scaledIconSizeForSize(NSSize imageSize)
// This is not a problem if it is also key, and I'm not sure if it // This is not a problem if it is also key, and I'm not sure if it
// is a problem at all. May be annoying in the case of workspace switch. // is a problem at all. May be annoying in the case of workspace switch.
[[self mainWindow] resignMainWindow]; [[self mainWindow] resignMainWindow];
for (i = 0; i < count; i++)
windows_list = GSOrderedWindows();
iter = [windows_list reverseObjectEnumerator];
while ((win = [iter nextObject]))
{ {
NSModalSession theSession; NSModalSession theSession;
NSWindow *win = [windows_list objectAtIndex: i];
if ([win isVisible] == NO) if ([win isVisible] == NO)
{ {
continue; /* Already invisible */ continue; /* Already invisible */
@ -2205,10 +2212,10 @@ image.</p><p>See Also: -applicationIconImage</p>
{ {
if (_app_is_hidden == NO) if (_app_is_hidden == NO)
{ {
NSArray *windows_list = [self windows]; NSArray *windows_list;
unsigned count = [windows_list count];
NSDictionary *info; NSDictionary *info;
unsigned i; NSWindow *win;
NSEnumerator *iter;
[nc postNotificationName: NSApplicationWillHideNotification [nc postNotificationName: NSApplicationWillHideNotification
object: self]; object: self];
@ -2218,10 +2225,12 @@ image.</p><p>See Also: -applicationIconImage</p>
_hidden_key = [self keyWindow]; _hidden_key = [self keyWindow];
[_hidden_key resignKeyWindow]; [_hidden_key resignKeyWindow];
} }
for (i = 0; i < count; i++)
{ windows_list = GSOrderedWindows();
NSWindow *win = [windows_list objectAtIndex: i]; iter = [windows_list reverseObjectEnumerator];
while ((win = [iter nextObject]))
{
if ([win isVisible] == NO) if ([win isVisible] == NO)
{ {
continue; /* Already invisible */ continue; /* Already invisible */
@ -2314,12 +2323,6 @@ image.</p><p>See Also: -applicationIconImage</p>
[[_hidden objectAtIndex: i] orderFrontRegardless]; [[_hidden objectAtIndex: i] orderFrontRegardless];
} }
[_hidden removeAllObjects]; [_hidden removeAllObjects];
if (_hidden_key != nil
&& [[self windows] indexOfObjectIdenticalTo: _hidden_key] != NSNotFound)
{
[_hidden_key makeKeyAndOrderFront: self];
_hidden_key = nil;
}
[[_app_icon_window contentView] setNeedsDisplay: YES]; [[_app_icon_window contentView] setNeedsDisplay: YES];
info = [self _notificationUserInfo]; info = [self _notificationUserInfo];
@ -2393,12 +2396,20 @@ image.</p><p>See Also: -applicationIconImage</p>
*/ */
- (NSWindow*) makeWindowsPerform: (SEL)aSelector inOrder: (BOOL)flag - (NSWindow*) makeWindowsPerform: (SEL)aSelector inOrder: (BOOL)flag
{ {
NSArray *window_list = [self windows]; NSArray *window_list;
unsigned i; unsigned i, c;
// FIXME flag ignored // so i suppose when flag is YES it only runs on visible windows
i = [window_list count]; if (flag)
while (i-- > 0) {
window_list = GSOrderedWindows();
}
else
{
window_list = [self windows];
}
for (i = 0, c = [window_list count]; i < c; i++)
{ {
NSWindow *window = [window_list objectAtIndex: i]; NSWindow *window = [window_list objectAtIndex: i];
@ -3251,14 +3262,24 @@ image.</p><p>See Also: -applicationIconImage</p>
} }
/** /**
* OS X scripting method to return windows in front-to-back on-screen order. * OS X scripting method to return windows in front-to-back on-screen order
* <em>The GNUstep implementation returns all the windows in an arbitrary * for scriptable windows.
* order.</em> * <em>The GNUstep implementation returns all the windows excluding NSPanels.
* some backends may return an array in an unspecified order.</em>
*/ */
- (NSArray *) orderedWindows - (NSArray *) orderedWindows
{ {
// FIXME NSArray *arr = GSOrderedWindows();
return [self windows]; NSMutableArray *ret = [[NSArray alloc] initWithCapacity:[arr count]];
NSEnumerator *iter = [arr objectEnumerator];
id win;
while ((win = [iter nextObject]))
{
if (![win isKindOfClass:[NSPanel class]])
[ret addObject:win];
}
return AUTORELEASE(ret);
} }
/* /*
@ -3478,17 +3499,17 @@ image.</p><p>See Also: -applicationIconImage</p>
- (void) _windowWillClose: (NSNotification*) notification - (void) _windowWillClose: (NSNotification*) notification
{ {
NSWindow *win = [notification object]; NSWindow *win = [notification object];
NSArray *windows_list = [self windows]; NSArray *windows_list = GSOrderedWindows();
unsigned count = [windows_list count]; unsigned count = [windows_list count];
unsigned i; unsigned i;
NSMutableArray *list = [NSMutableArray arrayWithCapacity: count]; NSMutableArray *list = [NSMutableArray arrayWithCapacity: count];
BOOL wasKey = [win isKeyWindow]; BOOL wasKey = [win isKeyWindow];
BOOL wasMain = [win isMainWindow]; BOOL wasMain = [win isMainWindow];
NSEnumerator *iter = [windows_list objectEnumerator];
NSWindow *tmp;
for (i = 0; i < count; i++) while ((tmp = [iter nextObject]))
{ {
NSWindow *tmp = [windows_list objectAtIndex: i];
if ([tmp canBecomeMainWindow] == YES && [tmp isVisible] == YES) if ([tmp canBecomeMainWindow] == YES && [tmp isVisible] == YES)
{ {
[list addObject: tmp]; [list addObject: tmp];

View file

@ -4613,23 +4613,37 @@ BOOL GSViewAcceptsDrag(NSView *v, id<NSDraggingInfo> dragInfo)
void NSCountWindows(int *count) void NSCountWindows(int *count)
{ {
*count = (int)NSCountMapTable(windowmaps); *count = (int)[[GSCurrentServer() windowlist] count];
} }
void NSWindowList(int size, int list[]) void NSWindowList(int size, int list[])
{ {
NSMapEnumerator me = NSEnumerateMapTable(windowmaps); NSArray *windowList = [GSCurrentServer() windowlist];
void *key; unsigned i, c;
id win; for (i = 0, c = [windowList count]; i < size && i < c; i++)
int i = 0;
while (i < size && NSNextMapEnumeratorPair(&me, &key, (void*)&win))
{ {
list[i++] = (intptr_t)key; list[i] = [[windowList objectAtIndex:i] intValue];
} }
/* FIXME - the list produced should be in window stacking order */
} }
NSArray *GSOrderedWindows(void)
{
NSArray *window_list = [GSCurrentServer() windowlist];
NSMutableArray *ret = [NSMutableArray array];
int i, c;
for (i = 0, c = [window_list count]; i < c; i++)
{
int windowNumber = [[window_list objectAtIndex:i] intValue];
NSWindow *win = GSWindowWithNumber(windowNumber);
[ret addObject:win];
}
return ret;
}
NSArray* GSAllWindows(void) NSArray* GSAllWindows(void)
{ {
if (windowmaps) if (windowmaps)