The only modifications needed for CEF are (3 lines of code):
- Code: Select all
bool DesktopWindowTreeHostWin::ShouldWindowContentsBeTransparent() const {
// but merely of the content Chrome draws, so even when the system titlebars
// appear opaque (Win 8+), the content above them needs to be transparent, or
// they'll be covered by a black (undrawn) region.
return true; // instead of return ShouldUseNativeFrame() && !IsFullscreen();
}
SkColor CefContext::GetBackgroundColor(
const CefBrowserSettings* browser_settings,
cef_state_t windowless_state) const {
{
return SK_ColorTRANSPARENT; // Enforces transparent background color
}
void CefWindowDelegateView::Init(gfx::AcceleratedWidget parent_widget,
content::WebContents* web_contents,
const gfx::Rect& bounds) {
[...]
params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; // instead of views::Widget::InitParams::OPAQUE_WINDOW
[...]
}
This modifications force the transparent window mode, but I can easily introduce a setting configuration in CefWindowInfo, something like CefWindowInfo::SetAsChild(parent, windowRect, bool transparentOverlay);
It's responsibility of the client code (who creates the parent window) to maintain the CEF window over the parent one and resize it to match the position and size of both windows.
When creating CEF, in Windows (Vista and above) you have to do:
- Code: Select all
CefWindowInfo window_info;
window_info.SetAsPopup(parentWnd, "CEF");
window_info.ex_style |= WS_EX_COMPOSITED;
In linux you have to create a parent XWindow that supoorts alpha channel, see https://stackoverflow.com/questions/4052940/how-to-make-an-opengl-rendering-context-with-transparent-background and https://github.com/datenwolf/codesamples/blob/master/samples/OpenGL/x11argb_opengl/x11argb_opengl.c.
If you think that this can be useful, and can be included in the base code of CEF, I can prepare a patch for any version you want.