[webkit-gtk] webkit2 missing webkit_web_view_set_transparent ?

Jérémy Lal kapouer at melix.org
Mon Dec 29 01:52:33 PST 2014


Le lundi 29 décembre 2014 à 10:32 +0100, Carlos Garcia Campos a écrit :
> El dom, 21-12-2014 a las 02:42 +0100, Jérémy Lal escribió:
> > Hi,
> > 
> > webkit_web_view_set_transparent has disappeared from webkit2gtk's API.
> Well, something that doesn't exist can't disappear :-)
> webkit_web_view_set_transparent is in the WebKit1 API, but it's never
> been in WebKit2 API, so it's not that it has been removed, but never
> implemented.
> > Is there another way to achieve the same effect ?
> It should be very easy to expose that in the WebKit2 API. What's exactly
> your use case? I didn't even know that function existed in WebKit1 :-P
> and I find it a bit confusing, it sounds like you can make a web view
> transparent, when it's actually referring to the background color. 
> Looking at WebPageProxy I see at least 3 methods related to the
> background and transparency:
>   - WebPageProxy::setDrawsBackground(): This ends up calling
> FrameView::setTransparent() for every frame. It seems that when this is
> set to true the document or base background color is ignored.
> webkit_web_view_set_transparent() in WebKit1 calls
> FrameView::setTransparent() for the main frame only.
>   - WebPageProxy::setDrawsTransparentBackground(): This calls
> FrameView::setBaseBackgroundColor() for every frame. It sets the color
> to Transparent when the called with true and White when called with
> false. Surprisingly this is not what webkit_web_view_set_transparent()
> does. Also, it seems that setDrawsBackground(false) is not exactly the
> same as setDrawsTransparentBackground(true). When the frame view is set
> transparent the background color is ignored and setCannotBlitToWindow()
> is called, but when the background color is set to transparent, it's
> used unless backgroundShouldExtendBeyondPage setting is true, in which
> case the document background color is used.
>   - WebPageProxy::setBackgroundExtendsBeyondPage: And this one sets the
> backgroundShouldExtendBeyondPage setting.
> Also, other ports have methods to set a background color for the backing
> store. 
> So, I find all this a bit messy. Exposing these methods in our API is
> easy, but first we need to understand what all those methods do, and
> what we want to expose and how.

Two usages:
- Let's imagine webkitgtk is used to show custom html widgets on a
desktop environment, in a borderless and transparent gtk window (like
widgets in dashboard).
- Another usage would be when webkitgtk is used as a scriptable html
rendering engine (to render graphs for example) - it is useful to be
able to output a transparent png from a snapshot.

Currently, if i set a rgba visual and a transparent background using gtk
methods to the window and the WebView widget, and if the webview itself
has a background:transparent (or background-color: rgba(0,0,0,0)) set on
html, body nodes, there is still a white background painted before the
webview gtkwidget (if i don't draw the webview, the window is

Some basic code to reproduce an example

// given a GtkWindow *window and a WebView *view
gtk_widget_set_app_paintable(window, TRUE); // not sure this is needed
const GdkRGBA color = {.0, .0, .0, .0};
// set rgba visual - also requires a compositing window manager
GdkScreen *screen = gtk_widget_get_screen(window);
GdkVisual *visual = gdk_screen_get_rgba_visual(screen);
gtk_widget_set_visual(window, visual);
gtk_widget_set_visual(GTK_WIDGET(view), visual);

// these looks useless
gtk_widget_override_background_color(window, GTK_STATE_FLAG_NORMAL,

gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view));


More information about the webkit-gtk mailing list