From 7d4ff3b06195bfa5ff134cc91dbcbe846bbfee48 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 6 Mar 2018 13:47:21 +0900 Subject: [PATCH] mac: Call SetBackgroundOpaque in BrowserWindow --- atom/browser/api/atom_api_browser_window.cc | 11 ++++++++++- atom/browser/native_window_mac.h | 2 -- atom/browser/native_window_mac.mm | 21 --------------------- 3 files changed, 10 insertions(+), 24 deletions(-) diff --git a/atom/browser/api/atom_api_browser_window.cc b/atom/browser/api/atom_api_browser_window.cc index 09cf078a24c9..8294dc1de62e 100644 --- a/atom/browser/api/atom_api_browser_window.cc +++ b/atom/browser/api/atom_api_browser_window.cc @@ -1116,8 +1116,17 @@ void BrowserWindow::AddTabbedWindow(NativeWindow* window, void BrowserWindow::SetVibrancy(mate::Arguments* args) { std::string type; - args->GetNext(&type); + + auto* render_view_host = web_contents()->GetRenderViewHost(); + if (render_view_host) { + auto* impl = content::RenderWidgetHostImpl::FromID( + render_view_host->GetProcess()->GetID(), + render_view_host->GetRoutingID()); + if (impl) + impl->SetBackgroundOpaque(type.empty() ? !window_->transparent() : false); + } + window_->SetVibrancy(type); } diff --git a/atom/browser/native_window_mac.h b/atom/browser/native_window_mac.h index 84ad0ba53ca4..aa47ca07b3bc 100644 --- a/atom/browser/native_window_mac.h +++ b/atom/browser/native_window_mac.h @@ -154,8 +154,6 @@ class NativeWindowMac : public NativeWindow { void InstallView(); void UninstallView(); - void SetRenderWidgetHostOpaque(bool opaque); - base::scoped_nsobject window_; base::scoped_nsobject window_delegate_; diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index 08b1a917d138..de1303a2610a 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -20,12 +20,7 @@ #include "brightray/browser/inspectable_web_contents.h" #include "brightray/browser/inspectable_web_contents_view.h" #include "brightray/browser/mac/event_dispatching_window.h" -#include "content/browser/renderer_host/render_widget_host_impl.h" #include "content/public/browser/browser_accessibility_state.h" -#include "content/public/browser/render_process_host.h" -#include "content/public/browser/render_view_host.h" -#include "content/public/browser/render_widget_host_view.h" -#include "content/public/browser/web_contents.h" #include "native_mate/dictionary.h" #include "skia/ext/skia_utils_mac.h" #include "third_party/skia/include/core/SkRegion.h" @@ -1652,20 +1647,6 @@ bool NativeWindowMac::AddTabbedWindow(NativeWindow* window) { return true; } -void NativeWindowMac::SetRenderWidgetHostOpaque(bool opaque) { - if (!web_contents()) return; - - auto render_view_host = web_contents()->GetRenderViewHost(); - if (!render_view_host) return; - - content::RenderWidgetHostImpl* impl = content::RenderWidgetHostImpl::FromID( - render_view_host->GetProcess()->GetID(), - render_view_host->GetRoutingID()); - if (!impl) return; - - impl->SetBackgroundOpaque(opaque); -} - void NativeWindowMac::SetVibrancy(const std::string& type) { if (!base::mac::IsAtLeastOS10_10()) return; @@ -1676,7 +1657,6 @@ void NativeWindowMac::SetVibrancy(const std::string& type) { [window_ setBackgroundColor:background_color_before_vibrancy_]; [window_ setTitlebarAppearsTransparent:transparency_before_vibrancy_]; } - SetRenderWidgetHostOpaque(!transparent()); if (vibrant_view == nil) return; [vibrant_view removeFromSuperview]; @@ -1685,7 +1665,6 @@ void NativeWindowMac::SetVibrancy(const std::string& type) { return; } - SetRenderWidgetHostOpaque(false); background_color_before_vibrancy_.reset([window_ backgroundColor]); transparency_before_vibrancy_ = [window_ titlebarAppearsTransparent];