From 535b477e7c2eee53c102787b45f100dd608561e3 Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Mon, 16 Nov 2015 08:47:18 +0000 Subject: 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 --- src/Fl_cocoa.mm | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index f1157a551..5f189317e 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -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) { -- cgit v1.2.3