From 965276d6165794aa50c85e0d9363464bf7bf294b Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Sat, 30 Sep 2023 09:33:09 +0200 Subject: [PATCH] Disallow entering fullscreen when showing window. (#12865) Fixes hard-to-reproduce problem when showing a window while on a fullscreen space. --- native/Avalonia.Native/src/OSX/WindowBaseImpl.mm | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/native/Avalonia.Native/src/OSX/WindowBaseImpl.mm b/native/Avalonia.Native/src/OSX/WindowBaseImpl.mm index 1a4f979ce7..3f54680ae7 100644 --- a/native/Avalonia.Native/src/OSX/WindowBaseImpl.mm +++ b/native/Avalonia.Native/src/OSX/WindowBaseImpl.mm @@ -106,6 +106,17 @@ HRESULT WindowBaseImpl::Show(bool activate, bool isDialog) { [Window center]; } + // When showing a window, disallow fullscreen because if the window is being + // shown while another window is fullscreen, macOS will briefly transition this + // new window to fullscreen and then it will be transitioned back. This breaks + // input events for a short time as described in this issue: + // + // https://yt.avaloniaui.net/issue/OUTSYSTEMS-40 + // + // We restore the collection behavior at the end of this method. + auto collectionBehavior = [Window collectionBehavior]; + [Window setCollectionBehavior:collectionBehavior & ~NSWindowCollectionBehaviorFullScreenPrimary]; + UpdateStyle(); [Window invalidateShadow]; @@ -120,7 +131,7 @@ HRESULT WindowBaseImpl::Show(bool activate, bool isDialog) { } _shown = true; - + [Window setCollectionBehavior:collectionBehavior]; return S_OK; } }