From 98b4ece33e1073702f340ed574327e778485979b Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Sun, 21 Apr 2019 09:45:06 +0200 Subject: [PATCH] Reorder Fl_Cocoa_Window_Driver to support upward OS compatibility --- src/Fl_cocoa.mm | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index 5689e470f..9d0edbb91 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -3205,19 +3205,19 @@ Fl_X* Fl_Cocoa_Window_Driver::makeWindow() void Fl_Cocoa_Window_Driver::fullscreen_on() { pWindow->_set_fullscreen(); - if (fl_mac_os_version < 100600) { - // On OS X < 10.6, it is necessary to recreate the window. This is done with hide+show. - pWindow->hide(); - pWindow->show(); - } else { - FLWindow *nswin = fl_xid(pWindow); #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 + if (fl_mac_os_version >= 100600) { + FLWindow *nswin = fl_xid(pWindow); [nswin setStyleMask:NSBorderlessWindowMask]; // 10.6 -#endif [nswin setLevel:NSStatusWindowLevel]; int X,Y,W,H; Fl::screen_xywh(X, Y, W, H, x(), y(), w(), h()); pWindow->resize(X, Y, W, H); + } else +#endif + { // On OS X < 10.6, it is necessary to recreate the window. This is done with hide+show. + pWindow->hide(); + pWindow->show(); } Fl::handle(FL_FULLSCREEN, pWindow); } @@ -3236,31 +3236,35 @@ static NSUInteger calc_win_style(Fl_Window *win) { void Fl_Cocoa_Window_Driver::fullscreen_off(int X, int Y, int W, int H) { pWindow->_clear_fullscreen(); - if (fl_mac_os_version < 100600) { - pWindow->hide(); - pWindow->resize(X, Y, W, H); - pWindow->show(); - } else { +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 + if (fl_mac_os_version >= 100600) { FLWindow *nswin = fl_xid(pWindow); NSInteger level = NSNormalWindowLevel; if (pWindow->modal()) level = modal_window_level(); else if (pWindow->non_modal()) level = non_modal_window_level(); [nswin setLevel:level]; -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 [nswin setStyleMask:calc_win_style(pWindow)]; //10.6 -#endif pWindow->resize(X, Y, W, H); - } + } else +#endif + { + pWindow->hide(); + pWindow->resize(X, Y, W, H); + pWindow->show(); + } Fl::handle(FL_FULLSCREEN, pWindow); } void Fl_Cocoa_Window_Driver::use_border() { if (!shown() || pWindow->parent()) return; - if (fl_mac_os_version < 100600) return Fl_Window_Driver::use_border(); #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 - [fl_xid(pWindow) setStyleMask:calc_win_style(pWindow)]; // 10.6 - pWindow->redraw(); + if (fl_mac_os_version >= 100600) { + [fl_xid(pWindow) setStyleMask:calc_win_style(pWindow)]; // 10.6 + pWindow->redraw(); + } + else #endif + Fl_Window_Driver::use_border(); } /*