Mac OS: with OS 10.11, the (green) window maximize button turns the window fullscreen so

it covers the dock and the system menu bar. The default behavior of a subwindow of such
a fullscreen window is to be prevented to cover the menu bar (which makes not much sense 
because this bar is covered by the main window). If the location of the subwindow within
its parent window expected by FLTK would have it cover the menu bar, Mac OS moves
it down. The subwindow therefore does not lie where FLTK wants it.
This patch overrides the adequate method of the NSWindow class to prevent this bad behavior.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10911 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Manolo Gouy 2015-11-16 08:47:18 +00:00
parent c319e9bcc9
commit 535b477e7c

View File

@ -767,6 +767,27 @@ void Fl::remove_timeout(Fl_Timeout_Handler cb, void* data)
Fl_X::i(w)->subRect(r);
}
}
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
/* With Mac OS 10.11 the green window button makes window fullscreen (covers system menu bar and dock).
When there are subwindows, they are by default constrained not to cover the menu bar
(this is arguably a Mac OS bug).
Overriding this method prevents them from having this constraint.
*/
- (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen *)screen
{
if (fl_mac_os_version >= 1011000) {
NSWindow *p = self, *win; // compute win the toplevel window
while (p) {
win = p;
p = [win parentWindow];
}
if ([win inLiveResize]) // inLiveResize requires 10.6
return frameRect;
}
return [super constrainFrameRect:frameRect toScreen:screen]; // will prevent a window from covering the menu bar
}
#endif
@end
@interface FLApplication : NSObject
@ -1343,7 +1364,7 @@ static FLWindowDelegate *flwindowdelegate_instance = nil;
Fl_Window *window = [nsw getFl_Window];
NSRect r; NSPoint pt2;
r = [[nsw contentView] frame];
pt2 = [nsw convertBaseToScreen:NSMakePoint(0, [[nsw contentView] frame].size.height)];
pt2 = [nsw convertBaseToScreen:NSMakePoint(0, r.size.height)];
pt2.y = main_screen_height - pt2.y;
Fl_Window *parent = window->window();
while (parent) {