Adventures in Compositation Land

As Thomas said, I’ve been working on hacking about with a compositor in Metacity recently. All I’ve really done is to take xcompmgr.c by Keith Packard and worked it into Metacity, so I’m not claiming that I really wrote the compositor, more massaged an already existing one into shape. The code is at http://svn.gnome.org/viewvc/metacity/branches/iains-blingtastic-bucket-o-bling/ and it seems to work reasonably well on my desktop (Nvidia), but not so well on the laptop (Intel), so you might be lucky. Its not perfectly stable, but I’ll track down the problems soon I’m sure. Everyone loves a screenshot:

With that out of the way, I thought I’d explain a little about compositing and what my plans are.

What is compositing anyway?

When people talk about compositing they seem to think about vibbly vindows, desktops laid out hendecagonally which spin around, fish swimming behind windows and eating windows and other stupid effects who’s only purpose is for you to play with in conferences so the people sitting behind you have something to watch instead of listen to the boring talk. These are all things made possible due to compositing, but they are byproducts if you will. You can only have the effects if you have compositing, but you don’t have to have the effects to have compositing. And it is this barebones compositor I’ve put into Metacity.

Compositing at its simplest is a program telling the Xserver not to draw the windows anymore because the program wants to do it instead. So now X doesn’t draw the window to the screen, but to a backing store pixmap which the compositor program then draws on the screen. It makes sense for this compositing program to be the window manager, because it already knows all about screens and displays and what window goes where when. . . etc, but it does not need to be (e.g. xcompmgr).

The trick is that when the compositor comes to draw the window’s backing pixmap to the screen it can really do whatever it wants with it. It can paint it backwards, or with a red tint, or just simply paint it normally to the screen. Compositors like Compiz draw the window onto GL textures and then are able to do 3D transforms on them. The compositor in Metacity just draws it to the screen using the XRender extension.

What can we do with a plain compositor?

Well, just because the windows aren’t rendered into a 3D scene doesn’t mean it isn’t useful. Metacity was a designed as a simple window manager that concentrated on managing windows well. Its design ethos doesn’t stretch to being configured in every minute detail. And in my opinion, a simple compositor based on XRender fits in well. Most people I have spoken to want two things from a compositor. They want translucent windows[1] and drop shadows.

What does the future hold?

All metacity’s compositor needs to do is draw windows to the screen and draw a drop shadow around them, and I think its doing that pretty well at the moment. There are some rendering glitches (mostly in dealing withTrans windows) and some crashes, but it is getting there. There are a few other things that the compositor could do but most of the usefulness of a compositor comes from when the programs running on the desktop start to become aware of the compositor’s presence. In the above screenshot the volume control OSD changes design when there is a compositor and draws itself in a translucent design and can fade in and out. The gnome-terminal switches to real transluceny when running on a composited desktop. I have a patch for Metacity that turns the alt-tab dialog translucent with a compositor

Metacity could use the presence of a compositor to do other tricks as well…the icons in the alt-tab dialog could be replaced with window previews (because we can get the backing store pixmap to use anywhere we want), Nautilus’ desktop could be completely transparent meaning we could stop having to draw a huge image on both the desktop window and on the root window and the task switcher could show a popup of the real window. The list is endless. Maybe when I’m feeling up to it I’ll write a “So you want your application to look cool when a compositor is running” tutorial type affair. Maybe. I might be busy.

[1] There are two types of translucent windows: windows which have some area painted with an alpha value (an example of this would be a translucent gnome-terminal, only the text area has an alpha value), and windows that are normally completely opaque but have had their opacity lowered somehow. The former is controlled by the program for artistic measure, the latter is controlled outside of the program and more for an effect (e.g. lower the opacity of all dialog windows to 75%) as it affects all the elements of the window (as well as the frame).

Internally the first type are called ARGB windows, and the second type are Trans windows. Currently the Metacity compositor supports both, but there is no way to set the opacity of the Trans windows. There maybe at some point, who knows?

