From eb5f81a21a1c275d18e88fe61aa3679df34f7a01 Mon Sep 17 00:00:00 2001 From: wlux Date: Sat, 17 Oct 2009 17:09:36 +0000 Subject: [PATCH] When using MS Windows style menus terminate an application by default when its last window is closed. In addition, fix a bug where the application was not terminated when the last window is closed while the application is in the background. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@28834 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 11 ++++++++++- Source/NSApplication.m | 14 ++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 52e965ae7..50587db3d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,13 @@ -2009-10-17 Wolfgang Lux +2009-10-17 Wolfgang Lux + + * Source/NSApplication.m (-_windowWillClose:): When using MS + Windows style menus terminate an application by default when its + last window is closed. + In addition, fix a bug where the application was not terminated + when the last window is closed while the application is in the + background. + +2009-10-17 Wolfgang Lux * Source/NSApplication.m (-finishLaunching): Open a new document by default when a document based application is started and there diff --git a/Source/NSApplication.m b/Source/NSApplication.m index 5bb5f62e6..f4129e536 100644 --- a/Source/NSApplication.m +++ b/Source/NSApplication.m @@ -3903,7 +3903,6 @@ struct _DelegateWrapper - (void) _windowWillClose: (NSNotification*) notification { NSWindow *win = [notification object]; - BOOL wasMain = [win isMainWindow]; if (_app_is_running) { @@ -3928,7 +3927,7 @@ struct _DelegateWrapper /* If there's only one window left, and that's the one being closed, then we ask the delegate if the app is to be terminated. */ - if (wasMain && count == 0) + if (count == 0) { if ([_delegate respondsToSelector: @selector(applicationShouldTerminateAfterLastWindowClosed:)]) @@ -3939,6 +3938,17 @@ struct _DelegateWrapper [self terminate: self]; } } + /* + wlux 2009-10-17: If we use MS Windows style menus, we terminate + the application by default if the last window is closed. + FIXME: I think we should send [self interfaceStyle] here, but + this does not return a meaningful result at present. + */ + else if (NSInterfaceStyleForKey(@"NSMenuInterfaceStyle", nil) == + NSWindows95InterfaceStyle) + { + [self terminate: self]; + } } } }