@@ -124,6 +124,13 @@ - (void)applicationDidFinishLaunching: (NSNotification *)notification
124124 NSAutoreleasePool *t_pool;
125125 t_pool = [[NSAutoreleasePool alloc ] init ];
126126
127+ // MW-2014-04-23: [[ Bug 12080 ]] Always create a dummy window which should
128+ // always sit at the bottom of our window list so that palettes have something
129+ // to float above.
130+ NSWindow *t_dummy_window;
131+ t_dummy_window = [[NSWindow alloc ] initWithContentRect: NSZeroRect styleMask: NSBorderlessWindowMask backing: NSBackingStoreBuffered defer: YES ];
132+ [t_dummy_window orderFront: nil ];
133+
127134 // Dispatch the startup callback.
128135 int t_error_code;
129136 char *t_error_message;
@@ -224,6 +231,20 @@ - (void)applicationDidUnhide:(NSNotification *)notification
224231
225232- (void )applicationWillBecomeActive : (NSNotification *)notification
226233{
234+ // MW-2014-04-23: [[ Bug 12080 ]] Loop through all our windows and any MCPanels
235+ // get set to not be floating. This is so that they sit behind the windows
236+ // of other applications (like we did before).
237+ for (NSNumber *t_window_id in [[NSWindow windowNumbersWithOptions: 0 ] reverseObjectEnumerator ])
238+ {
239+ NSWindow *t_window;
240+ t_window = [NSApp windowWithWindowNumber: [t_window_id longValue ]];
241+ if (![t_window isKindOfClass: [com_runrev_livecode_MCPanel class ]])
242+ {
243+ continue ;
244+ }
245+
246+ [t_window setFloatingPanel: YES ];
247+ }
227248}
228249
229250- (void )applicationDidBecomeActive : (NSNotification *)notification
@@ -233,11 +254,28 @@ - (void)applicationDidBecomeActive:(NSNotification *)notification
233254
234255- (void )applicationWillResignActive : (NSNotification *)notification
235256{
236- MCPlatformCallbackSendApplicationSuspend ();
257+ // MW-2014-04-23: [[ Bug 12080 ]] Loop through all our windows and move any
258+ // MCPanels to be above the top-most non-panel.
259+ NSInteger t_above_window_id;
260+ for (NSNumber *t_window_id in [[NSWindow windowNumbersWithOptions: 0 ] reverseObjectEnumerator ])
261+ {
262+ NSWindow *t_window;
263+ t_window = [NSApp windowWithWindowNumber: [t_window_id longValue ]];
264+ if (![t_window isKindOfClass: [com_runrev_livecode_MCPanel class ]])
265+ {
266+ t_above_window_id = [t_window_id longValue ];
267+ continue ;
268+ }
269+
270+ [t_window setFloatingPanel: NO ];
271+ [t_window orderWindow: NSWindowAbove relativeTo: t_above_window_id];
272+ t_above_window_id = [t_window_id longValue ];
273+ }
237274}
238275
239276- (void )applicationDidResignActive : (NSNotification *)notification
240277{
278+ MCPlatformCallbackSendApplicationSuspend ();
241279}
242280
243281// ////////
0 commit comments