Index: Source/NSApplication.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/gui/Source/NSApplication.m,v
retrieving revision 1.251
diff -u -r1.251 NSApplication.m
--- Source/NSApplication.m	21 Sep 2003 02:27:50 -0000	1.251
+++ Source/NSApplication.m	15 Oct 2003 17:17:59 -0000
@@ -931,7 +931,7 @@
 	  [[_inactive objectAtIndex: i] orderFrontRegardless];
 	}
       [_inactive removeAllObjects];
-      if (_hidden_key != nil
+      if ([self keyWindow] == nil && _hidden_key != nil
 	&& [[self windows] indexOfObjectIdenticalTo: _hidden_key] != NSNotFound)
 	{
 	  [_hidden_key makeKeyWindow];
@@ -949,8 +949,13 @@
 	}
       else if ([self mainWindow] != nil)
 	{
-	  [[self mainWindow] orderFront: self];
+	  [[self mainWindow] makeKeyAndOrderFront: self];
 	}
+      else
+        {
+	  //FIXME: why doesn't this work?
+          [[[self mainMenu] window] makeKeyAndOrderFront:self];
+        }
 
       [nc postNotificationName: NSApplicationDidBecomeActiveNotification
 			object: self];
@@ -975,6 +980,10 @@
 	  _hidden_key = [self keyWindow];
 	  [_hidden_key resignKeyWindow];
 	}
+      // FIXME: main window is not saved for when the app is activated again.
+      // 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++)
 	{
 	  NSModalSession theSession;
