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?

22 Comments

  1. Posted November 16, 2007 at 2:18 am | Permalink

    ‘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. Cameron
    Posted November 16, 2007 at 2:19 am | Permalink

    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. Ross Burton
    Posted November 16, 2007 at 10:16 am | Permalink

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

  4. Posted November 16, 2007 at 1:15 pm | Permalink

    Ross: aha, cheers. I obviously need to do some research to find out wtf RENDER performance actually means and whether I’ve got it. Off to Google we go…

  5. Posted November 17, 2007 at 7:41 pm | Permalink

    When will you implement this feature in metacity?

  6. Posted November 17, 2007 at 8:33 pm | Permalink

    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.)

  7. Paul Wellner Bou
    Posted November 18, 2007 at 10:47 am | Permalink

    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.

  8. Posted November 18, 2007 at 6:51 pm | Permalink

    Improved alt-tab, please! That’s the one thing I use desktop-effects for.

  9. Posted November 18, 2007 at 6:56 pm | Permalink

    Luis: Improved how? Translucency? Previews? Something else?

  10. Posted November 18, 2007 at 7:02 pm | Permalink

    Previews, mostly. I don’t really consider translucency a win, just about ever. :)

  11. Corey
    Posted November 18, 2007 at 7:21 pm | Permalink

    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.

  12. Corey
    Posted November 18, 2007 at 7:22 pm | Permalink

    I should point out the main reason I wanted compositing was to run the avant windom navigator.

  13. Rui
    Posted November 18, 2007 at 7:22 pm | Permalink

    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.

  14. Posted November 18, 2007 at 7:31 pm | Permalink

    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.

  15. Posted November 18, 2007 at 7:32 pm | Permalink

    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).

  16. Posted November 18, 2007 at 7:36 pm | Permalink

    My vote goes to previews in alt-tab and in desktop switcher :)

  17. Posted November 18, 2007 at 8:06 pm | Permalink

    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?

  18. Posted November 18, 2007 at 8:27 pm | Permalink

    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!

  19. Harm Hilvers
    Posted November 18, 2007 at 8:43 pm | Permalink

    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.

  20. Posted November 18, 2007 at 10:44 pm | Permalink

    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.)

  21. Posted November 19, 2007 at 12:27 am | Permalink

    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.

  22. Thomas
    Posted November 20, 2007 at 12:24 am | Permalink

    +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.

6 Trackbacks

  1. By Metacity non è passato di moda… « Opera Omnia on November 16, 2007 at 10:02 am

    [...] Postato in Applicazioni / Varie, Desktop Enviroment, Distribuzioni, Gnome, Gutsy Gibbon 7.10, Linux, Open Source, TuxFeed, Ubuntu C’è chi ci lavora con molto impegno, ha buone prospettive per il futuro, ne sa apprezzare i pregi e invita tutti a fare lo stesso,  con post espliativi come questo… [...]

  2. By » Metacity + composite manager?Qualcosa si muove! on November 17, 2007 at 7:59 pm

    [...] ci stanno lavorando. Il codice non è ancora stabile, per chi vuole provare può trovare tutto qui e se anche questo si aggiungerà assieme a epiphany+webkit in Gnome 2.22, ci dovremo aspettare una [...]

  3. By links for 2007-11-18 on November 18, 2007 at 6:18 pm

    [...] Adventures in Compositation Land “[People think compositing means] 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.” — Iain rocks out with a compositor for Metacity! (tags: metacity render gnome composite compiz) [...]

  4. [...] Iain’s compositing post continued to be the scene of much discussion. [...]

  5. [...] see recently that Iain work to integrate compositing in metacity. I’ll also work on composite manager (outside metacity) which use cairo for rendering. I have [...]

  6. By bonq.net/flipp » Blog Archive » daily del.icio.us on December 14, 2007 at 2:25 am

    [...] …for the adult in you » Adventures in Compositation Land (tags: eyecandy compiz linux gnome) [...]