diff options
author | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2023-01-13 00:02:07 +0200 |
---|---|---|
committer | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2023-01-13 07:39:45 +0200 |
commit | 1ed4ed3a16ace2640a7866d2e42b9da983013c9d (patch) | |
tree | 24ca5038b2a86e46ad3cf5552bfd5a5e2429619a /platform/macos/display_server_macos.mm | |
parent | 7c2768c2f8abc2e81a55be72b436de69d9f01bf9 (diff) |
[macOS] Avoid color flash on window creation and resizing.
Diffstat (limited to 'platform/macos/display_server_macos.mm')
-rw-r--r-- | platform/macos/display_server_macos.mm | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/platform/macos/display_server_macos.mm b/platform/macos/display_server_macos.mm index 759ae03d95..865b8d9711 100644 --- a/platform/macos/display_server_macos.mm +++ b/platform/macos/display_server_macos.mm @@ -166,6 +166,17 @@ DisplayServerMacOS::WindowID DisplayServerMacOS::_create_window(WindowMode p_mod layer.contentsScale = scale; } + NSColor *bg_color = [NSColor windowBackgroundColor]; + Color _bg_color; + if (_get_window_early_clear_override(_bg_color)) { + bg_color = [NSColor colorWithCalibratedRed:_bg_color.r green:_bg_color.g blue:_bg_color.b alpha:1.f]; + } + + [wd.window_object setBackgroundColor:bg_color]; + if (layer) { + [layer setBackgroundColor:bg_color.CGColor]; + } + #if defined(VULKAN_ENABLED) if (context_vulkan) { Error err = context_vulkan->window_create(window_id_counter, p_vsync_mode, wd.window_view, p_rect.size.width, p_rect.size.height); @@ -273,12 +284,17 @@ void DisplayServerMacOS::_set_window_per_pixel_transparency_enabled(bool p_enabl #endif wd.layered_window = true; } else { - [wd.window_object setBackgroundColor:[NSColor colorWithCalibratedWhite:1 alpha:1]]; + NSColor *bg_color = [NSColor windowBackgroundColor]; + Color _bg_color; + if (_get_window_early_clear_override(_bg_color)) { + bg_color = [NSColor colorWithCalibratedRed:_bg_color.r green:_bg_color.g blue:_bg_color.b alpha:1.f]; + } + [wd.window_object setBackgroundColor:bg_color]; [wd.window_object setOpaque:YES]; [wd.window_object setHasShadow:YES]; CALayer *layer = [(NSView *)wd.window_view layer]; if (layer) { - [layer setBackgroundColor:[NSColor colorWithCalibratedWhite:1 alpha:1].CGColor]; + [layer setBackgroundColor:bg_color.CGColor]; [layer setOpaque:YES]; } #if defined(GLES3_ENABLED) |