mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 07:00:46 +00:00
* 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:
parent
1658cb1dee
commit
a197607128
5 changed files with 122 additions and 56 deletions
15
ChangeLog
15
ChangeLog
|
@ -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>
|
||||
|
||||
* Source/NSTableView.m: If the tableview is smaller than
|
||||
|
|
|
@ -215,6 +215,7 @@ GSWViewIsFlipped(NSGraphicsContext *ctxt)
|
|||
@class NSArray;
|
||||
@class NSWindow;
|
||||
|
||||
APPKIT_EXPORT NSArray* GSOrderedWindows(void);
|
||||
APPKIT_EXPORT NSArray* GSAllWindows(void);
|
||||
APPKIT_EXPORT NSWindow* GSWindowWithNumber(int num);
|
||||
#endif
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include <Foundation/NSThread.h>
|
||||
#include <Foundation/NSGeometry.h>
|
||||
|
||||
#include "AppKit/NSApplication.h"
|
||||
#include "AppKit/NSEvent.h"
|
||||
#include "AppKit/NSImage.h"
|
||||
#include "AppKit/NSWindow.h"
|
||||
|
@ -664,11 +665,25 @@ GSCurrentServer(void)
|
|||
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
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
return nil;
|
||||
NSMutableArray *list = [NSMutableArray arrayWithArray:[NSApp windows]];
|
||||
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 */
|
||||
|
|
|
@ -522,12 +522,12 @@ static NSSize scaledIconSizeForSize(NSSize imageSize)
|
|||
*/
|
||||
if ([NSApp isHidden] == NO)
|
||||
{
|
||||
int i;
|
||||
NSArray *windows = RETAIN([NSApp windows]);
|
||||
|
||||
for (i = 0; i < [windows count]; i++)
|
||||
NSArray *windows = RETAIN(GSOrderedWindows());
|
||||
NSWindow *aWin;
|
||||
NSEnumerator *iter = [windows reverseObjectEnumerator];
|
||||
|
||||
while ((aWin = [iter nextObject]))
|
||||
{
|
||||
NSWindow *aWin = [windows objectAtIndex:i];
|
||||
|
||||
if ([aWin isVisible] == YES && [aWin isMiniaturized] == NO
|
||||
&& aWin != [NSApp keyWindow] && aWin != [NSApp mainWindow]
|
||||
|
@ -561,8 +561,10 @@ static NSSize scaledIconSizeForSize(NSSize imageSize)
|
|||
|
||||
RELEASE(windows);
|
||||
}
|
||||
|
||||
[NSApp unhide: self];
|
||||
else
|
||||
{
|
||||
[NSApp unhide: self];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1167,6 +1169,12 @@ static NSSize scaledIconSizeForSize(NSSize imageSize)
|
|||
[[_inactive objectAtIndex: i] orderFrontRegardless];
|
||||
}
|
||||
[_inactive removeAllObjects];
|
||||
|
||||
if (_unhide_on_activation)
|
||||
{
|
||||
[self unhide: nil];
|
||||
}
|
||||
|
||||
if ([self keyWindow] == nil && _hidden_key != nil
|
||||
&& [[self windows] indexOfObjectIdenticalTo: _hidden_key] != NSNotFound)
|
||||
{
|
||||
|
@ -1174,11 +1182,6 @@ static NSSize scaledIconSizeForSize(NSSize imageSize)
|
|||
_hidden_key = nil;
|
||||
}
|
||||
|
||||
if (_unhide_on_activation)
|
||||
{
|
||||
[self unhide: nil];
|
||||
}
|
||||
|
||||
if ([self keyWindow] != nil)
|
||||
{
|
||||
[[self keyWindow] orderFront: self];
|
||||
|
@ -1216,13 +1219,14 @@ static NSSize scaledIconSizeForSize(NSSize imageSize)
|
|||
{
|
||||
if (_app_is_active == YES)
|
||||
{
|
||||
NSArray *windows_list = [self windows];
|
||||
unsigned count = [windows_list count];
|
||||
unsigned i;
|
||||
NSArray *windows_list;
|
||||
NSDictionary *info;
|
||||
NSWindow *win;
|
||||
NSEnumerator *iter;
|
||||
|
||||
[nc postNotificationName: NSApplicationWillResignActiveNotification
|
||||
object: self];
|
||||
|
||||
|
||||
_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
|
||||
// is a problem at all. May be annoying in the case of workspace switch.
|
||||
[[self mainWindow] resignMainWindow];
|
||||
for (i = 0; i < count; i++)
|
||||
|
||||
windows_list = GSOrderedWindows();
|
||||
iter = [windows_list reverseObjectEnumerator];
|
||||
|
||||
while ((win = [iter nextObject]))
|
||||
{
|
||||
NSModalSession theSession;
|
||||
NSWindow *win = [windows_list objectAtIndex: i];
|
||||
|
||||
|
||||
if ([win isVisible] == NO)
|
||||
{
|
||||
continue; /* Already invisible */
|
||||
|
@ -2205,10 +2212,10 @@ image.</p><p>See Also: -applicationIconImage</p>
|
|||
{
|
||||
if (_app_is_hidden == NO)
|
||||
{
|
||||
NSArray *windows_list = [self windows];
|
||||
unsigned count = [windows_list count];
|
||||
NSArray *windows_list;
|
||||
NSDictionary *info;
|
||||
unsigned i;
|
||||
NSWindow *win;
|
||||
NSEnumerator *iter;
|
||||
|
||||
[nc postNotificationName: NSApplicationWillHideNotification
|
||||
object: self];
|
||||
|
@ -2218,10 +2225,12 @@ image.</p><p>See Also: -applicationIconImage</p>
|
|||
_hidden_key = [self keyWindow];
|
||||
[_hidden_key resignKeyWindow];
|
||||
}
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
NSWindow *win = [windows_list objectAtIndex: i];
|
||||
|
||||
windows_list = GSOrderedWindows();
|
||||
iter = [windows_list reverseObjectEnumerator];
|
||||
|
||||
while ((win = [iter nextObject]))
|
||||
{
|
||||
if ([win isVisible] == NO)
|
||||
{
|
||||
continue; /* Already invisible */
|
||||
|
@ -2314,12 +2323,6 @@ image.</p><p>See Also: -applicationIconImage</p>
|
|||
[[_hidden objectAtIndex: i] orderFrontRegardless];
|
||||
}
|
||||
[_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];
|
||||
|
||||
info = [self _notificationUserInfo];
|
||||
|
@ -2393,12 +2396,20 @@ image.</p><p>See Also: -applicationIconImage</p>
|
|||
*/
|
||||
- (NSWindow*) makeWindowsPerform: (SEL)aSelector inOrder: (BOOL)flag
|
||||
{
|
||||
NSArray *window_list = [self windows];
|
||||
unsigned i;
|
||||
NSArray *window_list;
|
||||
unsigned i, c;
|
||||
|
||||
// FIXME flag ignored
|
||||
i = [window_list count];
|
||||
while (i-- > 0)
|
||||
// so i suppose when flag is YES it only runs on visible windows
|
||||
if (flag)
|
||||
{
|
||||
window_list = GSOrderedWindows();
|
||||
}
|
||||
else
|
||||
{
|
||||
window_list = [self windows];
|
||||
}
|
||||
|
||||
for (i = 0, c = [window_list count]; i < c; 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.
|
||||
* <em>The GNUstep implementation returns all the windows in an arbitrary
|
||||
* order.</em>
|
||||
* OS X scripting method to return windows in front-to-back on-screen order
|
||||
* for scriptable windows.
|
||||
* <em>The GNUstep implementation returns all the windows excluding NSPanels.
|
||||
* some backends may return an array in an unspecified order.</em>
|
||||
*/
|
||||
- (NSArray *) orderedWindows
|
||||
{
|
||||
// FIXME
|
||||
return [self windows];
|
||||
NSArray *arr = GSOrderedWindows();
|
||||
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
|
||||
{
|
||||
NSWindow *win = [notification object];
|
||||
NSArray *windows_list = [self windows];
|
||||
NSArray *windows_list = GSOrderedWindows();
|
||||
unsigned count = [windows_list count];
|
||||
unsigned i;
|
||||
NSMutableArray *list = [NSMutableArray arrayWithCapacity: count];
|
||||
BOOL wasKey = [win isKeyWindow];
|
||||
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)
|
||||
{
|
||||
[list addObject: tmp];
|
||||
|
|
|
@ -4613,23 +4613,37 @@ BOOL GSViewAcceptsDrag(NSView *v, id<NSDraggingInfo> dragInfo)
|
|||
|
||||
void NSCountWindows(int *count)
|
||||
{
|
||||
*count = (int)NSCountMapTable(windowmaps);
|
||||
*count = (int)[[GSCurrentServer() windowlist] count];
|
||||
}
|
||||
|
||||
void NSWindowList(int size, int list[])
|
||||
{
|
||||
NSMapEnumerator me = NSEnumerateMapTable(windowmaps);
|
||||
void *key;
|
||||
id win;
|
||||
int i = 0;
|
||||
|
||||
while (i < size && NSNextMapEnumeratorPair(&me, &key, (void*)&win))
|
||||
NSArray *windowList = [GSCurrentServer() windowlist];
|
||||
unsigned i, c;
|
||||
for (i = 0, c = [windowList count]; i < size && i < c; i++)
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (windowmaps)
|
||||
|
|
Loading…
Reference in a new issue