fix: vibrant window should have transparent background (#31493)

This commit is contained in:
Shelley Vohr 2021-10-21 21:53:52 +02:00 committed by GitHub
parent 40a8e4fb58
commit 1d0f94f6b3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -37,14 +37,22 @@ BrowserWindow::BrowserWindow(gin::Arguments* args,
gin::Dictionary::CreateEmpty(isolate); gin::Dictionary::CreateEmpty(isolate);
options.Get(options::kWebPreferences, &web_preferences); options.Get(options::kWebPreferences, &web_preferences);
// Copy the backgroundColor to webContents.
v8::Local<v8::Value> value; v8::Local<v8::Value> value;
bool transparent = false; bool transparent = false;
options.Get(options::kTransparent, &transparent);
std::string vibrancy_type;
#if defined(OS_MAC)
options.Get(options::kVibrancyType, &vibrancy_type);
#endif
// Copy the backgroundColor to webContents.
if (options.Get(options::kBackgroundColor, &value)) { if (options.Get(options::kBackgroundColor, &value)) {
web_preferences.SetHidden(options::kBackgroundColor, value); web_preferences.SetHidden(options::kBackgroundColor, value);
} else if (options.Get(options::kTransparent, &transparent) && transparent) { } else if (!vibrancy_type.empty() || transparent) {
// If the BrowserWindow is transparent, also propagate transparency to the // If the BrowserWindow is transparent or a vibrancy type has been set,
// WebContents unless a separate backgroundColor has been set. // also propagate transparency to the WebContents unless a separate
// backgroundColor has been set.
web_preferences.SetHidden(options::kBackgroundColor, web_preferences.SetHidden(options::kBackgroundColor,
ToRGBAHex(SK_ColorTRANSPARENT)); ToRGBAHex(SK_ColorTRANSPARENT));
} }