From 4e9ed130dff6de5efa2ede73a0fe6f7793e7a122 Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Fri, 30 Dec 2022 18:23:57 +0100 Subject: [PATCH] Fix "Focus is lost leaving full screen on macOS 13" (#608) --- src/Fl_cocoa.mm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index e392157ed..8a1b6d8d9 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -3137,6 +3137,7 @@ void Fl_Window::fullscreen_off_x(int X, int Y, int W, int H) { NSInteger level = NSNormalWindowLevel; if (modal()) level = modal_window_level(); else if (non_modal()) level = non_modal_window_level(); + BOOL has_focus = [i->xid isKeyWindow]; [i->xid orderOut:nil]; [i->xid setLevel:level]; NSUInteger winstyle = (border() ? @@ -3144,7 +3145,8 @@ void Fl_Window::fullscreen_off_x(int X, int Y, int W, int H) { if (!modal()) winstyle |= NSMiniaturizableWindowMask; [i->xid setStyleMask:winstyle]; //10.6 resize(X, Y, W, H); - [i->xid orderFront:nil]; + if (has_focus) [i->xid makeKeyAndOrderFront:nil]; + else [i->xid orderFront:nil]; } else #endif {