Monday, January 3, 2011

Multiple backends for GTK+

I have to blog about this before the other Kristian finds out and beats me to it. Kris wrote about the new GDK backend work that Alex Larsson started and Benjamin Otte and Matthias Clasen finished. The backend work lets us compile several GDK backends into GTK+ at the same time. Over the holidays I was able to dust off my Wayland backend work for GTK+ and bring it up to date with all the cleanup that's been going on and make it work with the multi-backend stuff. With a little patch to the build system, it is now possible to actually build multiple backends, and adding a Wayland backend on top of that lets us try out the new multi-backend functionality:

The screen shot shows the testgtk application running under X (that's the window with decorations) and under Wayland (using the X based compositor, sort of like Xnest but Wayland nested under X instead). The two testgtk windows come from the same application linking to the same GTK+ library. The only difference is that the Wayland instance was started with the GDK_BACKEND environment variable set to "wayland".

I moved my wayland backend branch to the upstream gtk+ git repository, but it's still very much a work in progress. In fact, I'm using testgtk in the screenshot above, because gtk-demo currently doesn't work in the Wayland backend. But like Kris mentions in his post, the cleanups that has landed in gtk+ recently makes it a lot easier to work with and port to other window systems. And Wayland itself is a lot easier to run these days, all the custom branches of mesa, libdrm etc and kernel patches that were necessary a year ago are now upstream. Fedora rawhide has all the packages required to build and run Wayland and Bryce Harrington maintains a Wayland PPA for Ubuntu (only maverick for now). Or you can build it yourself

And by the way, Wayland moved to freedesktop.org hosting recently: wayland.freedesktop.org. We now have web pages, a real mailing list, #wayland on irc.freenode.org and an official looking git repo.