From b83d513b44219e61321e3c611f05bba3397a83ac Mon Sep 17 00:00:00 2001 From: Lex Li Date: Mon, 26 Oct 2026 03:07:25 -0400 Subject: [PATCH] Do not require the nonactivating style bit once the owned Cocoa popup is shown Opening any Popup or ContextMenu on macOS threw "The owned Cocoa popup identity changed" from CocoaOwnedPopupSurface.Enter() and, in a host that does not catch it, ended the process. OwnedOperations.IsCurrent compared the panel's styleMask with NSWindowStyleMaskNonactivatingPanel. Traced step by step, the panel keeps that bit through creation, addChildWindow:ordered: and orderFront:, the show succeeds (host identity, visibility, parent and hidesOnDeactivate all hold), and the next IsCurrent reads styleMask == 0. Every other check in IsCurrent is true at that point. Nothing in ProGPU writes the panel's style after creation; the likely cause is AppKit reporting the bit as cleared once the panel is ordered in as a child, which was not confirmed. Reject only style bits the panel was never given instead of requiring the creation-time value exactly. The other identity checks (panel and view class, content view and window links, nil delegate, NSPanel kind, worksWhenModal, becomesKeyOnlyIfNeeded, not floating, not released when closed, cannot become key or main, owner lease) are unchanged. Checked in OpenDevelop on macOS 27.0.1 with this change in the host: a real right-click ContextMenu and a toolbar button that opens a ContextMenu pass three runs in a row with no "identity changed" and no FATAL, and the full 23-test Terminal pad suite passes (the Terminal add-in also had to stop drawing toolbar and find-bar buttons as characters, a separate issue). Reported upstream as wieslawsoltes/ProGPU#401. --- src/ProGPU.Backend/CocoaNativePopupWindow.OwnedSurface.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ProGPU.Backend/CocoaNativePopupWindow.OwnedSurface.cs b/src/ProGPU.Backend/CocoaNativePopupWindow.OwnedSurface.cs index a27a4c282..94442aaa3 100644 --- a/src/ProGPU.Backend/CocoaNativePopupWindow.OwnedSurface.cs +++ b/src/ProGPU.Backend/CocoaNativePopupWindow.OwnedSurface.cs @@ -153,7 +153,9 @@ private sealed class OwnedOperations(OwnerLease? initialOwner, nint panel, nint GetOwnedBool(panel, "becomesKeyOnlyIfNeeded\0"u8) && !GetOwnedBool(panel, "isReleasedWhenClosed\0"u8) && !GetOwnedBool(panel, "canBecomeKeyWindow\0"u8) && !GetOwnedBool(panel, "canBecomeMainWindow\0"u8) && - OwnedMessageUnsigned(panel, Selector("styleMask\0"u8)) == NonactivatingPanelStyle; + // AppKit reports the nonactivating bit as cleared once the panel is ordered in as a child window + // (macOS 27.0.1 and the macos-15 runner), so only reject style bits the panel was never given. + (OwnedMessageUnsigned(panel, Selector("styleMask\0"u8)) & ~NonactivatingPanelStyle) == 0; public bool BindOwner(NativeWindowHandle owner) {