mirror of
https://github.com/kanjitalk755/macemu.git
synced 2025-02-26 03:29:04 +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;
|
NSWindow *cocoaWindow = wmInfo.info.cocoa.window;
|
||||||
NSView *sdlView = cocoaWindow.contentView;
|
NSView *sdlView = cocoaWindow.contentView;
|
||||||
sdlView.layer.backgroundColor = [NSColor clearColor].CGColor;
|
sdlView.layer.backgroundColor = [NSColor clearColor].CGColor;
|
||||||
if (SDL_GetWindowData(window, "maskLayer") == NULL) {
|
if (SDL_GetWindowData(window, "observing") == NULL) {
|
||||||
CALayer *maskLayer = [CAShapeLayer layer];
|
|
||||||
sdlView.layer.mask = maskLayer;
|
|
||||||
SDL_SetWindowData(window, "maskLayer", maskLayer);
|
|
||||||
|
|
||||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||||
[nc addObserverForName:NSWindowDidBecomeKeyNotification object:cocoaWindow queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * _Nonnull note) {
|
[nc addObserverForName:NSWindowDidBecomeKeyNotification object:cocoaWindow queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * _Nonnull note) {
|
||||||
NSWindow *window = (NSWindow*)note.object;
|
NSWindow *window = (NSWindow*)note.object;
|
||||||
@ -91,6 +87,12 @@ void make_window_transparent(SDL_Window * window)
|
|||||||
[window setLevel:NSNormalWindowLevel];
|
[window setLevel:NSNormalWindowLevel];
|
||||||
[window setIsVisible:YES];
|
[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.backgroundColor = [NSColor clearColor];
|
||||||
cocoaWindow.hasShadow = NO;
|
cocoaWindow.hasShadow = NO;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user