summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2015-11-16 08:47:18 +0000
committerManolo Gouy <Manolo>2015-11-16 08:47:18 +0000
commit535b477e7c2eee53c102787b45f100dd608561e3 (patch)
tree684024812835b5a8ff1948a33e436da51c80b02f
parentc319e9bcc99f1065e6d9c9b6e32925ffcbf409c1 (diff)
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
-rw-r--r--src/Fl_cocoa.mm23
1 files changed, 22 insertions, 1 deletions
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) {