gtk window transparency
I'm getting a bit confused with this. The goal is to create a window so that when you pack things into it, the window itself is translucent, but the widgets in the window are not (unless that thing is an image with an alpha channel). I'm writing in gtkmm, but if anyone knows the answer in any other port of gtk, I can translate that back.
I thought Gtk::Window::set_opacity() was supposed to do this, but on my machine it does absolutely nothing (and yes, I'm running a compositing manager. I've got awn and screenlets running while I test, so I know it works) Gdk::Display::supports_composite() is returning true on the display. I found some other techniques that involved drawing on the windows Gdk::Window, but I think that those were pseudo-transparency hacks. I want to work with compositing. |
What value are you passing in to set_opacity()? Stupid question, I know, but I thought I'd ask =D
|
Is your compositing manager running?
Following snippet works for me after I set "Visual Effects" to "Normal" or "Extra" in the appearance preferences ("System" -> "Preferences" -> "Appearance" -> "Visual Effects") [Ubuntu]. Code:
#include <gtk/gtk.h> |
@rocket357: I've tried 0, 1, and .5. No difference between them.
@ne_pas: The compositing manager is running. A 'ps -A' shows xcompmgr and both awn and screenlets are running with transparency. So this means that gtk_window_set_opacity should work, it's just not on my machine? I'll give it another shot and reply. |
Interesting. Your example code runs, but still gives me an opaque window. Just to clarify, I'm using openbox and xcompmgr. Hrm, I'll try again in Gnome and report back.
|
Well, the exact same code behaves as expected on Metacity with compositing or on Compiz. I guess that probably makes this an xcompmgr bug.
|
Hrm, well perhaps set_opacity isn't what I want. set_opacity() is also controlling the opacity of the widgets. For example, I create a transparent window, then pack a GtkLabel into it - the Label gets transparent with the window. Is there some other way of doing this?
|
That's not a real bug of xcompmgr - xcompmgr is just rather old and was only meant to be a small design study to show that compositing works.
The difference is as far as I know that xcompmgr does not use the GLX_blahbla_whatever_pixmap thingie function Open GL compositing stuff as Compiz, metacity and Xfce uses. (Didn't exist at the time, xcompmgr seems to speak more directly with the graphic's layer...) The appropriate test from within Gtk wether or not transparency / compositing is supported seems to depend exactly on this - that's why for example _some_ (not all) Cairo-based transparent gadgets like cairo clock or screenlets do not work. And: If you need per-widget transparency within a Gtk app, you'll need an engine actually supporting this. There is none right now but the most recent SVN/CVS stuff of "murrine", the fancy Cairo-based Gtk-engine. And I maybe totally wrong - it's really no fun to google in-depth information about all the transparency compositing gui widget foobar. So, in short: Just use a more contemporary compositing manager. There's also a cairo-based one, but it depends on some Gnome stuff. Addition: The combination of metisse and nucleo doesn't work either with most Gtk-stuff - the compositing mechanism is just not recognized. |
Quote:
i am using fedora9 i run this program in my machine.. it is not working for me. not showing any transaparency. may i know the reasons for this. and how can i overcome this problem any help thanks inhand |
I hacked some stuff together for per-widget transparency, from various sources, it works at least with compiz and xcompmgr (never used bevor). My metacity (GNOME 2.20) has no build-in support for compositing, so although it has alpha-channel support, alpha will not be honored (see GdkScreen - gdk_screen_get_rgba_colormap).
gtk_transparent_window.c Code:
#include <gtk/gtk.h> |
Quote:
|
Background image with alpha
Quote:
Code:
#include <gtk/gtk.h> Patrick |
I've done stuff like that before, and I found it much easier to use a shaped window instead of transparency. Look at gdk_window_shape_combine_mask, that's probably what you want.
|
All times are GMT -5. The time now is 08:17 PM. |