Index: Source/NSApplication.m =================================================================== --- Source/NSApplication.m (revision 32715) +++ Source/NSApplication.m (working copy) @@ -1376,93 +1376,108 @@ */ - (void) deactivate { +#ifdef __MINGW32__ + [self miniaturizeAll: self]; +#else if (_app_is_active == YES) { - NSArray *windows_list; - NSDictionary *info; - NSWindow *win; - NSEnumerator *iter; + if (![[NSUserDefaults standardUserDefaults] + boolForKey: @"GSSuppressAppIcon"]) + { + NSArray *windows_list; + NSDictionary *info; + NSWindow *win; + NSEnumerator *iter; - [nc postNotificationName: NSApplicationWillResignActiveNotification - object: self]; - - _app_is_active = NO; - - if ([self keyWindow] != nil) - { - _hidden_key = [self keyWindow]; - [_hidden_key resignKeyWindow]; - } - // The main window is saved for when the app is activated again. - // This is necessary for menu in window. - if ([self mainWindow] != nil) - { - _hidden_main = [self mainWindow]; - [_hidden_main resignMainWindow]; - } - - windows_list = GSOrderedWindows(); - iter = [windows_list reverseObjectEnumerator]; - - while ((win = [iter nextObject])) - { - NSModalSession theSession; - - if ([win isVisible] == NO) - { - continue; /* Already invisible */ - } - if ([win canHide] == NO) - { - continue; /* Can't be hidden */ - } - if (win == _app_icon_window) - { - continue; /* can't hide the app icon. */ - } - /* Don't order out modal windows */ - theSession = _session; - while (theSession != 0) - { - if (win == theSession->window) - break; - theSession = theSession->previous; - } - if (theSession) - continue; - - if ([win hidesOnDeactivate] == YES) - { - [_inactive addObject: win]; - [win orderOut: self]; - } - } - - if (YES == [[NSUserDefaults standardUserDefaults] - boolForKey: @"GSSuppressAppIcon"]) - { + [nc postNotificationName: NSApplicationWillResignActiveNotification + object: self]; + + _app_is_active = NO; + + if ([self keyWindow] != nil) + { + _hidden_key = [self keyWindow]; + [_hidden_key resignKeyWindow]; + } + // The main window is saved for when the app is activated again. + // This is necessary for menu in window. + if ([self mainWindow] != nil) + { + _hidden_main = [self mainWindow]; + [_hidden_main resignMainWindow]; + } + + windows_list = GSOrderedWindows(); + iter = [windows_list reverseObjectEnumerator]; + + while ((win = [iter nextObject])) + { + NSModalSession theSession; + + if ([win isVisible] == NO) + { + continue; /* Already invisible */ + } + if ([win canHide] == NO) + { + continue; /* Can't be hidden */ + } + if (win == _app_icon_window) + { + continue; /* can't hide the app icon. */ + } + /* Don't order out modal windows */ + theSession = _session; + while (theSession != 0) + { + if (win == theSession->window) + break; + theSession = theSession->previous; + } + if (theSession) + continue; + + if ([win hidesOnDeactivate] == YES) + { + [_inactive addObject: win]; + [win orderOut: self]; + } + } + + if (YES == [[NSUserDefaults standardUserDefaults] + boolForKey: @"GSSuppressAppIcon"]) + { #if MINI_ICON - NSRect f = [[[self mainMenu] window] frame]; - NSPoint p = f.origin; - - p.y += f.size.height; - [_app_icon_window setFrameTopLeftPoint: p]; - [_app_icon_window orderFrontRegardless]; - [_app_icon_window miniaturize: self]; + NSRect f = [[[self mainMenu] window] frame]; + NSPoint p = f.origin; + + p.y += f.size.height; + [_app_icon_window setFrameTopLeftPoint: p]; + [_app_icon_window orderFrontRegardless]; + [_app_icon_window miniaturize: self]; #else - [_app_icon_window orderFrontRegardless]; + [_app_icon_window orderFrontRegardless]; #endif + } + + info = [self _notificationUserInfo]; + [nc postNotificationName: NSApplicationDidResignActiveNotification + object: self + userInfo: info]; + [[[NSWorkspace sharedWorkspace] notificationCenter] + postNotificationName: NSApplicationDidResignActiveNotification + object: [NSWorkspace sharedWorkspace] + userInfo: info]; } - - info = [self _notificationUserInfo]; - [nc postNotificationName: NSApplicationDidResignActiveNotification - object: self - userInfo: info]; - [[[NSWorkspace sharedWorkspace] notificationCenter] - postNotificationName: NSApplicationDidResignActiveNotification - object: [NSWorkspace sharedWorkspace] - userInfo: info]; + else + { + /*Minimize all windows if there isn't an AppIcon. This isn't the + most elegant solution, but avoids to loss the app if it is + deactivated. */ + [self miniaturizeAll: self]; + } } +#endif } /** @@ -2429,89 +2444,100 @@ #else if (_app_is_hidden == NO) { - NSArray *windows_list; - NSDictionary *info; - NSWindow *win; - NSEnumerator *iter; + if (![[NSUserDefaults standardUserDefaults] + boolForKey: @"GSSuppressAppIcon"]) + { + NSArray *windows_list; + NSDictionary *info; + NSWindow *win; + NSEnumerator *iter; - [nc postNotificationName: NSApplicationWillHideNotification - object: self]; + [nc postNotificationName: NSApplicationWillHideNotification + object: self]; - if ([self keyWindow] != nil) - { - _hidden_key = [self keyWindow]; - [_hidden_key resignKeyWindow]; - } - - // The main window is saved for when the app is activated again. - // This is necessary for menu in window. - if ([self mainWindow] != nil) - { - _hidden_main = [self mainWindow]; - [_hidden_main resignMainWindow]; - } - - windows_list = GSOrderedWindows(); - iter = [windows_list reverseObjectEnumerator]; - - while ((win = [iter nextObject])) - { - if ([win isVisible] == NO && ![win isMiniaturized]) - { - continue; /* Already invisible */ - } - if ([win canHide] == NO) - { - continue; /* Not hideable */ - } - 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; - - if (YES == [[NSUserDefaults standardUserDefaults] - boolForKey: @"GSSuppressAppIcon"]) - { + if ([self keyWindow] != nil) + { + _hidden_key = [self keyWindow]; + [_hidden_key resignKeyWindow]; + } + + // The main window is saved for when the app is activated again. + // This is necessary for menu in window. + if ([self mainWindow] != nil) + { + _hidden_main = [self mainWindow]; + [_hidden_main resignMainWindow]; + } + + windows_list = GSOrderedWindows(); + iter = [windows_list reverseObjectEnumerator]; + + while ((win = [iter nextObject])) + { + if ([win isVisible] == NO && ![win isMiniaturized]) + { + continue; /* Already invisible */ + } + if ([win canHide] == NO) + { + continue; /* Not hideable */ + } + 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; + + if (YES == [[NSUserDefaults standardUserDefaults] + boolForKey: @"GSSuppressAppIcon"]) + { #if MINI_ICON - NSRect f = [[[self mainMenu] window] frame]; - NSPoint p = f.origin; - - p.y += f.size.height; - [_app_icon_window setFrameTopLeftPoint: p]; - [_app_icon_window orderFrontRegardless]; - [_app_icon_window miniaturize: self]; + NSRect f = [[[self mainMenu] window] frame]; + NSPoint p = f.origin; + + p.y += f.size.height; + [_app_icon_window setFrameTopLeftPoint: p]; + [_app_icon_window orderFrontRegardless]; + [_app_icon_window miniaturize: self]; #else - [_app_icon_window orderFrontRegardless]; + [_app_icon_window orderFrontRegardless]; #endif + } + else + { + [[_app_icon_window contentView] setNeedsDisplay: YES]; + } + + /* + * On hiding we also deactivate the application which will make the menus + * go away too. + */ + [self deactivate]; + _unhide_on_activation = YES; + + info = [self _notificationUserInfo]; + [nc postNotificationName: NSApplicationDidHideNotification + object: self + userInfo: info]; + [[[NSWorkspace sharedWorkspace] notificationCenter] + postNotificationName: NSApplicationDidHideNotification + object: [NSWorkspace sharedWorkspace] + userInfo: info]; } else { - [[_app_icon_window contentView] setNeedsDisplay: YES]; + /*Minimize all windows if there isn't an AppIcon. This isn't the + most elegant solution, but avoids to loss the app if the user + hide it. */ + [self miniaturizeAll: sender]; } - - /* - * On hiding we also deactivate the application which will make the menus - * go away too. - */ - [self deactivate]; - _unhide_on_activation = YES; - - info = [self _notificationUserInfo]; - [nc postNotificationName: NSApplicationDidHideNotification - object: self - userInfo: info]; - [[[NSWorkspace sharedWorkspace] notificationCenter] - postNotificationName: NSApplicationDidHideNotification - object: [NSWorkspace sharedWorkspace] - userInfo: info]; } #endif }