summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Melcher <fltk@matthiasm.com>2010-02-19 20:21:20 +0000
committerMatthias Melcher <fltk@matthiasm.com>2010-02-19 20:21:20 +0000
commitb416a027cf131d87fb798e246d96745d12786f52 (patch)
treef9daeaf6af1d61c09ebe5afb0d9231fd852572d4
parent3b7e7947193f510352206830705519fff109b184 (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
-rw-r--r--CHANGES1
-rw-r--r--src/Fl_cocoa.mm79
2 files changed, 80 insertions, 0 deletions
diff --git a/CHANGES b/CHANGES
index cdaeba5ee..59dac48a9 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,6 @@
CHANGES IN FLTK 1.3.0
+ - Fixed window levels in OS X Cocoa (STR #2316)
- Added jpeg support to Fluid image() element
- Added loading jpeg images from memory
- Added binary data type to Fluid
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