diff options
| author | Matthias Melcher <fltk@matthiasm.com> | 2010-02-19 20:21:20 +0000 |
|---|---|---|
| committer | Matthias Melcher <fltk@matthiasm.com> | 2010-02-19 20:21:20 +0000 |
| commit | b416a027cf131d87fb798e246d96745d12786f52 (patch) | |
| tree | f9daeaf6af1d61c09ebe5afb0d9231fd852572d4 /src | |
| parent | 3b7e7947193f510352206830705519fff109b184 (diff) | |
Fixed window levels in OS X Cocoa (STR #2316)
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7102 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
| -rw-r--r-- | src/Fl_cocoa.mm | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index 1fc5f5ce2..6dd795067 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -1301,6 +1301,8 @@ extern "C" { - (void)windowDidMiniaturize:(NSNotification *)notif; - (void)windowWillClose:(NSNotification *)notif; - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication*)sender; +- (void)applicationDidBecomeActive:(NSNotification *)notify; +- (void)applicationWillResignActive:(NSNotification *)notify; @end @implementation FLDelegate @@ -1389,6 +1391,83 @@ extern "C" { fl_unlock_function(); return reply; } +/** + * Cocoa organizes the Z depth of windows on a global priority. FLTK however + * expectes the window manager to organize Z level by application. The trickery + * below will change Z order during activation and deactivation. + */ +- (void)applicationDidBecomeActive:(NSNotification *)notify +{ + Fl_X *x; + FLWindow *top = 0, *topModal = 0, *topNonModal = 0; + for (x = Fl_X::first;x;x = x->next) { + FLWindow *cw = (FLWindow*)x->xid; + Fl_Window *win = x->w; + if (win && cw) { + if (win->modal()) { + [cw setLevel:NSModalPanelWindowLevel]; + if (topModal) + [cw orderWindow:NSWindowBelow relativeTo:[topModal windowNumber]]; + else + topModal = cw; + } else if (win->non_modal()) { + [cw setLevel:NSFloatingWindowLevel]; + if (topNonModal) + [cw orderWindow:NSWindowBelow relativeTo:[topNonModal windowNumber]]; + else + topNonModal = cw; + } else { + if (top) + ; + else + top = cw; + } + } + } +} +- (void)applicationWillResignActive:(NSNotification *)notify +{ + Fl_X *x; + FLWindow *top = 0; + // sort in all regular windows + for (x = Fl_X::first;x;x = x->next) { + FLWindow *cw = (FLWindow*)x->xid; + Fl_Window *win = x->w; + if (win && cw) { + if (win->modal()) { + } else if (win->non_modal()) { + } else { + if (!top) top = cw; + } + } + } + // now sort in all modals + for (x = Fl_X::first;x;x = x->next) { + FLWindow *cw = (FLWindow*)x->xid; + Fl_Window *win = x->w; + if (win && cw) { + if (win->modal()) { + [cw setLevel:NSNormalWindowLevel]; + if (top) [cw orderWindow:NSWindowAbove relativeTo:[top windowNumber]]; + } else if (win->non_modal()) { + } else { + } + } + } + // finally all non-modals + for (x = Fl_X::first;x;x = x->next) { + FLWindow *cw = (FLWindow*)x->xid; + Fl_Window *win = x->w; + if (win && cw) { + if (win->modal()) { + } else if (win->non_modal()) { + [cw setLevel:NSNormalWindowLevel]; + if (top) [cw orderWindow:NSWindowAbove relativeTo:[top windowNumber]]; + } else { + } + } + } +} @end @interface FLApplication : NSApplication |
