mirror of
https://github.com/kanjitalk755/macemu.git
synced 2024-11-28 08:49:32 +00:00
don't add window observers multiple times
This commit is contained in:
parent
60ce4fc5f7
commit
20f027dd97
@ -74,11 +74,7 @@ void make_window_transparent(SDL_Window * window)
|
||||
NSWindow *cocoaWindow = wmInfo.info.cocoa.window;
|
||||
NSView *sdlView = cocoaWindow.contentView;
|
||||
sdlView.layer.backgroundColor = [NSColor clearColor].CGColor;
|
||||
if (SDL_GetWindowData(window, "maskLayer") == NULL) {
|
||||
CALayer *maskLayer = [CAShapeLayer layer];
|
||||
sdlView.layer.mask = maskLayer;
|
||||
SDL_SetWindowData(window, "maskLayer", maskLayer);
|
||||
|
||||
if (SDL_GetWindowData(window, "observing") == NULL) {
|
||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||
[nc addObserverForName:NSWindowDidBecomeKeyNotification object:cocoaWindow queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * _Nonnull note) {
|
||||
NSWindow *window = (NSWindow*)note.object;
|
||||
@ -91,6 +87,12 @@ void make_window_transparent(SDL_Window * window)
|
||||
[window setLevel:NSNormalWindowLevel];
|
||||
[window setIsVisible:YES];
|
||||
}];
|
||||
SDL_SetWindowData(window, "observing", nc);
|
||||
}
|
||||
if (SDL_GetWindowData(window, "maskLayer") == NULL) {
|
||||
CALayer *maskLayer = [CAShapeLayer layer];
|
||||
sdlView.layer.mask = maskLayer;
|
||||
SDL_SetWindowData(window, "maskLayer", maskLayer);
|
||||
}
|
||||
cocoaWindow.backgroundColor = [NSColor clearColor];
|
||||
cocoaWindow.hasShadow = NO;
|
||||
|
Loading…
Reference in New Issue
Block a user