From 68fcaa117bdcf543a85335b603cefbf5b9927f31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesu=CC=81s=20A=2E=20A=CC=81lvarez?= Date: Tue, 5 Nov 2019 23:02:59 +0100 Subject: [PATCH] make rootless window overlay everything else --- BasiliskII/src/MacOSX/utils_macosx.mm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/BasiliskII/src/MacOSX/utils_macosx.mm b/BasiliskII/src/MacOSX/utils_macosx.mm index c2716c0e..68855488 100644 --- a/BasiliskII/src/MacOSX/utils_macosx.mm +++ b/BasiliskII/src/MacOSX/utils_macosx.mm @@ -75,10 +75,26 @@ void make_window_transparent(SDL_Window * window) CALayer *maskLayer = [CAShapeLayer layer]; sdlView.layer.mask = 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.hasShadow = NO; cocoaWindow.opaque = NO; + if (cocoaWindow.isKeyWindow) { + cocoaWindow.level = NSMainMenuWindowLevel+1; + } // make metal layer transparent for (NSView *view in sdlView.subviews) {