Linux.com

Home News Software Applications The What Why and How of Wayland and Weston on Linux

The What Why and How of Wayland and Weston on Linux

Let's start from the beginning, because even though Wayland has been in development for over five years there is still a lot of misunderstanding of what it is. Wayland is a display server protocol that is intended to replace the X Window System. We've had X for 27 years, and computing has changed a wee bit in that time. Back in the olden days we had text terminals and every little pixel was precious. Now we have great honking graphics cards with more processing power than the servers and workstations of yesteryear, multiple displays, smartphones and tablets, embedded devices, and users who are not going to settle for colorful ANSI displays, but want complex 3D graphics. And why shouldn't Linux lead the way in graphics rendering? Are we not overdue for holodecks? And who would ever want to leave their holodeck? Though, as figure 1 shows, you can make some cool color images with ANSI.

lordFigure 1: ANSI artwork from Legend of the Red Dragon.

The Evolution of X

X has been showing its age for the past 10-12 years, and has acquired a considerable cruft base in that time, to the point that it is more in the way than useful. You younguns might not remember, but back in the olden days of Linux we had to configure X manually, and it controlled displays, mice and keyboards. Yes, keyboards and mice. Why? Darned if I know. This is what I wrote in my awesome Linux Cookbook, published in 2004:

    "XF86Config requires that you know configuration data about your mouse, keyboard, video adapter, and monitor. It takes you through setup line by line, asking questions until you're ready to explode. Most important are the name of your video card, the amount of video RAM, and the horizontal/vertical refresh rates for your monitor."

