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.4@13045 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
b6f65b1c87
commit
b0e0e0912c
3
CHANGES
3
CHANGES
@ -102,6 +102,9 @@ Changes in FLTK 1.4.0 Released: ??? ?? 2018
|
||||
Other Improvements
|
||||
|
||||
- (add new items here)
|
||||
- MacOS ≥ 10.10: Fl_Window::fullscreen() and fullscreen_off() no longer
|
||||
proceed by Fl_Window::hide() + Fl_Window::show() but essentially
|
||||
resize the window, as done on the X11+EWMH and Windows platforms.
|
||||
- Fl_Cairo_Window constructors are now compatible with Fl_Double_Window
|
||||
constructors - fixed missing constructors (STR #3160).
|
||||
- The include file for platform specific functions and definitions
|
||||
|
||||
@ -198,7 +198,6 @@ int main (int argc, char* argv[])
|
||||
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | FL_OPENGL3);
|
||||
glutInitWindowSize(400, 400);
|
||||
glutCreateWindow("Triangle Test");
|
||||
if (fullscreen) Fl::first_window()->fullscreen();
|
||||
#ifndef __APPLE__
|
||||
GLenum err = glewInit(); // defines pters to functions of OpenGL V 1.2 and above
|
||||
if (err) Fl::error("glewInit() failed returning %u", err);
|
||||
@ -215,6 +214,7 @@ int main (int argc, char* argv[])
|
||||
initShaders();
|
||||
init();
|
||||
glutDisplayFunc(display);
|
||||
if (fullscreen) Fl::first_window()->fullscreen();
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -3000,6 +3000,48 @@ Fl_X* Fl_Cocoa_Window_Driver::makeWindow()
|
||||
return x;
|
||||
}
|
||||
|
||||
void Fl_Cocoa_Window_Driver::fullscreen_on() {
|
||||
pWindow->_set_fullscreen();
|
||||
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
|
||||
pWindow->hide();
|
||||
pWindow->show();
|
||||
} else {
|
||||
FLWindow *nswin = fl_xid(pWindow);
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
|
||||
[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);
|
||||
}
|
||||
Fl::handle(FL_FULLSCREEN, pWindow);
|
||||
}
|
||||
|
||||
void Fl_Cocoa_Window_Driver::fullscreen_off(int X, int Y, int W, int H) {
|
||||
pWindow->_clear_fullscreen();
|
||||
if (fl_mac_os_version < 101000) {
|
||||
pWindow->hide();
|
||||
pWindow->resize(X, Y, W, H);
|
||||
pWindow->show();
|
||||
} else {
|
||||
FLWindow *nswin = fl_xid(pWindow);
|
||||
NSUInteger winstyle = (pWindow->border() ?
|
||||
(NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask) : NSBorderlessWindowMask);
|
||||
if (!pWindow->modal()) winstyle |= NSMiniaturizableWindowMask;
|
||||
NSInteger level = NSNormalWindowLevel;
|
||||
if (pWindow->modal()) level = modal_window_level();
|
||||
else if (pWindow->non_modal()) level = non_modal_window_level();
|
||||
[nswin setLevel:level];
|
||||
pWindow->resize(X, Y, W, H);
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
|
||||
[nswin setStyleMask:winstyle]; //10.6
|
||||
#endif
|
||||
}
|
||||
Fl::handle(FL_FULLSCREEN, pWindow);
|
||||
}
|
||||
|
||||
/*
|
||||
* Tell the OS what window sizes we want to allow
|
||||
|
||||
@ -252,25 +252,6 @@ void Fl_Cocoa_Window_Driver::hide() {
|
||||
}
|
||||
|
||||
|
||||
void Fl_Cocoa_Window_Driver::fullscreen_on() {
|
||||
pWindow->_set_fullscreen();
|
||||
/* 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);
|
||||
}
|
||||
|
||||
|
||||
void Fl_Cocoa_Window_Driver::fullscreen_off(int X, int Y, int W, int H) {
|
||||
pWindow->_clear_fullscreen();
|
||||
pWindow->hide();
|
||||
pWindow->resize(X, Y, W, H);
|
||||
pWindow->show();
|
||||
Fl::handle(FL_FULLSCREEN, pWindow);
|
||||
}
|
||||
|
||||
|
||||
void Fl_Cocoa_Window_Driver::decoration_sizes(int *top, int *left, int *right, int *bottom) {
|
||||
*top = 24;
|
||||
*left = 2;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user