Fix: Fl_Window::fullscreen() does not work correctly on Mac (#920)

This commit is contained in:
ManoloFLTK 2024-02-26 12:15:47 +01:00
parent 41740caa2e
commit 0818d4ec5b
2 changed files with 29 additions and 2 deletions

View File

@ -1192,6 +1192,8 @@ static FLTextView *fltextview_instance = nil;
- (void)windowDidDeminiaturize:(NSNotification *)notif;
- (void)fl_windowMiniaturize:(NSNotification *)notif;
- (void)windowDidMiniaturize:(NSNotification *)notif;
- (void)windowWillEnterFullScreen:(NSNotification *)notif;
- (void)windowWillExitFullScreen:(NSNotification *)notif;
- (BOOL)windowShouldClose:(id)fl;
- (void)anyWindowWillClose:(NSNotification *)notif;
- (void)doNothing:(id)unused;
@ -1447,6 +1449,18 @@ static FLWindowDelegate *flwindowdelegate_instance = nil;
Fl::handle(FL_HIDE, window);
fl_unlock_function();
}
- (void)windowWillEnterFullScreen:(NSNotification *)notif;
{
FLWindow *nsw = (FLWindow*)[notif object];
Fl_Window *window = [nsw getFl_Window];
window->_set_fullscreen();
}
- (void)windowWillExitFullScreen:(NSNotification *)notif;
{
FLWindow *nsw = (FLWindow*)[notif object];
Fl_Window *window = [nsw getFl_Window];
window->_clear_fullscreen();
}
- (BOOL)windowShouldClose:(id)fl
{
fl_lock_function();
@ -3198,7 +3212,12 @@ void Fl_Cocoa_Window_Driver::makeWindow()
void Fl_Cocoa_Window_Driver::fullscreen_on() {
pWindow->_set_fullscreen();
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
if (fl_mac_os_version >= 100600) {
if (fl_mac_os_version >= 100700) {
# if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
FLWindow *nswin = fl_xid(pWindow);
[nswin toggleFullScreen:nil];
# endif
} else if (fl_mac_os_version >= 100600) {
FLWindow *nswin = fl_xid(pWindow);
[nswin setStyleMask:NSWindowStyleMaskBorderless]; // 10.6
if ([nswin isKeyWindow]) {
@ -3279,7 +3298,12 @@ static void restore_window_title_and_icon(Fl_Window *pWindow, NSImage *icon) {
void Fl_Cocoa_Window_Driver::fullscreen_off(int X, int Y, int W, int H) {
pWindow->_clear_fullscreen();
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
if (fl_mac_os_version >= 100600) {
if (fl_mac_os_version >= 100700) {
# if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
FLWindow *nswin = fl_xid(pWindow);
[nswin toggleFullScreen:nil];
# endif
} else if (fl_mac_os_version >= 100600) {
FLWindow *nswin = fl_xid(pWindow);
NSInteger level = NSNormalWindowLevel;
if (pWindow->modal()) level = modal_window_level();

View File

@ -139,6 +139,9 @@ void after_resize(void *data) {
if (win->maximize_active()) win->b3_maxi->set();
else win->b3_maxi->clear();
win->b3_maxi->redraw();
if (win->fullscreen_active()) win->b3->set();
else win->b3->clear();
win->b3->redraw();
}
void fullscreen_window::resize(int x, int y, int w, int h) {