What is this XF86Config? It was the main configuration file for XFree86 (capitalized in a most annoying and typing-unfriendly way) which was the original X Window System for Linux. It was doing fine and everyone was happy until the core development team became full of strife. In 2003 they gave developer Keith Packard the boot and changed the XFree86 license so that it was incompatible with the GPL, by adding an advertising clause:

     "The end-user documentation included with the redistribution, if any, must include the following acknowledgment: "This product includes software developed by The XFree86 Project, Inc (http://www.xfree86.org/) and its contributors", in the same place and form as other third-party acknowledgments. Alternately, this acknowledgment may appear in the software itself, in the same form and location as other such third-party acknowledgments."

The GPL prohibits the addition of restrictions beyond those that it already imposes, and this was a cumbersome and possibly unworkable clause in any case, as tracking multiple contributors in a large project composed of multiple components is difficult. Of such small things are great rifts born, and this was the final blow in a succession of internal problems on the XFree86 project. Keith Packard, who is probably the most knowledgeable person about the X Window System, went on to lead the fork of XFree86 that we use today, Xorg, which is short for X.org. Development on XFree86 ended in 2009.

Xorg does not even come with a user configuration file, but rather auto-configures your graphical display. Though you can write your own custom xorg.conf file if you like, or use the X -configure command to generate a skeleton config file.

Linux users are used to clunky configuration tools, and the world hasn't ended yet. So what else is wrong with X? How about decades of cruft? Much of X's functionality has moved into the kernel-- for example memory management, command scheduling, and mode setting-- and into libraries like freetype, fontconfig, and cairo. It's very complex and difficult for developers to understand, with unintended consequences galore, and not in a good state to be fixed rather than replaced. Even with so much functionality moved out of X it's still a memory and CPU hog.

What is Wayland

As it says in the FAQ Wayland is not an X fork, and it is not an X server. Rather, it is a protocol that communicates between a compositor and its clients. Compositing is one of the most useful and progressive developements in window managers: the old way was for applications to handle rendering their own windows directly inside shared display memory, which was not particularly efficient or stable. These old-style window managers are called stacking window managers. A compositing window manager takes control of this by giving each application its own little bit of memory buffer, and then it composites all these buffers into an image in the display memory. It's more stable because a stacking window manager can freeze or crash when a single application misbehaves. A compositing window manager keeps on chugging even when an application wigs out, and draws windows more smoothly and without flickering.

The compositor can also be a Linux display server, an X application, or a special Wayland client. The Wayland project includes a demo Wayland compositor, called Weston. It's fast, small, and runs on embedded and mobile devices.

Compositing window managers are capable of all kinds of special effects coolness, such as 2D and 3D animations, rotation, drop shadows, blurring, magnifiers, and all kinds of nifty stuff. Some popular compositing window managers are Xfwm, Cairo, KWin (KDE4), Mutter (GNOME 3) and Compiz. KWin and Mutter have partial Wayland support, with plans for complete suppport. The Enlightenment team have always done amazing work with graphics, and are also working hard to implement Wayland. Fedora includes Wayland, and is aiming for complete support by Fedora 21. A number of key toolkits support Wayland: Qt 5, GTK+ 3, and Clutter.

Wayland offloads many tasks that X currently handles. Drawing, multiple monitors, and font rendering are all tasks that can be handled by something other than an X server. Drawing is what you see on your screen every time something changes, like scrolling, opening a new application, playing a video-- everything is drawn on your screen by the X server.

X has two drawing APIs, one which is old and nobody uses, and the other is the XRender extension which is what we use now. Wayland has no drawing APIs, and doesn't need any thanks to direct rendering which links the Linux kernel directly with your graphics adapter, cutting out the fat X server middle layer. The Linux kernel includes a direct rendering manager (DRM) which has two parts: the kernel drm driver, and your graphics card driver, if it supports direct rendering. Which it should in this glorious year 2013 in the new millennium. Graphics processing units (GPUs) are much faster at processing video than your CPU, so the more video functionality we can push to them the better.

Wayland aims to be simpler, cleaner, and more flexible. It's not possible to make a clean break with Xorg because of trainloads of legacy code and applications, but Xorg can run as client of Wayland for backwards-compatibility. By positioning Wayland as an intermediary between compositing window managers, clients, and the Linux kernel, clients can load up on all kinds of specialized functionality without having to deal with an old giant complex X codebase.

What About Network Transparency?

The Wayland developers seem undecided about building networking into Wayland, suggesting that perhaps standalone network display servers like VNC are preferable. Me, I love my ssh -Y incantations and you can pry them from my cold dead hands. But I'm not picky about the details of how to forward graphical displays over the network as long as I can do it, so time will tell.

How to Get Wayland Now

Wayland has been in development for five years by the people with the most expertise: the Xorg team. It's going to take a few more years before it's ready for prime time, but you can play with it now. The best distro for previewing Wayland is Arch Linux, which has all the essential bits in their software repos and some good beginner instructions.

 

Comments

Subscribe to Comments Feed
  • jean horten Said:

    So something developed for intel graphics chips by an intel employee with an aversion against proprietary drivers for other gpu manufacturer'S products is supposed to be the next standard in Linux? I see a bad conspiracy to push AMD/Nvdiia out to kill off desktop linux in favour of the operating systems offered by one of inzel'S biggest business partners, Microsoft

  • Erinn Said:

    What?? If you're referring to Kristian Høgsberg, he started work on Wayland while he was working for Red Hat. Now he works for Intel, which has a robust open source program, including open source video chips and drivers. NVidia is 100% closed-source, and AMD's open source drivers are inferior to their closed ones. Wayland has nothing to do with Microsoft. Your comment is weird.

  • jean horten Said:

    But you know that Hoegsberg hates proprietary graphics drivers and develops wayland mainly for the low perf intel chips? Someone with that shitty attitude and technical/commercial background should not develop a new 'standard' that will kick back Linux graphics performance 20 years by giving a freck about drivers that unleash full graphics power. Don't tell me to use intel graphics cards, there are none.

  • Del Said:

    Actually, AMD and Intel are quite similar in that respect. Intel drivers on linux are at about the same level as AMD drivers on linux compared to their windows counterparts, both in terms of features, performance delta and opengl support. AMD tend to get way too little credit for the great work they are doing on the open drivers.

  • Neel Gupta Said:

    Just wait for OpenGL 5.0 release. The new graphics drivers for Linux should become Standardized !

  • Brent W. Hopkins Said:

    Is Wayland the future of Ubuntu as well? That is probably all that matters to the majority of Linux users.

  • Ollie Said:

    Nope! They're opting to go with their own display server called Mir instead of Wayland.

  • Bob Mesibov Said:

    Will Wayland/Weston have the primary clipboard feature that's so handy in X (highlight to select and copy text, middle-click to paste)? It's a huge time-saver and I've used it in some can't-do-without scripts based on the xclip utility.

  • LinuxFu Said:

    I can't give you a definitive answer but I can tell you that all of this is going to be passed through in new applications that don't rely on an X abstraction. In short what it means is that your old x applications will behave the same way and that the new applications will have to decide for themselves. The clipping utilities will probably be implemented as an api to the display server. So expect your old scripts to be broken on new programs that don't traverse an X abstraction. If the display servers are designed with details in mind then most of this functionality should be preserved... however by then you will have rewritten the scripts already to accommodate the gap.

  • Me Said:

    I'm with you about wanting ssh -Y functionality at my fingertips forever... But... THere is only one app that I definitely "need" this for any more -- and I need that seldom... but the thing is that what I need it for most is the mission critical piece of crap perl/tk code that does my company's program releases to our custom database... Also, if I ever have need to run one of the mission critical simulators... yes, I need to remote display that to my local display... So, the full functionality of X network transparency is now for me, granted, a seldom used feature, but absolutely necessary for me to get my job done.

  • zeuslinux Said:

    Carla, Do you know if the Wayland developers are planning to put the RDP (Remote Desktop Protocol) feature into wayland ? For X there are 2 RDP implementations: xdrp (http://www.xrdp.org/) and freerdp (

  • Carla Schroder Said:

    Hi zeuslinux, So far they're talking about RDP as an external option, like VNC, rather than built-in to Wayland. I'm not worried about it as network transparency is essential to a whole lot of users, so I'm confident something will replace it. I have no idea what, though.

  • LinuxFu Said:

    I would agree that they should implement it as a it's own thing such as VNC. X was perhaps the biggest breach of Unix philosophy that has persisted for so long. Without going into captain hindsight mode, we can look to implementing functionality in a more compartmentalized fashion in the future. Love the article.

  • TuffTuff Said:

    Network transparency is essential, I use it every day, unlike You I use ssh -X:-) There are lots of reasons, like running a tool that for some reason needs a special machine (other arch or special hardware). Actually I've only recently replaced my 10+ year old desktop machine, there was no need since there are other machines in the office to run the more CPU intensive apps on. Without something like X forwarding on Linux I might run OsX instead.

  • dgelling Said:

    You should really watch this talk: http://www.youtube.com/watch?v=RIctzAQOe44&t=18m58s He talks about what the x server actually does these days, and why it causes lag. Near the end of the talk, he mentions that all the round trips X does these days means that X is actually very bad for remoting these days -- something like VNC would do better, and this would be very easy to implement on top of wayland. So actually, Wayland will probably make remoting better and less laggy.

  • jean horten Said:

    A wayland dev bashing x for 45 minutes and praising wayland as the reinvention of sliced bread, what a surprize

  • Terry A. Davis Said:

    CPU graphics are what I'm sticking with. There is beauty in easy-to-get-your-head-around system code. I was excited by "open source" when I heard of Linux, until I realized, I could not have fun tinkering because it's a monstrosity. God said 640x480 16 color. I watched a talk with Carmack and I learned how terribly complex fancy graphics code is -- it's not within range of amateurs to make a computer game.

  • Stu Said:

    Terry, I had a similar motivation (Linux as a freedom to tinker), though for CAD rather than gaming. And similar disappointment. GPUs are closed-source so I focused on CPU rendered 8 bit graphics on my workstation. CPU redraws full HD screen full of complex 2D objects (grids, background colors, 500 pt self-crossing polygon, swirly cursor (500 lines from cursor to those points in various widths, colors). 30,000 bit mapped chars in various sizes on overlapping framed pages) in 5 msec. Then I wait 80~120msec for X to copy my bitmap to the display. Now I'm running Arch, hoping that Wayland will at least give me low-latency access to the display buffer. Linux means freedom only for those who already want what it provides, or a poor copy of commercial software of decades past. Good luck!


Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board