transparent window can't click through in macos sonoma

i crate a fully transparent NSWindow like this:

NSWindowStyleMask styleMask = NSBorderlessWindowMask | NSFullSizeContentViewWindowMask; 
 
NSWinod *window = [[BrowserNSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 500, 600) 
                                                    styleMask:styleMask 
                                                      backing:NSBackingStoreBuffered 
                                                        defer:NO]; 
 
 
[window setBackgroundColor:[NSColor clearColor]]; 
[window setOpaque:NO]; 
[window setHasShadow:NO]; 
 
NSCustomView *view = [[NSCustomView alloc] initWithFrame:NSMakeRect(0, 0, 500, 600) andBrowserWindow:this]; 
[view setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)]; 
[view setAutoresizesSubviews: true]; 
[window.contentView addSubview:view];

and override the NSView drawRect function:

- (void)drawRect:(NSRect)rect 
{ 
    [[NSColor clearColor] set]; 
    NSRectFill(rect); 
    NSRectFillUsingOperation(rect, NSCompositingOperationSourceOver); 
}

i call setNeedDisplay:YES to redraw the view. in macos sonoma, i found that when after multiple calls setNeedDisplay:YES, the transparent window can't click through. This feature run correctly in previous versions, like macos 13,

You may want to set the ignoresMouseEvents property of the window.

In the example code, I simplified the implementation of drawRect. In real app, some areas of the window are transparent, so i can't set ignoresMouseEvents.

I found an old sample project that draws a round window: https://www.cocoawithlove.com/2008/12/drawing-custom-window-on-mac-os-x.html It's old, so it needs a few obvious changes to make it compile with a recent Xcode. But it does work in a Sonoma beta. You may want to see how this compares with your code.

@JWWalker Thanks for your help, i try the the project and also find the same error

transparent window can't click through in macos sonoma
 
 
Q