28 thoughts on “Adventures in Compositation Land”

  1. ‘Cos I don’t know much about this stuff…presumably this won’t require 3D acceleration for graphics cards, so it’ll work on cards that don’t have free software support for things like Compiz? That’d be great, if so…

  2. The main feature that I like from a compositor is the flicker free rendering of my screen.

    I find metacity more usable than compiz – especially the ALT-Tab application switcher.

    I’d love to see a flicker free metacity that functions how metacity currently does.

  3. Stuart: that’s right, you don’t need 2D acceleration. You will need decent RENDER performance though, which many drivers do lack.

  4. I am hoping to start talking about merging the branch after the next unstable release, which should happen tonight sometime. That will mean that if all goes well, Iain’s code will show up in an unstable point release within the next fortnight.

    (Looks from the trackbacks as though there’s a lot of interest in compositing Metacity in Italy.)

  5. Just a note I would like to add to the “wished compositing features”. Translucent windows looks cool, but are quite unusable, I think. What I wish most is a kind of fade in/fade out effect of all windows/dialogs/menus/whatever, when opening them, closing them, switching focus, …
    For me, this is more important than translucent windows and shadows.

  6. Sweet! Lately I’ve been using xfwm4 on my laptop because I wanted compositing but can’t get compiz running. (Didn’t think to try xcompmgr honestly). This is a much nicer solution since I won’t have to install the xfce settings manager to tweak the theme and settings.

  7. This is just to point out that flicker free desktopwide rendering is what I crave for in a compositor too, but I guess that that is a byproduct of the use of a compositor anyway.

    BTW, what happened to the compositor that Soren Sandmann worked on for a while on metacity? I think it was openGL based but seems to have been abandoned.

  8. Luis: I suppose improved alt-tab comes more into the “how other applications use a compositor” category. Translucency used correctly can be a nice subtle effect, but is used for artistic measures. On that front:

    a) I’m probably not the best to be creating the artistic measures (just look at how ugly that alt-tab box I made actually is…)
    b) It would be very nice to have a way in XRender to do fast gaussian blurs on part of the screen. That would allow us to blur the image below the translucent windows, which I think might help the usability of translucency while keeping the artisitic benefits.

  9. An alternative to improved alt-tab that is very useful is expose. I used compiz-fusion for like a week or so but performance in rendering while scrolling on any app was so bad that i switched back to metacity, i would love to have improved alt-tab and a dock bar (like awn).

  10. Rui: Søren’s compositor was abandoned (I think he was moved to other duties when his employer decided there were better uses of his time, but I don’t know the details); I tried to pick it up, but the major breakage was the infamous red window bug on some particular graphics cards, and since I didn’t have access to those cards, I wasn’t able to debug the problem. It took well over a month of my development time away from fixing other things and gave me nothing back in return. :(

    gus: I’m not familiar with the awn dock bar; can you show us some links?

  11. AWN page is on https://launchpad.net/awn
    Main developer blog: http://njpatel.blogspot.com/

    There you can find a lot of videos. One of the things that i really love about this bar is that icons are always present on all the workspaces and when you click on a icon on the dock and the application related is on another workspace the dock automatically switch you to that workspace.

    Cheers!

  12. It’s great to see someone working on the compositor in Metacity. It would be really nice to get the mini-previews in the Alt+Tab switcher, since it gives the desktop a more modern feeling. Nice, very nice that you’re working on this.

    Although I know it’s not yet really the time, I’d like to mention another feature I would like to see in Metacity: the possibility to get an overview of all the active workspaces. Mac OS X has this, and it’s called Spaces. Compiz Fusion has it, and there it’s called Expo.

  13. Interestingly, the window previews in Compiz’s Alt-Tab is one thing I don’t find an improvement. Perhaps that’s because most of my windows are white with black text in it, and indistinguishable from each other when shrunk to thumbnail size.

    Good news about the compositor in metacity. It will be very welcome by the folks whose video cards can’t handle 3D very well. (For example, I cannot use Compiz on a side-by-side dual-head layout, because the Nautilus desktop window at 2560×1024 doesn’t fit into a single 2048×2048 texture. And this with a relatively powerful Intel 965GM chip with 256 megs of video RAM.)

  14. This is such wonderful news! This kind of measured incremental improvement to a solid foundation (Metacity) is exactly the kind of progress that results in software stable enough to use in production. The rabid-eye-candy-by-way-of-throwing-everything-out-the-window that is Compiz is frustrating.

  15. +1 (and then some)

    I’m in the Intel P965 situation, too. Gusty has no Compiz love for me and I really miss two things: (a) AWN and (b) better Alt-TAB. TIA.

Leave a Reply

Your email address will not be published. Required fields are marked *

Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported.