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,