From 39bb0bf488dc1d9051b6eec719df1ac17ca88bc9 Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Mon, 17 Sep 2018 08:08:39 +0000 Subject: [PATCH] MacOS 10.10+: Fl_Window::fullscreen() and fullscreen_off() no longer call Fl_Window::hide() + Fl_Window::show() The new procedure essentially resizes the window, as done on the X11+EWMH and Windows platforms. This improves in particular the possibility to turn an Fl_Gl_Window fullscreen on and off. MacOS 10.10+ is required because the procedure isn't stable (random crashes during fast switches) with 10.9. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@13051 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_cocoa.mm | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index 53ba7bbf1..f61f83764 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -2926,18 +2926,42 @@ void Fl_X::GLcontext_makecurrent(NSOpenGLContext* ctxt) void Fl_Window::fullscreen_x() { _set_fullscreen(); - /* On OS X < 10.6, it is necessary to recreate the window. This is done - with hide+show. */ - hide(); - show(); + if (fl_mac_os_version < 101000) { + // On OS X < 10.6, it is necessary to recreate the window. This is done with hide+show. + // The alternative procedure isn't stable until MacOS 10.10 + hide(); + show(); + } else { +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 + [i->xid setStyleMask:NSBorderlessWindowMask]; //10.6 +#endif + [i->xid setLevel:NSStatusWindowLevel]; + int X,Y,W,H; + Fl::screen_xywh(X, Y, W, H, x(), y(), w(), h()); + resize(X, Y, W, H); + } Fl::handle(FL_FULLSCREEN, this); } void Fl_Window::fullscreen_off_x(int X, int Y, int W, int H) { _clear_fullscreen(); - hide(); - resize(X, Y, W, H); - show(); + if (fl_mac_os_version < 101000) { + hide(); + resize(X, Y, W, H); + show(); + } else { + NSUInteger winstyle = (border() ? + (NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask) : NSBorderlessWindowMask); + if (!modal()) winstyle |= NSMiniaturizableWindowMask; + NSInteger level = NSNormalWindowLevel; + if (modal()) level = modal_window_level(); + else if (non_modal()) level = non_modal_window_level(); + [i->xid setLevel:level]; + resize(X, Y, W, H); +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 + [i->xid setStyleMask:winstyle]; //10.6 +#endif + } Fl::handle(FL_FULLSCREEN, this); } @@ -3293,7 +3317,7 @@ void Fl_Window::resize(int X,int Y,int W,int H) { by += parent->y(); parent = parent->window(); } - NSRect r = NSMakeRect(bx, main_screen_height - (by + H), W, H + (border()?bt:0)); + NSRect r = NSMakeRect(bx, main_screen_height - (by + H), W, H + ( (border()&&!fullscreen_active())?bt:0 )); if (visible_r()) [fl_xid(this) setFrame:r display:YES]; } else { bx = X; by = Y;