make rootless window overlay everything else

This commit is contained in:
Jesús A. Álvarez 2019-11-05 23:02:59 +01:00
parent f6616d1d4d
commit 68fcaa117b

View File

@ -75,10 +75,26 @@ void make_window_transparent(SDL_Window * window)
CALayer *maskLayer = [CAShapeLayer layer]; CALayer *maskLayer = [CAShapeLayer layer];
sdlView.layer.mask = maskLayer; sdlView.layer.mask = maskLayer;
SDL_SetWindowData(window, "maskLayer", maskLayer); SDL_SetWindowData(window, "maskLayer", maskLayer);
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc addObserverForName:NSWindowDidBecomeKeyNotification object:cocoaWindow queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * _Nonnull note) {
NSWindow *window = (NSWindow*)note.object;
window.level = NSMainMenuWindowLevel+1;
}];
[nc addObserverForName:NSWindowDidResignKeyNotification object:cocoaWindow queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * _Nonnull note) {
NSWindow *window = (NSWindow*)note.object;
// hack for window to be sent behind new key window
[window setIsVisible:NO];
[window setLevel:NSNormalWindowLevel];
[window setIsVisible:YES];
}];
} }
cocoaWindow.backgroundColor = [NSColor clearColor]; cocoaWindow.backgroundColor = [NSColor clearColor];
cocoaWindow.hasShadow = NO; cocoaWindow.hasShadow = NO;
cocoaWindow.opaque = NO; cocoaWindow.opaque = NO;
if (cocoaWindow.isKeyWindow) {
cocoaWindow.level = NSMainMenuWindowLevel+1;
}
// make metal layer transparent // make metal layer transparent
for (NSView *view in sdlView.subviews) { for (NSView *view in sdlView.subviews) {