Commit f476148c authored by Daniel Stone's avatar Daniel Stone

Add all files from annarchy.fd.o

Pull the files from annarchy.fd.o, which was serving wayland.fd.o, which
were on the disk and served by Apache but not in the repository.
Signed-off-by: Daniel Stone's avatarDaniel Stone <daniels@collabora.com>
parent 008647c3

Too many changes to show.

To preserve performance only 539 of 539+ files are displayed.

This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Chapter 1. Introduction</title><link rel="stylesheet" type="text/css" href="css/default.css"><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"><link rel="home" href="index.html" title="Wayland"><link rel="up" href="index.html" title="Wayland"><link rel="prev" href="pr02.html" title="Acknowledgments"><link rel="next" href="ch02.html" title="Chapter 2. Types of Compositors"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 1. Introduction</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="pr02.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="ch02.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="chap-Introduction"></a>Chapter 1. Introduction</h1></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl class="toc"><dt><span class="section"><a href="ch01.html#sect-Motivation">Motivation</a></span></dt><dt><span class="section"><a href="ch01.html#sect-Compositing-manager-display-server">The compositing manager as the display server</a></span></dt></dl></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="sect-Motivation"></a>Motivation</h2></div></div></div><p>
Most Linux and Unix-based systems rely on the X Window System (or
simply <span class="emphasis"><em>X</em></span>) as the low-level protocol for building
bitmap graphics interfaces. On these systems, the X stack has grown to
encompass functionality arguably belonging in client libraries,
helper libraries, or the host operating system kernel. Support for
things like PCI resource management, display configuration management,
direct rendering, and memory management has been integrated into the X
stack, imposing limitations like limited support for standalone
applications, duplication in other projects (e.g. the Linux fb layer
or the DirectFB project), and high levels of complexity for systems
combining multiple elements (for example radeon memory map handling
between the fb driver and X driver, or VT switching).
</p><p>
Moreover, X has grown to incorporate modern features like offscreen
rendering and scene composition, but subject to the limitations of the
X architecture. For example, the X implementation of composition adds
additional context switches and makes things like input redirection
difficult.
</p><div class="mediaobject"><img src="images/x-architecture.png" alt="X architecture diagram"></div><p>
The diagram above illustrates the central role of the X server and
compositor in operations, and the steps required to get contents on to
the screen.
</p><p>
Over time, X developers came to understand the shortcomings of this
approach and worked to split things up. Over the past several years,
a lot of functionality has moved out of the X server and into
client-side libraries or kernel drivers. One of the first components
to move out was font rendering, with freetype and fontconfig providing
an alternative to the core X fonts. Direct rendering OpenGL as a
graphics driver in a client side library went through some iterations,
ending up as DRI2, which abstracted most of the direct rendering
buffer management from client code. Then cairo came along and provided
a modern 2D rendering library independent of X, and compositing
managers took over control of the rendering of the desktop as toolkits
like GTK+ and Qt moved away from using X APIs for rendering. Recently,
memory and display management have moved to the Linux kernel, further
reducing the scope of X and its driver stack. The end result is a
highly modular graphics stack.
</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="sect-Compositing-manager-display-server"></a>The compositing manager as the display server</h2></div></div></div><p>
Wayland is a new display server and compositing protocol, and Weston
is the implementation of this protocol which builds on top of all the
components above. We are trying to distill out the functionality in
the X server that is still used by the modern Linux desktop. This
turns out to be not a whole lot. Applications can allocate their own
off-screen buffers and render their window contents directly, using
hardware accelerated libraries like libGL, or high quality software
implementations like those found in Cairo. In the end, what’s needed
is a way to present the resulting window surface for display, and a
way to receive and arbitrate input among multiple clients. This is
what Wayland provides, by piecing together the components already in
the eco-system in a slightly different way.
</p><p>
X will always be relevant, in the same way Fortran compilers and VRML
browsers are, but it’s time that we think about moving it out of the
critical path and provide it as an optional component for legacy
applications.
</p><p>
Overall, the philosophy of Wayland is to provide clients with a way to
manage windows and how their contents is displayed. Rendering is left
to clients, and system wide memory management interfaces are used to
pass buffer handles between clients and the compositing manager.
</p><div class="mediaobject"><img src="images/wayland-architecture.png" alt="Wayland architecture diagram"></div><p>
The figure above illustrates how Wayland clients interact with a
Wayland server. Note that window management and composition are
handled entirely in the server, significantly reducing complexity
while marginally improving performance through reduced context
switching. The resulting system is easier to build and extend than a
similar X system, because often changes need only be made in one
place. Or in the case of protocol extensions, two (rather than 3 or 4
in the X case where window management and/or composition handling may
also need to be updated).
</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="pr02.html">Prev</a> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="ch02.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Acknowledgments </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 2. Types of Compositors</td></tr></table></div></body></html>
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Chapter 2. Types of Compositors</title><link rel="stylesheet" type="text/css" href="css/default.css"><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"><link rel="home" href="index.html" title="Wayland"><link rel="up" href="index.html" title="Wayland"><link rel="prev" href="ch01.html" title="Chapter 1. Introduction"><link rel="next" href="ch03.html" title="Chapter 3. Wayland Architecture"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 2. Types of Compositors</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch01.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="ch03.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="chap-Compositors"></a>Chapter 2. Types of Compositors</h1></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl class="toc"><dt><span class="section"><a href="ch02.html#sect-Compositors-System-Compositor">System Compositor</a></span></dt><dt><span class="section"><a href="ch02.html#sect-Compositors-Session-Compositor">Session Compositor</a></span></dt><dt><span class="section"><a href="ch02.html#sect-Compositors-Embedding-Compositor">Embedding Compositor</a></span></dt></dl></div><p>
Compositors come in different types, depending on which
role they play in the overall architecture of the OS.
For instance, a
<a class="link" href="ch02.html#sect-Compositors-System-Compositor" title="System Compositor">system compositor</a>
can be used for booting the system, handling multiple user switching, a
possible console terminal emulator and so forth. A different compositor, a
<a class="link" href="ch02.html#sect-Compositors-Session-Compositor" title="Session Compositor">session compositor</a>
would provide the actual desktop environment. There are many ways for
different types of compositors to co-exist.
</p><p>
In this section, we introduce three types of Wayland compositors relying
on <a class="link" href="apc.html" title="Appendix C. Server API">libwayland-server</a>.
</p><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="sect-Compositors-System-Compositor"></a>System Compositor</h2></div></div></div><p>
A system compositor can run from early boot until shutdown.
It effectively replaces the kernel vt system, and can tie in
with the systems graphical boot setup and multiseat support.
</p><p>
A system compositor can host different types of session
compositors, and let us switch between multiple sessions
(fast user switching, or secure/personal desktop switching).
</p><p>
A linux implementation of a system compositor will typically
use libudev, egl, kms, evdev and cairo.
</p><p>
For fullscreen clients, the system compositor can reprogram the
video scanout address to read directly from the client provided
buffer.
</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="sect-Compositors-Session-Compositor"></a>Session Compositor</h2></div></div></div><p>
A session compositor is responsible for a single user session.
If a system compositor is present, the session compositor will
run nested under the system compositor. Nesting is feasible because
the protocol is asynchronous; roundtrips would be too expensive
when nesting is involved. If no system compositor is present, a
session compositor can run directly on the hw.
</p><p>
X applications can continue working under a session compositor
by means of a root-less X server that is activated on demand.
</p><p>
Possible examples for session compositors include
</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
gnome-shell
</p></li><li class="listitem"><p>
moblin
</p></li><li class="listitem"><p>
kwin
</p></li><li class="listitem"><p>
kmscon
</p></li><li class="listitem"><p>
rdp session
</p></li><li class="listitem"><p>
Weston with X11 or Wayland backend is a session compositor nested
in another session compositor.
</p></li><li class="listitem"><p>
fullscreen X session under Wayland
</p></li></ul></div><p>
</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="sect-Compositors-Embedding-Compositor"></a>Embedding Compositor</h2></div></div></div><p>
X11 lets clients embed windows from other clients, or lets clients
copy pixmap contents rendered by another client into their window.
This is often used for applets in a panel, browser plugins and similar.
Wayland doesn't directly allow this, but clients can communicate GEM
buffer names out-of-band, for example, using D-Bus, or command line
arguments when the panel launches the applet. Another option is to
use a nested Wayland instance. For this, the Wayland server will have
to be a library that the host application links to. The host
application will then pass the Wayland server socket name to the
embedded application, and will need to implement the Wayland
compositor interface. The host application composites the client
surfaces as part of it's window, that is, in the web page or in the
panel. The benefit of nesting the Wayland server is that it provides
the requests the embedded client needs to inform the host about buffer
updates and a mechanism for forwarding input events from the host
application.
</p><p>
An example for this kind of setup is firefox embedding the flash
player as a kind of special-purpose compositor.
</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch01.html">Prev</a> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="ch03.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 1. Introduction </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 3. Wayland Architecture</td></tr></table></div></body></html>
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Chapter 3. Wayland Architecture</title><link rel="stylesheet" type="text/css" href="css/default.css"><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"><link rel="home" href="index.html" title="Wayland"><link rel="up" href="index.html" title="Wayland"><link rel="prev" href="ch02.html" title="Chapter 2. Types of Compositors"><link rel="next" href="ch04.html" title="Chapter 4. Wayland Protocol and Model of Operation"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 3. Wayland Architecture</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch02.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="ch04.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="chap-Wayland-Architecture"></a>Chapter 3. Wayland Architecture</h1></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl class="toc"><dt><span class="section"><a href="ch03.html#sect-Wayland-Architecture-wayland_architecture">X vs. Wayland Architecture</a></span></dt><dt><span class="section"><a href="ch03.html#sect-Wayland-Architecture-wayland_rendering">Wayland Rendering</a></span></dt><dt><span class="section"><a href="ch03.html#sect-Wayland-Architecture-wayland_hw_enabling">Hardware Enabling for Wayland</a></span></dt></dl></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="sect-Wayland-Architecture-wayland_architecture"></a>X vs. Wayland Architecture</h2></div></div></div><p>
A good way to understand the Wayland architecture
and how it is different from X is to follow an event
from the input device to the point where the change
it affects appears on screen.
</p><p>
This is where we are now with X:
</p><div class="figure"><a name="idm140152825430224"></a><p class="title"><b>Figure 3.1. X architecture diagram</b></p><div class="figure-contents"><div class="mediaobjectco"><img border="0" usemap="#map1" src="images/x-architecture.png" alt="X architecture diagram"><map name="map1"><area shape="rect" href="ch03.html#x_flow_1" coords="198,346,221,373"><area shape="rect" href="ch03.html#x_flow_2" coords="124,160,146,187"><area shape="rect" href="ch03.html#x_flow_3" coords="37,65,60,92"><area shape="rect" href="ch03.html#x_flow_4" coords="230,265,252,292"><area shape="rect" href="ch03.html#x_flow_5" coords="250,211,273,238"><area shape="rect" href="ch03.html#x_flow_6" coords="118,305,141,332"></map></div></div></div><br class="figure-break"><p>
</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p><a name="x_flow_1"></a>
The kernel gets an event from an input
device and sends it to X through the evdev
input driver. The kernel does all the hard
work here by driving the device and
translating the different device specific
event protocols to the linux evdev input
event standard.
</p></li><li class="listitem"><p><a name="x_flow_2"></a>
The X server determines which window the
event affects and sends it to the clients
that have selected for the event in question
on that window. The X server doesn't
actually know how to do this right, since
the window location on screen is controlled
by the compositor and may be transformed in
a number of ways that the X server doesn't
understand (scaled down, rotated, wobbling,
etc).
</p></li><li class="listitem"><p><a name="x_flow_3"></a>
The client looks at the event and decides
what to do. Often the UI will have to change
in response to the event - perhaps a check
box was clicked or the pointer entered a
button that must be highlighted. Thus the
client sends a rendering request back to the
X server.
</p></li><li class="listitem"><p><a name="x_flow_4"></a>
When the X server receives the rendering
request, it sends it to the driver to let it
program the hardware to do the rendering.
The X server also calculates the bounding
region of the rendering, and sends that to
the compositor as a damage event.
</p></li><li class="listitem"><p><a name="x_flow_5"></a>
The damage event tells the compositor that
something changed in the window and that it
has to recomposite the part of the screen
where that window is visible. The compositor
is responsible for rendering the entire
screen contents based on its scenegraph and
the contents of the X windows. Yet, it has
to go through the X server to render this.
</p></li><li class="listitem"><p><a name="x_flow_6"></a>
The X server receives the rendering requests
from the compositor and either copies the
compositor back buffer to the front buffer
or does a pageflip. In the general case, the
X server has to do this step so it can
account for overlapping windows, which may
require clipping and determine whether or
not it can page flip. However, for a
compositor, which is always fullscreen, this
is another unnecessary context switch.
</p></li></ol></div><p>
</p><p>
As suggested above, there are a few problems with this
approach. The X server doesn't have the information to
decide which window should receive the event, nor can it
transform the screen coordinates to window-local
coordinates. And even though X has handed responsibility for
the final painting of the screen to the compositing manager,
X still controls the front buffer and modesetting. Most of
the complexity that the X server used to handle is now
available in the kernel or self contained libraries (KMS,
evdev, mesa, fontconfig, freetype, cairo, Qt etc). In
general, the X server is now just a middle man that
introduces an extra step between applications and the
compositor and an extra step between the compositor and the
hardware.
</p><p>
In Wayland the compositor is the display server. We transfer
the control of KMS and evdev to the compositor. The Wayland
protocol lets the compositor send the input events directly
to the clients and lets the client send the damage event
directly to the compositor:
</p><div class="figure"><a name="idm140152825611760"></a><p class="title"><b>Figure 3.2. Wayland architecture diagram</b></p><div class="figure-contents"><div class="mediaobjectco"><img border="0" usemap="#mapB" src="images/wayland-architecture.png" alt="Wayland architecture diagram"><map name="mapB"><area shape="rect" href="ch03.html#wayland_flow_1" coords="271,414,293,440"><area shape="rect" href="ch03.html#wayland_flow_2" coords="337,132,360,159"><area shape="rect" href="ch03.html#wayland_flow_3" coords="290,81,312,107"><area shape="rect" href="ch03.html#wayland_flow_4" coords="185,414,207,441"></map></div></div></div><br class="figure-break"><p>
</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p><a name="wayland_flow_1"></a>
The kernel gets an event and sends
it to the compositor. This
is similar to the X case, which is
great, since we get to reuse all the
input drivers in the kernel.
</p></li><li class="listitem"><p><a name="wayland_flow_2"></a>
The compositor looks through its
scenegraph to determine which window
should receive the event. The
scenegraph corresponds to what's on
screen and the compositor
understands the transformations that
it may have applied to the elements
in the scenegraph. Thus, the
compositor can pick the right window
and transform the screen coordinates
to window-local coordinates, by
applying the inverse
transformations. The types of
transformation that can be applied
to a window is only restricted to
what the compositor can do, as long
as it can compute the inverse
transformation for the input events.
</p></li><li class="listitem"><p><a name="wayland_flow_3"></a>
As in the X case, when the client
receives the event, it updates the
UI in response. But in the Wayland
case, the rendering happens in the
client, and the client just sends a
request to the compositor to
indicate the region that was
updated.
</p></li><li class="listitem"><p><a name="wayland_flow_4"></a>
The compositor collects damage
requests from its clients and then
recomposites the screen. The
compositor can then directly issue
an ioctl to schedule a pageflip with
KMS.
</p></li></ol></div><p>
</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="sect-Wayland-Architecture-wayland_rendering"></a>Wayland Rendering</h2></div></div></div><p>
One of the details I left out in the above overview
is how clients actually render under Wayland. By
removing the X server from the picture we also
removed the mechanism by which X clients typically
render. But there's another mechanism that we're
already using with DRI2 under X: direct rendering.
With direct rendering, the client and the server
share a video memory buffer. The client links to a
rendering library such as OpenGL that knows how to
program the hardware and renders directly into the
buffer. The compositor in turn can take the buffer
and use it as a texture when it composites the
desktop. After the initial setup, the client only
needs to tell the compositor which buffer to use and
when and where it has rendered new content into it.
</p><p>
This leaves an application with two ways to update its window contents:
</p><p>
</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p>
Render the new content into a new buffer and tell the compositor
to use that instead of the old buffer. The application can
allocate a new buffer every time it needs to update the window
contents or it can keep two (or more) buffers around and cycle
between them. The buffer management is entirely under
application control.
</p></li><li class="listitem"><p>
Render the new content into the buffer that it previously
told the compositor to to use. While it's possible to just
render directly into the buffer shared with the compositor,
this might race with the compositor. What can happen is that
repainting the window contents could be interrupted by the
compositor repainting the desktop. If the application gets
interrupted just after clearing the window but before
rendering the contents, the compositor will texture from a
blank buffer. The result is that the application window will
flicker between a blank window or half-rendered content. The
traditional way to avoid this is to render the new content
into a back buffer and then copy from there into the
compositor surface. The back buffer can be allocated on the
fly and just big enough to hold the new content, or the
application can keep a buffer around. Again, this is under
application control.
</p></li></ol></div><p>
</p><p>
In either case, the application must tell the compositor
which area of the surface holds new contents. When the
application renders directly to the shared buffer, the
compositor needs to be noticed that there is new content.
But also when exchanging buffers, the compositor doesn't
assume anything changed, and needs a request from the
application before it will repaint the desktop. The idea
that even if an application passes a new buffer to the
compositor, only a small part of the buffer may be
different, like a blinking cursor or a spinner.
</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="sect-Wayland-Architecture-wayland_hw_enabling"></a>Hardware Enabling for Wayland</h2></div></div></div><p>
Typically, hardware enabling includes modesetting/display
and EGL/GLES2. On top of that Wayland needs a way to share
buffers efficiently between processes. There are two sides
to that, the client side and the server side.
</p><p>
On the client side we've defined a Wayland EGL platform. In
the EGL model, that consists of the native types
(EGLNativeDisplayType, EGLNativeWindowType and
EGLNativePixmapType) and a way to create those types. In
other words, it's the glue code that binds the EGL stack and
its buffer sharing mechanism to the generic Wayland API. The
EGL stack is expected to provide an implementation of the
Wayland EGL platform. The full API is in the wayland-egl.h
header. The open source implementation in the mesa EGL stack
is in wayland-egl.c and platform_wayland.c.
</p><p>
Under the hood, the EGL stack is expected to define a
vendor-specific protocol extension that lets the client side
EGL stack communicate buffer details with the compositor in
order to share buffers. The point of the wayland-egl.h API
is to abstract that away and just let the client create an
EGLSurface for a Wayland surface and start rendering. The
open source stack uses the drm Wayland extension, which lets
the client discover the drm device to use and authenticate
and then share drm (GEM) buffers with the compositor.
</p><p>
The server side of Wayland is the compositor and core UX for
the vertical, typically integrating task switcher, app
launcher, lock screen in one monolithic application. The
server runs on top of a modesetting API (kernel modesetting,
OpenWF Display or similar) and composites the final UI using
a mix of EGL/GLES2 compositor and hardware overlays if
available. Enabling modesetting, EGL/GLES2 and overlays is
something that should be part of standard hardware bringup.
The extra requirement for Wayland enabling is the
EGL_WL_bind_wayland_display extension that lets the
compositor create an EGLImage from a generic Wayland shared
buffer. It's similar to the EGL_KHR_image_pixmap extension
to create an EGLImage from an X pixmap.
</p><p>
The extension has a setup step where you have to bind the
EGL display to a Wayland display. Then as the compositor
receives generic Wayland buffers from the clients (typically
when the client calls eglSwapBuffers), it will be able to
pass the struct wl_buffer pointer to eglCreateImageKHR as
the EGLClientBuffer argument and with EGL_WAYLAND_BUFFER_WL
as the target. This will create an EGLImage, which can then
be used by the compositor as a texture or passed to the
modesetting code to use as an overlay plane. Again, this is
implemented by the vendor specific protocol extension, which
on the server side will receive the driver specific details
about the shared buffer and turn that into an EGL image when
the user calls eglCreateImageKHR.
</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch02.html">Prev</a> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="ch04.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 2. Types of Compositors </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 4. Wayland Protocol and Model of Operation</td></tr></table></div></body></html>
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Chapter 4. Wayland Protocol and Model of Operation</title><link rel="stylesheet" type="text/css" href="css/default.css"><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"><link rel="home" href="index.html" title="Wayland"><link rel="up" href="index.html" title="Wayland"><link rel="prev" href="ch03.html" title="Chapter 3. Wayland Architecture"><link rel="next" href="ch05.html" title="Chapter 5. X11 Application Support"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 4. Wayland Protocol and Model of Operation</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch03.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="ch05.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="chap-Protocol"></a>Chapter 4. Wayland Protocol and Model of Operation</h1></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl class="toc"><dt><span class="section"><a href="ch04.html#sect-Protocol-Basic-Principles">Basic Principles</a></span></dt><dt><span class="section"><a href="ch04.html#sect-Protocol-Code-Generation">Code Generation</a></span></dt><dt><span class="section"><a href="ch04.html#sect-Protocol-Wire-Format">Wire Format</a></span></dt><dt><span class="section"><a href="ch04.html#sect-Protocol-Interfaces">Interfaces</a></span></dt><dt><span class="section"><a href="ch04.html#sect-Protocol-Versioning">Versioning</a></span></dt><dt><span class="section"><a href="ch04.html#sect-Protocol-Connect-Time">Connect Time</a></span></dt><dt><span class="section"><a href="ch04.html#sect-Protocol-Security-and-Authentication">Security and Authentication</a></span></dt><dt><span class="section"><a href="ch04.html#sect-Protocol-Creating-Objects">Creating Objects</a></span></dt><dt><span class="section"><a href="ch04.html#sect-Protocol-Compositor">Compositor</a></span></dt><dt><span class="section"><a href="ch04.html#sect-Protocol-Surface">Surfaces</a></span></dt><dt><span class="section"><a href="ch04.html#sect-Protocol-Input">Input</a></span></dt><dt><span class="section"><a href="ch04.html#sect-Protocol-Output">Output</a></span></dt><dt><span class="section"><a href="ch04.html#sect-Protocol-data-sharing">Data sharing between clients</a></span></dt></dl></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="sect-Protocol-Basic-Principles"></a>Basic Principles</h2></div></div></div><p>
The Wayland protocol is an asynchronous object oriented protocol. All
requests are method invocations on some object. The requests include
an object ID that uniquely identifies an object on the server. Each
object implements an interface and the requests include an opcode that
identifies which method in the interface to invoke.
</p><p>
The protocol is message-based. A message sent by a client to the server
is called request. A message from the server to a client is called event.
A message has a number of arguments, each of which has a certain type (see
<a class="xref" href="ch04.html#sect-Protocol-Wire-Format" title="Wire Format">the section called “Wire Format”</a> for a list of argument types).
</p><p>
Additionally, the protocol can specify <span class="type">enum</span>s which associate
names to specific numeric enumeration values. These are primarily just
descriptive in nature: at the wire format level enums are just integers.
But they also serve a secondary purpose to enhance type safety or
otherwise add context for use in language bindings or other such code.
This latter usage is only supported so long as code written before these
attributes were introduced still works after; in other words, adding an
enum should not break API, otherwise it puts backwards compatibility at
risk.
</p><p>
<span class="type">enum</span>s can be defined as just a set of integers, or as
bitfields. This is specified via the <span class="type">bitfield</span> boolean
attribute in the <span class="type">enum</span> definition. If this attribute is true,
the enum is intended to be accessed primarily using bitwise operations,
for example when arbitrarily many choices of the enum can be ORed
together; if it is false, or the attribute is omitted, then the enum
arguments are a just a sequence of numerical values.
</p><p>
The <span class="type">enum</span> attribute can be used on either <span class="type">uint</span>
or <span class="type">int</span> arguments, however if the <span class="type">enum</span> is
defined as a <span class="type">bitfield</span>, it can only be used on
<span class="type">uint</span> args.
</p><p>
The server sends back events to the client, each event is emitted from
an object. Events can be error conditions. The event includes the
object ID and the event opcode, from which the client can determine
the type of event. Events are generated both in response to requests
(in which case the request and the event constitutes a round trip) or
spontaneously when the server state changes.
</p><p>
</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
State is broadcast on connect, events are sent
out when state changes. Clients must listen for
these changes and cache the state.
There is no need (or mechanism) to query server state.
</p></li><li class="listitem"><p>
The server will broadcast the presence of a number of global objects,
which in turn will broadcast their current state.
</p></li></ul></div><p>
</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="sect-Protocol-Code-Generation"></a>Code Generation</h2></div></div></div><p>
The interfaces, requests and events are defined in
<code class="filename">protocol/wayland.xml</code>.
This xml is used to generate the function prototypes that can be used by