We are currently working on developing a GTK application, in GJS, and want to display videos with a WebView layered on top of the video. We are able to open a window and display videos using GStreamer and open a sperate window and display a WebView using WebKit2 from WebkitGTK+.
The GStreamer window is a DrawingArea inside of an ApplicationWindow. The WebView is a WebView inside of an ApplicationWindow. The WebView window is set to always be on top of the video, but has a white background so we cannot see through the webview to the video below.
We would like to change the opacity of the window displaying the Webview to make the background completely transparent, while keeping the contents of what is being displayed in the WebView. We are able to set the document of the WebView background to be completely transparent. Is there a way to make an ApplicationWindow and WebView background transparent in GTK?
I've tried using the CSSProperties, but this did not seem to affect the window opacity.
Hi i also needed a transparent Gtk window.
You say you use CSS and it didnt work, i also thought CSS is not working correct in GTK 3 (3.24.33), because some of my CSS Rules didnt effect the widgets, til i recognized, it was my fault paying to less attention to the priority parameter of the "add_provider" instance method of "Gtk.StyleContext" class.
i always used 0 for priority
widget.get_style_context().add_provider (cssProvider, 0);but you have to set high priority values, to make it work.use:
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION - has a value of 600
Gtk.STYLE_PROVIDER_PRIORITY_USER - has a value of 800
here my code for a window with alpha channel in GTK (3.24.33)
but the real problem is - how to let the events pass through the window, where the window is transparent, because it is still there and catches all events.
I tried "set_pass_through" method, but didnt work.
I tried constructing a new Gdk.Event but i cant set the values like coords, root_coords and window, and so on. There are only get methods no set methods.
The only thing worked is catching the event in the window and send it unchanged to a defined receiver window (can be below or where ever), using low level function "Gtk.propagate_event"
But that means only the root coords of the event are correct and you have to manage the event propagation inside the receiver window by checking all the allocations of the child widgets, if they are under pointer and then fire on them!