GTK+ theme translucency

Monday 14 January, 2008 @ 19:55

Translucency in GTK+ theme engines, as presented by a Murrine developer, is really nothing special. In fact, it’s overhyped. (Blog posts, news articles, etc.) It’s been around since day one when GDK implemented RGBA visual and Cairo support.

Here’s the Mist engine with a translucent background:
Screenshot of a translucent Mist engine.

The big problem is, and Cimi’s blog post does mention this: it needs application support. The theme engine can easily detect and perform drawing with translucency, but it’s up to the application to actually enable it. One way to do this is using a snippit of code like this, after gtk_init and before any windows are created:

 GdkDisplay* display = gdk_display_get_default ();
 gint nscreens = gdk_display_get_n_screens (display);
 for (gint i = 0; i < nscreens; i++)
 {
     GdkScreen* screen = gdk_display_get_screen (display, i);
     GdkColormap* rgbamap = gdk_screen_get_rgba_colormap (screen);
     if (rgbamap != NULL)
         gdk_screen_set_default_colormap (screen, rgbamap);
 }

Another way to do this, is to patch GTK+ itself to prefer RGBA surfaces over the trusty old RGB surfaces. Trusty, because RGBA still tends to break some applications, and probably some GTK+ custom widgets as well.

So to get translucency, either all applications need to be patched, or GTK+ needs to break compatibility. Patching all applications is a rather stupid option, if we have to do that anyways once GTK+ breaks compatibility. I say it’s about time for GTK+ 3.0. :P

Though I think it’s overhyped, I guess that it will end up to be a good thing. Maybe we will finally get a push for more of this great bling in GTK+.

By the way, here’s the patch against gtk-engines trunk for the above screenshot of translucent Mist:
http://stephan.kochen.nl/proj/gtk-translucent-mist.patch

0 Comments »

No comments yet.

Leave a comment

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.
(c) 2010 Shtééf | powered by WordPress with Barecity