Translucent widgets on X11

Posted by sroedal on September 23, 2008 · 9 comments

When running an X11 compositing manager it’s possible to have translucent widgets by using 32 bit visuals, also known as ARGB visuals. We don’t use these visuals by default in Qt because we’ve seen some driver issues which cause buggy rendering and widgets containing garbage pixels when first being shown, as well as generic slow-downs in some cases. However, we’re now adding conditional ARGB visuals to top-level widgets that are non-opaque, i.e. either have the Qt::WA_NoSystemBackground attribute set or have a transparent or semi-transparent background color specified in the palette. This means that the ARGB visuals will be opt-in instead of being forced onto every Qt application.

What this all means that in 4.5 you’ll be able to have nice translucent Qt widgets on your Linux desktop without any hassle, as long as you have a compositing manager running (which should be easy to enable on newer distributions). Of course, this wouldn’t be a proper graphics dojo post without a nice and shiny example, so I’ve cooked up an example which puts some nice chrome buttons inside a graphics view, and does a fancy animation when you click on the buttons. Here’s a screenshot:

Translucent widget example

Translucent widget video capture

To play with the source and try the example out for yourself, do “svn checkout svn://labs.trolltech.com/svn/graphics/dojo/glossygradients”. You’ll have to wait for the snapshots to be back online to get the translucency effect though :)

QShare(this)

Possibly related posts:

  1. Alien widgets on Mac
  2. Qt for Maemo 5 home screen widgets

9 comments

1 Robin September 23, 2008 at 8:06 pm
 

Nice! Just a note regarding the video. You should no longer use the “ogg” extension for video files, “ogv” is recommended for that now: http://wiki.xiph.org/MIME_Types_and_File_Extensions

3 Andrea September 24, 2008 at 12:40 am
 

Really nice! Is something like that possible also on Macs, I mean nice non rectangular widgets. I tried with a mask, but it looks ugly like … the clock :-)

4 trenton September 24, 2008 at 9:43 am
 

It should work on Mac OS X, but we haven’t implemented it. I guess we were trying to keep the experience cross-platform. It really isn’t that difficult though, so we’ll see if we can’t get this fixed up shortly.

5 David B September 24, 2008 at 3:08 pm
 

Very nice. I am anxious to see what is happening with respect to Animation. I was reading about Mamo’s use of Clutter, which is GTK’s animated desktop. There was a nice demo of it at http://arstechnica.com/news.ars/post/20080924-nokia-will-bring-bling-and-finger-friendliness-to-maemo-5.html.

I hope QT can match the animated user experience as shown in this GTK demo.

6 Scorp1us September 24, 2008 at 7:25 pm
 

Any hope for this on Win32?

7 Bjørn Lindeijer September 25, 2008 at 1:11 pm
 

I like the example, however it doesn’t run very smoothly. After reading the QTimeLine docs though, this is simply because its default update interval is 40 ms, leading to just 25 frames per second. Inserting the following line after its construction makes the example run nice and smooth (50 fps, in theory):

m_rotation->setUpdateInterval(20);

8 sroedal September 25, 2008 at 5:29 pm
 

Scorp1us: We’re planning to support this on Windows too, though I can’t say exactly when it will be implemented.

Bjørn: Thanks, I changed the example to include your suggestion. It certainly feels smoother now :)

9 pettersolberg September 26, 2008 at 10:42 am
 

Are you using VIM there?
Is it right?
Restecpa :)

Comments on this entry are closed.

Previous post:

Next post: