<div dir="ltr"><br><div class="gmail_quote"><div dir="ltr">I build webkitgtk 1.9.92 by below configuration<br>./configure --prefix=/usr --enable-accelerated-compositing --enable-fast-mobile-scrolling --enable-jit --disable-webkit2 --disable-plugin-process --disable-gtk-doc-html --with-gtk=2.0 --with-acceleration-backend=opengl<br>
<br>After that, I write a simple app to make the content of webview transparent by calling webkit_web_view_set_transparent(). But it failed. <br>I tryied version 1.11.5, it also does not work.<br>The same app source code works in a old version of gtk-webkit, AFAIK, it was about gtk-webkit 1.3.<br>
<br>Why I want to a build a new version of gtk-webkit, is to use the compositing accelerating feature.<br><br>Anyone know something about this problem?<br><br>The test code is here:<br>-----------app code---------<br>#include <gtk/gtk.h><br>
#include <gdk/gdkx.h><br>#include <webkit/webkit.h><br>#include <stdlib.h><br>#include <string.h><br>static void destroy_cb(GtkWidget* widget, gpointer data) {<br> gtk_main_quit();<br>}<br><br>
bool transparent = true;<br>
bool decorate = false;<br>int width = 800;<br>int height = 480;<br>gchar * url = "/home/meego/httproot/htdocs/hmi/hmi/index.html";<br>char *window_name = "HMI";<br>WebKitWebView* view;<br>GdkColormap* rgba;<br>
GdkScreen* screen;<br><br>gint key_press_cb(GtkWidget *widget, GdkEventKey *kevent, gpointer data) {<br> GtkWidget *btn = (GtkWidget *)data;<br><br> if(kevent->type == GDK_KEY_PRESS && kevent->keyval == 'p') {<br>
<br> GdkPixbuf * pixbuf;<br> pixbuf = gdk_pixbuf_get_from_drawable( NULL, GTK_WIDGET(view)->window, rgba, 0, 0, 0, 0, 600, 400 );<br> gdk_pixbuf_save(pixbuf, "/home/meego/dump.png", "png", NULL, NULL);<br>
printf("colormap is %s\n", rgba ? "not NULL" : "NULL");<br> printf("screen %s compoisted\n", gdk_screen_is_composited(screen)? "is" : "is not");<br>
printf("webview %s transparent\n", webkit_web_view_get_transparent(view) ? "is" : "is not");<br> }<br> return TRUE;<br>}<br><br>static gboolean window_delete_event(GtkWidget *widget, GdkEvent *event, gpointer user_data)<br>
{<br> gtk_widget_destroy(widget);<br> gtk_main_quit();<br> return TRUE;<br>}<br><br>int main(int argc, char* argv[]) {<br> int ret;<br><br> if(argc >= 2) {<br> url = argv[1];<br> }<br> gtk_init(&argc, &argv);<br>
<br> // Create a Window, set colormap to RGBA<br> GtkWidget* window = gtk_window_new(GTK_WINDOW_TOPLEVEL);<br> screen = gtk_widget_get_screen(window);<br> rgba = gdk_screen_get_rgba_colormap (screen);<br><br>
gtk_window_set_title(GTK_WINDOW(window), (const gchar*)window_name);<br>
if (rgba && gdk_screen_is_composited (screen)) {<br> gtk_widget_set_default_colormap(rgba);<br> gtk_widget_set_colormap(GTK_WIDGET(window), rgba);<br> }<br><br> gtk_widget_set_size_request(window, width, height);<br>
<br> if(!decorate)<br> {<br> gtk_window_set_decorated(GTK_WINDOW(window), FALSE);<br> }<br><br> view = WEBKIT_WEB_VIEW(webkit_web_view_new());<br> gtk_widget_set_colormap(GTK_WIDGET(view), rgba);<br>
if(transparent) {<br> if(gdk_screen_is_composited(screen)) {<br> printf("set transparent\n");<br> webkit_web_view_set_transparent(view, TRUE);<br> }<br> }<br><br> WebKitWebSettings *settings = webkit_web_settings_new();<br>
<br> if(NULL == settings) {<br> return -1;<br> } else {<br> g_object_set (G_OBJECT(settings), "enable-file-access-from-file-uris", TRUE, NULL);<br> g_object_set (G_OBJECT(settings), "enable-default-context-menu", FALSE, NULL);<br>
webkit_web_view_set_settings (WEBKIT_WEB_VIEW(view), settings);<br> }<br> gtk_container_add (GTK_CONTAINER(window), GTK_WIDGET(view));<br><br><br> g_signal_connect(window, "delete-event", G_CALLBACK(window_delete_event), NULL);<br>
g_signal_connect(window, "destroy", G_CALLBACK(destroy_cb), NULL);<br><br> g_signal_connect(G_OBJECT(window), "key_press_event", G_CALLBACK(key_press_cb), window);<br> //g_signal_emit_by_name(G_OBJECT(window), "activate", NULL);<br>
<br> // Load a default page<br> if (g_str_has_prefix(url, "http://")<br> || g_str_has_prefix(url, "https://")<br> || g_str_has_prefix(url, "file://"))<br> {<br>
webkit_web_view_open(WEBKIT_WEB_VIEW(view), url);<br> } else {<br> gchar *t_url = NULL;<br> if (g_path_is_absolute(url)) {<br> t_url = g_strjoin("", "file://", url, NULL);<br>
} else {<br> gchar *pwd = g_get_current_dir();<br> t_url = g_strjoin("/", "file://", pwd, url, NULL);<br> g_free(pwd);<br> }<br> webkit_web_view_open(WEBKIT_WEB_VIEW(view), t_url);<br>
g_free(t_url);<br> }<br><br> gtk_widget_show_all(window);<br> gtk_main();<br> return 0;<br>}<br><br><br>-----------html code-----------<br><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "<a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" target="_blank">http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd</a>"><br>
<html xmlns="<a href="http://www.w3.org/1999/xhtml" target="_blank">http://www.w3.org/1999/xhtml</a>"><head><br><meta http-equiv="content-type" content="text/html; charset=UTF-8"><br>
<title>Transparency Test</title><br>
<style type="text/css"><br> /*<![CDATA[*/<br> body { background: rgba(220, 220, 0, .5); }<br> /*]]>*/<br> </style><br></head><br><body><br> <p><br> Text on a yellowish, semi-transparent background.<br>
</p><br><br><br></body></html><br><br><br><br><br></div>
</div><br></div>