A Look at the Modern X Server
When Apple introduced OS X, it chose to use its own proprietary GUI instead of X11. This provoked some criticism from the community. Mike Paquette, who did much of the design work on the system, replied, saying that they could have used X, but if they had they would have had to extend it in so many ways it would have been almost unrecognizable. Since then, Keith Packard and a few others have done exactly that.
The X Window System is conceptually very simple. It provides a mechanism for assigning a region of the screen onto which an application can draw (with a clipping region to prevent it from drawing over other applications’ windows), some inter-window communication systems, and very little else.
As a result, X earns an entire chapter in the UNIX Haters’ Handbook because it has lead to a large number of mostly incompatible extensions. Everyone adds their own widget sets on top of X, and even extended the core protocol in different ways.
At one point, there were three different extensions for providing support to screensavers, for example. At the height of the UNIX wars, each vendor was adding their own extensions to the reference implementation, causing interoperability headaches for everyone. This has largely been resolved now, since most people use the x.org X server.
I Can See Right Through You
One thing that has traditionally been hard for X11 is transparent windows. X is designed for network transparency and it includes a number of optimizations so that windows are not updated when they are not visible. But the problem extended deeper into the drawing model used by X. A system such as OS X’s Quartz gets transparency very easily; every window is drawn to an off-screen buffer, and then composited together to provide the final image.
Any of these buffers can have an alpha (transparency) value associated with it, allowing some very shiny visual effects. This was impossible with X. A lot of hacks were used, such as inspecting the pixel values of all the overlapping windows and then performing the compositing in the application that wanted the translucent window, but this was a lot of effort and not a general solution.
The Composite extension provided part of the solution. Using this extension, it is possible to redirect drawing of a window to an off-screen buffer. This buffer is then drawn to the screen using the RENDER extension. The Composite extension is very simple. Any window (and its children) can be redirected to an off-screen Picture, which is an opaque data type representing the image. It can also be retrieved as a pixmap as of version 0.2 of the standard. After this redirection, drawing the window to the screen is no longer the responsibility of the X server.
The RENDER extension, often known as XRender, is somewhat more complicated. Among other things, RENDER allows a Porter-Duff compositing of the off-screen Pictures created by the Composite extension. This allows translucency in a very general way, since windows with an alpha value will have this used in their compositing operations. This compositing is typically done by a compositing manager.
One of the design goals of X11 was the separation of policy and mechanism. Keith Packard has been an active member of the development community since around 1988, when X was still in its infancy, and so it should come as no surprise that he maintained these principles in his latest modifications. X does not, for example, draw decorations around windows for supporting things like moving and resizing, it relies on a window manager to do this. A compositing manager is conceptually similar; it provides the policy, while the X server provides the mechanism.
When using a composting manager, it is common for all of the windows to be drawn off-screen and then composited onto the root window. During this process, a number of additional effects can be applied. One common example is adding drop shadows to a window, with a larger one on the active window giving a visual clue that it is in the foreground.