From 4a6134f3f71ab7cd7e1406d588f74480b870a3da Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 23 Oct 2015 11:17:14 +0800 Subject: [PATCH] win: Set native window's background color --- atom/browser/native_window_views.cc | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index 1e4207bf0c6..ab4df82df75 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -42,6 +42,7 @@ #elif defined(OS_WIN) #include "atom/browser/ui/views/win_frame_view.h" #include "atom/browser/ui/win/atom_desktop_window_tree_host_win.h" +#include "skia/ext/skia_utils_win.h" #include "ui/base/win/shell.h" #include "ui/gfx/win/dpi.h" #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" @@ -230,14 +231,22 @@ NativeWindowViews::NativeWindowViews( SetLayoutManager(new MenuLayout(this, kMenuBarHeight)); // web views' background color. - std::string background_color = "#fff"; - options.Get(switches::kBackgroundColor, &background_color); - set_background(views::Background::CreateSolidBackground( - ParseHexColor(background_color))); + SkColor background_color = SK_ColorWHITE; + std::string color_name; + if (options.Get(switches::kBackgroundColor, &color_name)) + background_color = ParseHexColor(color_name); + set_background(views::Background::CreateSolidBackground(background_color)); AddChildView(web_view_); #if defined(OS_WIN) + // Set the background color of native window. + HBRUSH brush = CreateSolidBrush(skia::SkColorToCOLORREF(background_color)); + ULONG_PTR previous_brush = SetClassLongPtr( + GetAcceleratedWidget(), GCLP_HBRBACKGROUND, (LONG)brush); + if (previous_brush) + DeleteObject((HBRUSH)previous_brush); + // Save initial window state. if (fullscreen) last_window_state_ = ui::SHOW_STATE_FULLSCREEN;