[dev] [surf] background window color

From: Markus Teich <markus.teich_AT_stusta.mhn.de>
Date: Sat, 21 Nov 2015 18:35:39 +0100


a little annoyance, that bugged me for quite a while is that you get a short
white "flash" when changing between different tabbed clients running surf. This
is mostly only visible when both websites have a dark background. I tested it
and I can "fix" it for these cases with the following lines:

    GdkColor bla = {0,0,0,0};
    gdk_window_set_background(GTK_WIDGET(c->win)->window, &bla);

This effectively sets the XWindows background to black. Now for bright websites
its obviously counterproductive, so my plan was to set the XWindow background
color to the same color used for the <body> tag of the website displayed.
I tried two methods to get this color from webkit, but both failed (returning an
empty string). If you know, how to extract this value from webkit, please let me
know. It should of course also work with custom stylesheets, so basically it
should return the "background-color" value of the "computed" style of the <body>
tag from the inspector.

Here are the two approaches I tried (I put them into the keypress function to
test it on demand during or after pageload has finished):

    WebKitDOMDocument *doc;
    WebKitDOMElement *body;
    WebKitDOMCSSStyleDeclaration *stil;
    gchar *color;
    if ((doc = webkit_web_view_get_dom_document(c->view))
        && (body = webkit_dom_document_query_selector(doc, "body", NULL))
        && (stil = webkit_dom_element_get_style(body))
        && (color = webkit_dom_css_style_declaration_get_property_value(stil, "background-color")))

    WebKitDOMDocument *doc;
    WebKitDOMHTMLBodyElement *body;
    WebKitDOMCSSStyleDeclaration *stil;
    gchar *color;
    if ((doc = webkit_web_view_get_dom_document(c->view))
        && (body = (WebKitDOMHTMLBodyElement*)webkit_dom_document_get_body(doc))
        && (color = webkit_dom_html_body_element_get_background(body)))

Received on Sat Nov 21 2015 - 18:35:39 CET

This archive was generated by hypermail 2.3.0 : Sat Nov 21 2015 - 18:36:09 CET