mirror of
https://github.com/kanjitalk755/macemu.git
synced 2024-06-16 15:29:32 +00:00
make window transparent
This commit is contained in:
parent
8e9fa50385
commit
36195df44a
|
@ -52,6 +52,40 @@ void disable_SDL2_macosx_menu_bar_keyboard_shortcuts() {
|
|||
}
|
||||
}
|
||||
|
||||
void make_window_transparent(SDL_Window * window)
|
||||
{
|
||||
if (!window) {
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_SysWMinfo wmInfo;
|
||||
SDL_VERSION(&wmInfo.version);
|
||||
if (!SDL_GetWindowWMInfo(window, &wmInfo)) {
|
||||
return;
|
||||
}
|
||||
|
||||
CGColorRef clearColor = [NSColor clearColor].CGColor;
|
||||
NSWindow *cocoaWindow = wmInfo.info.cocoa.window;
|
||||
NSView *sdlView = cocoaWindow.contentView;
|
||||
sdlView.layer.backgroundColor = [NSColor clearColor].CGColor;
|
||||
cocoaWindow.backgroundColor = [NSColor clearColor];
|
||||
cocoaWindow.hasShadow = NO;
|
||||
cocoaWindow.opaque = NO;
|
||||
|
||||
// make metal layer transparent
|
||||
for (NSView *view in sdlView.subviews) {
|
||||
if ([view.className isEqualToString:@"SDL_cocoametalview"]) {
|
||||
view.layer.opaque = NO;
|
||||
view.layer.backgroundColor = clearColor;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// make OpenGL surface transparent
|
||||
GLint zero = 0;
|
||||
[[NSOpenGLContext currentContext] setValues:&zero forParameter:NSOpenGLCPSurfaceOpacity];
|
||||
}
|
||||
|
||||
bool is_fullscreen_osx(SDL_Window * window)
|
||||
{
|
||||
if (!window) {
|
||||
|
|
|
@ -751,6 +751,11 @@ static SDL_Surface * init_sdl_video(int width, int height, int bpp, Uint32 flags
|
|||
}
|
||||
if (flags & SDL_WINDOW_FULLSCREEN) SDL_SetWindowGrab(sdl_window, SDL_TRUE);
|
||||
|
||||
#ifdef __MACOSX__
|
||||
extern void make_window_transparent(SDL_Window * window);
|
||||
make_window_transparent(sdl_window);
|
||||
#endif
|
||||
|
||||
// Some SDL events (regarding some native-window events), need processing
|
||||
// as they are generated. SDL2 has a facility, SDL_AddEventWatch(), which
|
||||
// allows events to be processed as they are generated.
|
||||
|
|
Loading…
Reference in New Issue
Block a user