Something changed with the focus handling between macOS 12 and macOS 13. We now lose focus whenever we leave full screen. It doesn't matter if a keyboard grab was active or not.
This was split of bug 8046. A backtrace for when it happened was found as part of that bug:
> (lldb) bt
> * thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGUSR1
> * frame #0: 0x00007ff807a82e5a libsystem_kernel.dylib`__kill + 10
> frame #1: 0x000000010001cfc2 vncviewer`DesktopWindow::fltkDispatch(int, Fl_Window*) + 162
> frame #2: 0x00000001000d2616 vncviewer`-[FLWindowDelegate windowDidResignKey:] + 70
> frame #3: 0x00007ff807b8b6e6 CoreFoundation`__CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 137
> frame #4: 0x00007ff807c24ccc CoreFoundation`___CFXRegistrationPost_block_invoke + 86
> frame #5: 0x00007ff807c24c23 CoreFoundation`_CFXRegistrationPost + 534
> frame #6: 0x00007ff807b5ee61 CoreFoundation`_CFXNotificationPost + 809
> frame #7: 0x00007ff8088d1f2c Foundation`-[NSNotificationCenter postNotificationName:object:userInfo:] + 82
> frame #8: 0x00007ff80ad8d8dd AppKit`-[NSWindow resignKeyWindow] + 758
> frame #9: 0x00007ff80b53af66 AppKit`-[NSWindow _orderOut:calculatingKeyWithOptions:documentWindow:] + 319
> frame #10: 0x00007ff80ac3d1c2 AppKit`NSPerformVisuallyAtomicChange + 132
> frame #11: 0x00007ff80b53d008 AppKit`-[NSWindow _reallyDoOrderWindowOutRelativeTo:] + 634
> frame #12: 0x00007ff80b53d413 AppKit`-[NSWindow _reallyDoOrderWindow:] + 99
> frame #13: 0x00007ff80b53d689 AppKit`-[NSWindow _doOrderWindow:] + 295
> frame #14: 0x00000001000d5eb1 vncviewer`Fl_Window::fullscreen_off_x(int, int, int, int) + 113
> frame #15: 0x00000001000b7f75 vncviewer`Fl_Window::fullscreen_off(int, int, int, int) + 85
> frame #16: 0x0000000100028c24 vncviewer`Viewport::handleSystemEvent(void*, void*) + 436
> frame #17: 0x000000010008daf2 vncviewer`fl_send_system_handlers(void*) + 50
> frame #18: 0x00000001000d4555 vncviewer`+[FLApplication sendEvent:] + 21
> frame #19: 0x00000001000d4d39 vncviewer`fl_mac_flush_and_wait(double) + 473
> frame #20: 0x00000001003e2fc6 vncviewer`main + 2070
> frame #21: 0x0000000100019f74 vncviewer`start + 52
Digging further, the call that happens in between frame 14 and frame 15 is orderOut:. We added this call as part of bug 7777, and the upstream discussion for adding that can be found here:
Reported upstream here:
Upstream has a fix in place, so let's get it into our builds.
Works much better with a fixed FLTK. I can get the F8 menu right away after leaving full screen.
Tested with server build #2977 on Fedora37 and client builds #2876 (pre-fix) and #2882 (post-fix), on macOS 13.1.
Can confirm that the session windows indeed loses focus with the client pre-fix build when going from full screen to windowed mode. However, this is not the case for the post-fix build, as focus is retained as intended. There seems to be no complication from using multiple screens. Moreover, focus is retained even when bug 8066 occurs.