For two decades, X has been the foundation for Linux graphics. Ubuntu’s decision late in 2010 to switch to Wayland shakes things up all the way to those roots. Just over a month ago, the official 1.0.0 release of Wayland appeared, as well as its associated Weston project. How will these milestones affect working GUI programmers? What will happen to all the existing toolkits — Qt, wxWindows, Tk, and others — on which so many graphical applications already depend?
The hope is that Wayland will make things better. With luck, or at least optimism, graphics will be faster and richer, and perhaps no more difficult than now – possibly even easier to maintain. In this article, I explain why, and explore the challenges that remain.
Let’s start by considering what an end user will see. In casual language, future releases of Ubuntu will base their graphics on Wayland rather than X. Since Wayland is designed for 3D displays, the Linux applications of the future will look three-dimensional!
That summary hides considerable detail. When this will actually happen is not set in stone. Certainly it was not in time for Quantal Quetzal 12.10 in mid-October 2012, and I doubt that 13.04, scheduled for spring 2013, will include Wayland as Ubuntu’s default display protocol. The Ubuntu Developer Summit in Copenhagen at the end of October 2012 hinted at plans for Wayland adoption. While Wayland would nicely complement 14.04’s planned break-out to a wide variety of display devices, including televisions and smartphones, I doubt that anyone can be certain how many Wayland-targeted device drivers will be ready by then.
3D on a Single 2D Screen — Through Time
Wayland supports three-dimensional effects; it doesn’t magically create them.
“Three-dimensional” has a peculiar meaning among graphics programmers. While stereoscopic displays that provide perceived depth do exist, “3D” for this introduction involves no funny glasses. This kind of 3D is generally understood as a contrast to typical applications’ elements: “Flatland” text, perhaps layered in a simple fashion over a background of images. 3D in this sense refers more to the representation within the computer, and only secondarily to what a viewer sees at any instant of time.
So, for the purpose of this article, 3D graphics involve an implementation of objects in a volumetric, rather than planar, space.
For end users, a 3D implementation has advantages. It is comparatively easy to move, turn and otherwise transform scenes through time, so the viewer can see the sides and backs of objects, not just their fronts. While it would be nice for me to illustrate such effects with a graphic, part of the point is that the two-dimensional medium where you’re reading this description doesn’t support static three-dimensionality. What you can do, though, is run these videos from HowStuffWorks for a “moving-picture” sense of what 3D computer graphics shows. This video, released at the end of summer 2012, focuses particularly on how OpenGL-based three-dimensional display renders a three-dimensional scene as one moves around and through it.
Knowledgeable people agree that Wayland’s 3D-savvy OpenGL-based API gives developers pleasant access to hardware capabilities. The contrast is with X, which does wonders with graphics cards and resources from the 1990s, but has accumulated 15 years of scar tissue that get in the way of efficient solution of today’s problems.
Wayland’s breakthrough is to abstract the notions of buffer and compositor so that they’re coupled as weakly as possible. Wayland gives graphical toolkit designers the relatively easy task of managing the buffers given them, and it takes responsibility for combining the buffers into a visible screen display. For programmers, this brings several conveniences, including easier access to 3D graphics, potentially complete control over every display frame, and slick ways to emulate other hardware or styles.
Wayland’s refactoring of the graphics stack also holds out hope that it will be easier to write device drivers and other low-level hardware interfaces, and thus Ubuntu will become nimbler at support of new products.
How will you update your graphical applications to run in the new Wayland desktop, once it arrives? You might have to do … nothing. Your GUI application is itself probably written against one of the popular GUI toolkits, such as wxWindows, Tk, or Qt. Suppose, as is often true, your application is dynamically-linked. Once these toolkits are migrated to Wayland, your application immediately becomes available as a Wayland application, without recompilation.
The Wayland 1.0 release is intended to remove any technical barriers to migration. Wayland 1.0 arrives with a commitment “to never break backwards compatibility of interfaces.” Qt 5, for instance, already has Wayland compatibility in development.
Compatible in all directions
Even before migration of the toolkits to Wayland, though, you can run your application unchanged within Wayland. This easy transition path is possible because X itself — which is baked into the current implementation of your application — can be served by a Wayland client. Experimental versions of this facility are already in laboratory test. Version 1.14 of the X.org server, scheduled for release in spring 2013, can use Wayland as the back end for X11 service.
Also available, as mentioned above, is Weston 1.0. Wayland, in this perspective, is the C-coded library that supports the development side of the Wayland protocol. Weston is a reference implementation of the other side, the “compositor,” which interacts more directly with hardware. Weston is constructed to port well to mobile devices and other limited-resource contexts.
Another recent breakthrough the Wayland development team has achieved is a “remotable” prototype. While X11 was originally designed to offer a number of benefits, the one that remains most salient is its network transparency: It’s natural with X11 to run a computation here, but view it there. Weston now builds in this capability.
A few hurdles remain
Not everything is rosy for Wayland. Many Linux PCs lack graphics hardware to make the most of 3D. As of this writing, for instance, no Chromebook has such a chipset. Clunkiness on some platforms will cramp interest in Wayland. Most crucially, Ubuntu is only one of several distributions for Linux, and Linux itself is at best third in popularity among desktop operating systems.
Over the longer term, though, computing hardware will continue to gain capabilities. It always does. Plus, use of Linux-based mobile devices is exploding. Even if plans for one particular release of one particular product turn out to have problems — as they inevitably will — the care with which compatibility has been designed into Wayland should keep it close to the marketplace’s eventual path. Wayland is positioned to play a crucial role in making displays of all sizes more immersive, and it’s time for aggressive graphics programmers to research for themselves how they will try it out first.