Skip to content

Commit

Permalink
Merge pull request #71295 from bruvzg/macos_bg_color
Browse files Browse the repository at this point in the history
[macOS] Avoid color flash on window resizing
  • Loading branch information
akien-mga committed Jan 13, 2023
2 parents 7c2768c + 1ed4ed3 commit 04bee38
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions platform/macos/display_server_macos.mm
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,17 @@
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);
Expand Down Expand Up @@ -273,12 +284,17 @@
#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)
Expand Down

0 comments on commit 04bee38

Please sign in to comment.