From 091e43b9fee1ad782813408173ec78cc6a71430f Mon Sep 17 00:00:00 2001 From: richard Date: Wed, 22 Dec 1999 09:25:51 +0000 Subject: [PATCH] window level fixes in modal sessions git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@5604 72102866-910b-0410-8b05-ffd578937521 --- Headers/gnustep/gui/NSWindow.h | 11 ++++-- Source/NSApplication.m | 62 +++++++++++++++++++++------------- 2 files changed, 46 insertions(+), 27 deletions(-) diff --git a/Headers/gnustep/gui/NSWindow.h b/Headers/gnustep/gui/NSWindow.h index 281db1f70..1c184639b 100644 --- a/Headers/gnustep/gui/NSWindow.h +++ b/Headers/gnustep/gui/NSWindow.h @@ -61,9 +61,14 @@ enum { NSNormalWindowLevel = 0, NSFloatingWindowLevel = 3, - NSDockWindowLevel = 5, - NSSubmenuWindowLevel = 10, - NSMainMenuWindowLevel = 20 + NSSubmenuWindowLevel = 3, + NSTornOffMenuWindowLevel = 3, + NSDockWindowLevel = 5, /* Deprecated - use NSStatusWindowLevel */ + NSMainMenuWindowLevel = 20, + NSStatusWindowLevel = 21, + NSModalPanelWindowLevel = 100, + NSPopUpMenuWindowLevel = 101, + NSScreenSaverWindowLevel = 1000 }; enum { diff --git a/Source/NSApplication.m b/Source/NSApplication.m index 4d1f391a2..a98f19cbe 100644 --- a/Source/NSApplication.m +++ b/Source/NSApplication.m @@ -70,9 +70,10 @@ * Types */ struct _NSModalSession { - int runState; - NSWindow *window; - NSModalSession previous; + int runState; + int entryLevel; + NSWindow *window; + NSModalSession previous; }; @interface NSIconWindow : NSWindow @@ -885,16 +886,41 @@ static NSCell* tileCell = nil; theSession = (NSModalSession)NSZoneMalloc(NSDefaultMallocZone(), sizeof(struct _NSModalSession)); theSession->runState = NSRunContinuesResponse; + theSession->entryLevel = [theWindow level]; theSession->window = theWindow; theSession->previous = session; session = theSession; + /* + * The NSWindow documentation says runModalForWindow centers panels. + * Here would seem the best place to do it. + */ + if ([theWindow isKindOfClass: [NSPanel class]]) + { + [theWindow center]; +// FIXME need support for NSModalPanelWindowLevel in Window Maker +// [theWindow setLevel: NSModalPanelWindowLevel]; + } + [theWindow orderFrontRegardless]; + if ([self isActive] == YES) + { + if ([theWindow canBecomeKeyWindow] == YES) + { + [theWindow makeKeyWindow]; + } + else if ([theWindow canBecomeMainWindow] == YES) + { + [theWindow makeMainWindow]; + } + } + return theSession; } - (void) endModalSession: (NSModalSession)theSession { - NSModalSession tmp = session; + NSModalSession tmp = session; + NSArray *windows = [self windows]; if (theSession == 0) { @@ -915,9 +941,17 @@ static NSCell* tileCell = nil; { tmp = session; session = tmp->previous; + if ([windows indexOfObjectIdenticalTo: tmp->window] != NSNotFound) + { + [tmp->window setLevel: tmp->entryLevel]; + } NSZoneFree(NSDefaultMallocZone(), tmp); } session = session->previous; + if ([windows indexOfObjectIdenticalTo: theSession->window] != NSNotFound) + { + [theSession->window setLevel: theSession->entryLevel]; + } NSZoneFree(NSDefaultMallocZone(), theSession); } @@ -926,26 +960,6 @@ static NSCell* tileCell = nil; NSModalSession theSession = 0; int code = NSRunContinuesResponse; - /* - * The NSWindow documentation says runModalForWindow centers panels. - */ - if ([theWindow isKindOfClass: [NSPanel class]]) - { - [theWindow center]; - } - [theWindow orderFrontRegardless]; - if ([self isActive] == YES) - { - if ([theWindow canBecomeKeyWindow] == YES) - { - [theWindow makeKeyWindow]; - } - else if ([theWindow canBecomeMainWindow] == YES) - { - [theWindow makeMainWindow]; - } - } - NS_DURING { theSession = [self beginModalSessionForWindow: theWindow];