mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-22 16:10:48 +00:00
Change to avoid notifications for hide/unhide, activate/deactivate.
Keep lists of deactivated/hidden windows in application. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@5251 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
ae30b120ff
commit
f5ab35ff5d
4 changed files with 101 additions and 109 deletions
|
@ -76,6 +76,9 @@ extern NSString *NSEventTrackingRunLoopMode;
|
|||
BOOL unhide_on_activation;
|
||||
BOOL windows_need_update;
|
||||
NSImage *app_icon;
|
||||
NSMutableArray *_hidden;
|
||||
NSMutableArray *_inactive;
|
||||
NSWindow *_hidden_key;
|
||||
|
||||
BOOL inTrackingLoop;
|
||||
|
||||
|
|
|
@ -136,8 +136,6 @@ extern NSSize NSTokenSize;
|
|||
unsigned menu_exclude:1;
|
||||
unsigned hides_on_deactivate:1;
|
||||
unsigned accepts_mouse_moved:1;
|
||||
unsigned is_closed:1;
|
||||
unsigned is_deactivated:1;
|
||||
} _f;
|
||||
|
||||
/* Reserved for back-end use */
|
||||
|
|
|
@ -308,6 +308,8 @@ static NSCell* tileCell = nil;
|
|||
|
||||
NSDebugLog(@"Begin of NSApplication -init\n");
|
||||
|
||||
_hidden = [NSMutableArray new];
|
||||
_inactive = [NSMutableArray new];
|
||||
[self _appIconInit];
|
||||
unhide_on_activation = YES;
|
||||
app_is_hidden = YES;
|
||||
|
@ -416,6 +418,8 @@ static NSCell* tileCell = nil;
|
|||
/* Let ourselves know we are within dealloc */
|
||||
gnustep_gui_app_is_in_dealloc = YES;
|
||||
|
||||
RELEASE(_hidden);
|
||||
RELEASE(_inactive);
|
||||
RELEASE(listener);
|
||||
RELEASE(null_event);
|
||||
RELEASE(current_event);
|
||||
|
@ -439,9 +443,11 @@ static NSCell* tileCell = nil;
|
|||
{
|
||||
if (app_is_active == NO)
|
||||
{
|
||||
NSGraphicsContext *context = GSCurrentContext();
|
||||
NSWindow *kw = [self keyWindow];
|
||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||
NSGraphicsContext *context = GSCurrentContext();
|
||||
NSWindow *kw = [self keyWindow];
|
||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||
unsigned count = [_inactive count];
|
||||
unsigned i;
|
||||
|
||||
/*
|
||||
* Menus should observe this notification in order to make themselves
|
||||
|
@ -450,23 +456,32 @@ static NSCell* tileCell = nil;
|
|||
[nc postNotificationName: NSApplicationWillBecomeActiveNotification
|
||||
object: self];
|
||||
|
||||
NSDebugLog(@"activateIgnoringOtherApps start.");
|
||||
app_is_active = YES;
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
[[_inactive objectAtIndex: i] orderFrontRegardless];
|
||||
}
|
||||
[_inactive removeAllObjects];
|
||||
|
||||
[main_menu update];
|
||||
[main_menu display];
|
||||
|
||||
if (unhide_on_activation)
|
||||
[self unhide: nil];
|
||||
{
|
||||
[self unhide: nil];
|
||||
}
|
||||
|
||||
if (kw == nil || [kw isVisible] == NO)
|
||||
{
|
||||
kw = app_icon_window;
|
||||
[kw orderFrontRegardless];
|
||||
}
|
||||
NSDebugLog(@"activateIgnoringOtherApps start.");
|
||||
[context flush];
|
||||
|
||||
DPSsetinputfocus(context, [kw windowNumber]);
|
||||
NSDebugLog(@"activateIgnoringOtherApps end.");
|
||||
|
||||
[main_menu update];
|
||||
[main_menu display];
|
||||
|
||||
[nc postNotificationName: NSApplicationDidBecomeActiveNotification
|
||||
object: self];
|
||||
}
|
||||
|
@ -476,15 +491,34 @@ static NSCell* tileCell = nil;
|
|||
{
|
||||
if (app_is_active == YES)
|
||||
{
|
||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||
NSArray *windows_list = [self windows];
|
||||
unsigned count = [windows_list count];
|
||||
unsigned i;
|
||||
|
||||
/*
|
||||
* Menus should observe this notification in order to make themselves
|
||||
* invisible when the application is not active.
|
||||
*/
|
||||
[nc postNotificationName: NSApplicationWillResignActiveNotification
|
||||
object: self];
|
||||
|
||||
[[self context] flush];
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
NSWindow *win = [windows_list objectAtIndex: i];
|
||||
|
||||
if ([win isVisible] == NO)
|
||||
{
|
||||
continue; /* Already invisible */
|
||||
}
|
||||
if (win == app_icon_window)
|
||||
{
|
||||
continue; /* can't hide the app icon. */
|
||||
}
|
||||
if ([win hidesOnDeactivate] == YES)
|
||||
{
|
||||
[_inactive addObject: win];
|
||||
[win orderOut: self];
|
||||
}
|
||||
}
|
||||
|
||||
app_is_active = NO;
|
||||
|
||||
[nc postNotificationName: NSApplicationDidResignActiveNotification
|
||||
|
@ -1026,29 +1060,36 @@ NSAssert([event retainCount] > 0, NSInternalInconsistencyException);
|
|||
{
|
||||
if (app_is_hidden == NO)
|
||||
{
|
||||
NSNotificationCenter *nc;
|
||||
NSArray *windowArray;
|
||||
unsigned count;
|
||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||
NSArray *windows_list = [self windows];
|
||||
unsigned count = [windows_list count];
|
||||
unsigned i;
|
||||
|
||||
nc = [NSNotificationCenter defaultCenter];
|
||||
[nc postNotificationName: NSApplicationWillHideNotification
|
||||
object: self];
|
||||
|
||||
windowArray = [self windows];
|
||||
count = [windowArray count];
|
||||
_hidden_key = [self keyWindow];
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
id win = [windowArray objectAtIndex: i];
|
||||
NSWindow *win = [windows_list objectAtIndex: i];
|
||||
|
||||
if ([win isKindOfClass: [NSWindow class]]
|
||||
&& ![win isKindOfClass: [NSMenuWindow class]]
|
||||
&& ![win isKindOfClass: [NSIconWindow class]])
|
||||
if ([win isVisible] == NO)
|
||||
{
|
||||
[win orderOut: self];
|
||||
continue; /* Already invisible */
|
||||
}
|
||||
if (win == app_icon_window)
|
||||
{
|
||||
continue; /* can't hide the app icon. */
|
||||
}
|
||||
if (app_is_active == YES && [win hidesOnDeactivate] == YES)
|
||||
{
|
||||
continue; /* Will be hidden by deactivation */
|
||||
}
|
||||
[_hidden addObject: win];
|
||||
[win orderOut: self];
|
||||
}
|
||||
app_is_hidden = YES;
|
||||
|
||||
/*
|
||||
* On hiding we also deactivate the application which will make the menus
|
||||
* go away too.
|
||||
|
@ -1056,7 +1097,6 @@ NSAssert([event retainCount] > 0, NSInternalInconsistencyException);
|
|||
[self deactivate];
|
||||
unhide_on_activation = YES;
|
||||
|
||||
|
||||
[nc postNotificationName: NSApplicationDidHideNotification
|
||||
object: self];
|
||||
}
|
||||
|
@ -1072,6 +1112,7 @@ NSAssert([event retainCount] > 0, NSInternalInconsistencyException);
|
|||
if (app_is_hidden)
|
||||
{
|
||||
[self unhideWithoutActivation];
|
||||
unhide_on_activation = NO;
|
||||
if (app_is_active == NO)
|
||||
{
|
||||
/*
|
||||
|
@ -1079,7 +1120,6 @@ NSAssert([event retainCount] > 0, NSInternalInconsistencyException);
|
|||
*/
|
||||
[self activateIgnoringOtherApps: YES];
|
||||
}
|
||||
unhide_on_activation = NO;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1087,38 +1127,27 @@ NSAssert([event retainCount] > 0, NSInternalInconsistencyException);
|
|||
{
|
||||
if (app_is_hidden == YES)
|
||||
{
|
||||
NSNotificationCenter *nc;
|
||||
NSWindow *key;
|
||||
NSArray *windowArray;
|
||||
unsigned count;
|
||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||
unsigned count = [_hidden count];
|
||||
unsigned i;
|
||||
|
||||
nc = [NSNotificationCenter defaultCenter];
|
||||
[nc postNotificationName: NSApplicationWillUnhideNotification
|
||||
object: self];
|
||||
|
||||
key = [self keyWindow];
|
||||
windowArray = [self windows];
|
||||
count = [windowArray count];
|
||||
app_is_hidden = NO;
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
id win = [windowArray objectAtIndex: i];
|
||||
|
||||
if (win != key && [win isKindOfClass: [NSWindow class]]
|
||||
&& ![win isKindOfClass: [NSMenuWindow class]]
|
||||
&& ![win isKindOfClass: [NSIconWindow class]])
|
||||
{
|
||||
[win orderFrontRegardless];
|
||||
}
|
||||
[[_hidden objectAtIndex: i] orderFrontRegardless];
|
||||
}
|
||||
[_hidden removeAllObjects];
|
||||
if ([[self windows] containsObject: _hidden_key])
|
||||
{
|
||||
[_hidden_key makeKeyAndOrderFront: self];
|
||||
_hidden_key = nil;
|
||||
}
|
||||
app_is_hidden = NO;
|
||||
|
||||
[nc postNotificationName: NSApplicationDidUnhideNotification
|
||||
object: self];
|
||||
|
||||
if ([self keyWindow] != key)
|
||||
[key orderFront: self];
|
||||
[[self keyWindow] makeKeyAndOrderFront: self];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1152,35 +1181,36 @@ NSAssert([event retainCount] > 0, NSInternalInconsistencyException);
|
|||
*/
|
||||
- (NSWindow*) keyWindow
|
||||
{
|
||||
NSArray *window_list = [self windows];
|
||||
int i, j;
|
||||
id w;
|
||||
NSArray *window_list = [self windows];
|
||||
unsigned c = [window_list count];
|
||||
unsigned i;
|
||||
|
||||
j = [window_list count];
|
||||
for (i = 0; i < j; ++i)
|
||||
for (i = 0; i < c; ++i)
|
||||
{
|
||||
w = [window_list objectAtIndex: i];
|
||||
NSWindow *w = [window_list objectAtIndex: i];
|
||||
if ([w isKeyWindow])
|
||||
return w;
|
||||
{
|
||||
return w;
|
||||
}
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSWindow*) mainWindow
|
||||
{
|
||||
NSArray *window_list = [self windows];
|
||||
int i, j;
|
||||
id w;
|
||||
NSArray *window_list = [self windows];
|
||||
unsigned c = [window_list count];
|
||||
unsigned i;
|
||||
|
||||
j = [window_list count];
|
||||
for (i = 0; i < j; ++i)
|
||||
for (i = 0; i < c; ++i)
|
||||
{
|
||||
w = [window_list objectAtIndex: i];
|
||||
if ([w isMainWindow])
|
||||
return w;
|
||||
}
|
||||
NSWindow *w = [window_list objectAtIndex: i];
|
||||
|
||||
if ([w isMainWindow])
|
||||
{
|
||||
return w;
|
||||
}
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
@ -1399,7 +1429,7 @@ NSAssert([event retainCount] > 0, NSInternalInconsistencyException);
|
|||
/*
|
||||
* Now we insert a menu item for the window in the correct order.
|
||||
* Make special allowance for menu entries to 'arrangeInFront: '
|
||||
* 'performMiniaturize: ' and 'preformClose: '. If these exist the
|
||||
* 'performMiniaturize: ' and 'performClose: '. If these exist the
|
||||
* window entries should stay after the first one and before the
|
||||
* other two.
|
||||
*/
|
||||
|
|
|
@ -192,31 +192,6 @@ static NSMapTable* windowmaps = NULL;
|
|||
return 8;
|
||||
}
|
||||
|
||||
- (void) _appNotification: (NSNotification*)aNotification
|
||||
{
|
||||
NSString *name = [aNotification name];
|
||||
|
||||
if ([name isEqualToString: NSApplicationWillBecomeActiveNotification])
|
||||
{
|
||||
if (_f.is_deactivated == YES && _f.is_closed == NO)
|
||||
{
|
||||
[self orderFrontRegardless];
|
||||
}
|
||||
}
|
||||
else if ([name isEqualToString: NSApplicationWillResignActiveNotification])
|
||||
{
|
||||
if (_f.hides_on_deactivate == YES && _f.visible == YES)
|
||||
{
|
||||
_f.is_deactivated = YES;
|
||||
[self orderOut: self];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"Unexpected notification - %@", aNotification);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Instance methods
|
||||
*/
|
||||
|
@ -293,7 +268,6 @@ static NSMapTable* windowmaps = NULL;
|
|||
screen: (NSScreen*)aScreen
|
||||
{
|
||||
NSGraphicsContext *context = GSCurrentContext();
|
||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||
NSRect r = [[NSScreen mainScreen] frame];
|
||||
NSRect cframe;
|
||||
|
||||
|
@ -355,15 +329,6 @@ static NSMapTable* windowmaps = NULL;
|
|||
filename: isDoc];
|
||||
}
|
||||
|
||||
[nc addObserver: self
|
||||
selector: @selector(_appNotification:)
|
||||
name: NSApplicationWillBecomeActiveNotification
|
||||
object: NSApp];
|
||||
[nc addObserver: self
|
||||
selector: @selector(_appNotification:)
|
||||
name: NSApplicationWillResignActiveNotification
|
||||
object: NSApp];
|
||||
|
||||
NSDebugLog(@"NSWindow end of init\n");
|
||||
return self;
|
||||
}
|
||||
|
@ -583,7 +548,7 @@ static NSMapTable* windowmaps = NULL;
|
|||
ASSIGN(_windowController, windowController);
|
||||
}
|
||||
|
||||
- (id)windowController
|
||||
- (id) windowController
|
||||
{
|
||||
return _windowController;
|
||||
}
|
||||
|
@ -596,6 +561,7 @@ static NSMapTable* windowmaps = NULL;
|
|||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||
|
||||
_f.is_key = YES;
|
||||
DPSsetinputfocus(GSCurrentContext(), [self windowNumber]);
|
||||
[self resetCursorRects];
|
||||
[nc postNotificationName: NSWindowDidBecomeKeyNotification object: self];
|
||||
}
|
||||
|
@ -702,11 +668,6 @@ static NSMapTable* windowmaps = NULL;
|
|||
- (void) orderWindow: (NSWindowOrderingMode)place relativeTo: (int)otherWin
|
||||
{
|
||||
DPSorderwindow(GSCurrentContext(), place, otherWin, [self windowNumber]);
|
||||
if (place != NSWindowOut)
|
||||
{
|
||||
_f.is_deactivated = NO;
|
||||
_f.is_closed = NO;
|
||||
}
|
||||
}
|
||||
|
||||
- (void) resignKeyWindow
|
||||
|
|
Loading…
Reference in a new issue