|
@@ -21,7 +21,9 @@
|
|
|
#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"
|
|
@@ -1682,12 +1684,31 @@ void NativeWindowMac::AddTabbedWindow(NativeWindow* window) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+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;
|
|
|
|
|
|
NSView* vibrant_view = [window_ vibrantView];
|
|
|
|
|
|
if (type.empty()) {
|
|
|
+ if (background_color_before_vibrancy_) {
|
|
|
+ [window_ setBackgroundColor:background_color_before_vibrancy_];
|
|
|
+ [window_ setTitlebarAppearsTransparent:transparency_before_vibrancy_];
|
|
|
+ }
|
|
|
+ SetRenderWidgetHostOpaque(!transparent());
|
|
|
if (vibrant_view == nil) return;
|
|
|
|
|
|
[vibrant_view removeFromSuperview];
|
|
@@ -1696,6 +1717,13 @@ void NativeWindowMac::SetVibrancy(const std::string& type) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ SetRenderWidgetHostOpaque(false);
|
|
|
+ background_color_before_vibrancy_.reset([window_ backgroundColor]);
|
|
|
+ transparency_before_vibrancy_ = [window_ titlebarAppearsTransparent];
|
|
|
+
|
|
|
+ [window_ setTitlebarAppearsTransparent:YES];
|
|
|
+ [window_ setBackgroundColor:[NSColor clearColor]];
|
|
|
+
|
|
|
NSVisualEffectView* effect_view = (NSVisualEffectView*)vibrant_view;
|
|
|
if (effect_view == nil) {
|
|
|
effect_view = [[[NSVisualEffectView alloc]
|