Skip to content

Commit

Permalink
MacOS 10.10+: Fl_Window::fullscreen() and fullscreen_off() no longer …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
Manolo Gouy authored and Manolo Gouy committed Sep 17, 2018
1 parent 226b64e commit 39bb0bf
Showing 1 changed file with 32 additions and 8 deletions.
40 changes: 32 additions & 8 deletions src/Fl_cocoa.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2926,18 +2926,42 @@ - (NSInteger)windowLevel {

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);
}

Expand Down Expand Up @@ -3293,7 +3317,7 @@ - (NSInteger)windowLevel {
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;
Expand Down

0 comments on commit 39bb0bf

Please sign in to comment.