Tell the render widget to use transparent background.
This commit is contained in:
parent
9593c71f52
commit
4fc73117c4
2 changed files with 27 additions and 0 deletions
|
@ -32,6 +32,7 @@
|
||||||
#include "brightray/browser/inspectable_web_contents_view.h"
|
#include "brightray/browser/inspectable_web_contents_view.h"
|
||||||
#include "chrome/browser/printing/print_view_manager_basic.h"
|
#include "chrome/browser/printing/print_view_manager_basic.h"
|
||||||
#include "chrome/browser/ui/browser_dialogs.h"
|
#include "chrome/browser/ui/browser_dialogs.h"
|
||||||
|
#include "content/browser/renderer_host/render_widget_host_impl.h"
|
||||||
#include "content/public/browser/devtools_agent_host.h"
|
#include "content/public/browser/devtools_agent_host.h"
|
||||||
#include "content/public/browser/invalidate_type.h"
|
#include "content/public/browser/invalidate_type.h"
|
||||||
#include "content/public/browser/navigation_entry.h"
|
#include "content/public/browser/navigation_entry.h"
|
||||||
|
@ -60,6 +61,10 @@ using content::NavigationEntry;
|
||||||
using content::RenderWidgetHostView;
|
using content::RenderWidgetHostView;
|
||||||
using content::RenderWidgetHost;
|
using content::RenderWidgetHost;
|
||||||
|
|
||||||
|
namespace content {
|
||||||
|
CONTENT_EXPORT extern bool g_use_transparent_window;
|
||||||
|
}
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -88,6 +93,7 @@ NativeWindow::NativeWindow(content::WebContents* web_contents,
|
||||||
const mate::Dictionary& options)
|
const mate::Dictionary& options)
|
||||||
: content::WebContentsObserver(web_contents),
|
: content::WebContentsObserver(web_contents),
|
||||||
has_frame_(true),
|
has_frame_(true),
|
||||||
|
transparent_(false),
|
||||||
enable_larger_than_screen_(false),
|
enable_larger_than_screen_(false),
|
||||||
is_closed_(false),
|
is_closed_(false),
|
||||||
node_integration_(true),
|
node_integration_(true),
|
||||||
|
@ -99,9 +105,14 @@ NativeWindow::NativeWindow(content::WebContents* web_contents,
|
||||||
printing::PrintViewManagerBasic::CreateForWebContents(web_contents);
|
printing::PrintViewManagerBasic::CreateForWebContents(web_contents);
|
||||||
|
|
||||||
options.Get(switches::kFrame, &has_frame_);
|
options.Get(switches::kFrame, &has_frame_);
|
||||||
|
options.Get(switches::kTransparent, &transparent_);
|
||||||
options.Get(switches::kEnableLargerThanScreen, &enable_larger_than_screen_);
|
options.Get(switches::kEnableLargerThanScreen, &enable_larger_than_screen_);
|
||||||
options.Get(switches::kNodeIntegration, &node_integration_);
|
options.Get(switches::kNodeIntegration, &node_integration_);
|
||||||
|
|
||||||
|
// Tell the content module to initialize renderer widget with transparent
|
||||||
|
// mode.
|
||||||
|
content::g_use_transparent_window = transparent_;
|
||||||
|
|
||||||
// Read icon before window is created.
|
// Read icon before window is created.
|
||||||
options.Get(switches::kIcon, &icon_);
|
options.Get(switches::kIcon, &icon_);
|
||||||
|
|
||||||
|
@ -560,6 +571,18 @@ content::JavaScriptDialogManager* NativeWindow::GetJavaScriptDialogManager() {
|
||||||
return dialog_manager_.get();
|
return dialog_manager_.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NativeWindow::RenderViewCreated(
|
||||||
|
content::RenderViewHost* render_view_host) {
|
||||||
|
if (!transparent_)
|
||||||
|
return;
|
||||||
|
|
||||||
|
content::RenderWidgetHostImpl* impl = content::RenderWidgetHostImpl::FromID(
|
||||||
|
render_view_host->GetProcess()->GetID(),
|
||||||
|
render_view_host->GetRoutingID());
|
||||||
|
if (impl)
|
||||||
|
impl->SetBackgroundOpaque(false);
|
||||||
|
}
|
||||||
|
|
||||||
void NativeWindow::BeforeUnloadFired(content::WebContents* tab,
|
void NativeWindow::BeforeUnloadFired(content::WebContents* tab,
|
||||||
bool proceed,
|
bool proceed,
|
||||||
bool* proceed_to_fire_unload) {
|
bool* proceed_to_fire_unload) {
|
||||||
|
|
|
@ -269,6 +269,7 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
|
||||||
void RendererResponsive(content::WebContents* source) override;
|
void RendererResponsive(content::WebContents* source) override;
|
||||||
|
|
||||||
// Implementations of content::WebContentsObserver.
|
// Implementations of content::WebContentsObserver.
|
||||||
|
void RenderViewCreated(content::RenderViewHost* render_view_host) override;
|
||||||
void BeforeUnloadFired(const base::TimeTicks& proceed_time) override;
|
void BeforeUnloadFired(const base::TimeTicks& proceed_time) override;
|
||||||
bool OnMessageReceived(const IPC::Message& message) override;
|
bool OnMessageReceived(const IPC::Message& message) override;
|
||||||
|
|
||||||
|
@ -287,6 +288,9 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
|
||||||
// Whether window has standard frame.
|
// Whether window has standard frame.
|
||||||
bool has_frame_;
|
bool has_frame_;
|
||||||
|
|
||||||
|
// Whether window is transparent.
|
||||||
|
bool transparent_;
|
||||||
|
|
||||||
// Whether window can be resized larger than screen.
|
// Whether window can be resized larger than screen.
|
||||||
bool enable_larger_than_screen_;
|
bool enable_larger_than_screen_;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue