<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Wayland on Ozbem</title><link>https://www.ozbem.com/tags/tech/wayland/</link><description>Recent content in Wayland on Ozbem</description><generator>Hugo -- gohugo.io</generator><language>en</language><managingEditor>info@ozbem.com (ebeem)</managingEditor><webMaster>info@ozbem.com (ebeem)</webMaster><copyright>© 2026 ebeem</copyright><lastBuildDate>Thu, 18 Apr 2024 00:00:00 +0000</lastBuildDate><atom:link href="https://www.ozbem.com/tags/tech/wayland/rss.xml" rel="self" type="application/rss+xml"/><item><title>Wayland Protocol &amp; Architecture</title><link>https://www.ozbem.com/posts/tech/wayland/archeticture/</link><pubDate>Thu, 18 Apr 2024 00:00:00 +0000</pubDate><author>info@ozbem.com (ebeem)</author><guid>https://www.ozbem.com/posts/tech/wayland/archeticture/</guid><description>&#10;&lt;div id="outline-container-headline-1" class="outline-3"&gt;&#10;&lt;h3 id="headline-1"&gt;&#10;Introduction&#10;&lt;/h3&gt;&#10;&lt;div id="outline-text-headline-1" class="outline-text-3"&gt;&#10;&lt;p&gt;&#10;&lt;code&gt;Wayland&lt;/code&gt; is a modern, secure display server protocol for Linux and Unix-like operating systems. It is a replacement for the older &lt;code&gt;X11&lt;/code&gt; system and it manages how applications render graphics and windows to your screen.&lt;/p&gt;&#10;&lt;p&gt;&#10;In a &lt;code&gt;Wayland&lt;/code&gt; desktop, you have two components:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;code&gt;Wayland Client&lt;/code&gt; (The Application): This is the individual program (like your web browser or text editor). It draws its own interface and sends the finished pixels to the &lt;code&gt;compositor&lt;/code&gt; to be displayed.&lt;/li&gt;&#10;&lt;li&gt;&lt;code&gt;Wayland Compositor&lt;/code&gt; (The Server/Manager): This is the manager, it handles all hardware input (mouse, keyboard) and forwards it to the proper &lt;code&gt;client&lt;/code&gt; (application like your focused browser), and combines all the individual windows rendered by the clients into the final image you see on your screen.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&#10;&lt;div id="outline-container-headline-2" class="outline-3"&gt;&#10;&lt;h3 id="headline-2"&gt;&#10;Wayland Package&#10;&lt;/h3&gt;&#10;&lt;div id="outline-text-headline-2" class="outline-text-3"&gt;&#10;&lt;p&gt;&#10;Installing the &lt;code&gt;wayland&lt;/code&gt; package (preinstalled on most modern distros) provides the official &lt;code&gt;freedesktop.org&lt;/code&gt; implementation of the protocol. This includes:&lt;/p&gt;&#10;&lt;p&gt;&#10; &lt;code&gt;wayland.xml&lt;/code&gt;: A high-level &lt;code&gt;XML&lt;/code&gt; interface defining the core &lt;code&gt;Wayland&lt;/code&gt; specifications (requests and events). All &lt;code&gt;Wayland&lt;/code&gt; protocols (core and extensions) use this format.&lt;/p&gt;&#10;&lt;p&gt;&#10; &lt;code&gt;wayland-scanner&lt;/code&gt;: A tool that generates &lt;code&gt;C&lt;/code&gt; headers and glue code from &lt;code&gt;XML&lt;/code&gt; protocol files. Many scanners exist in other languages like &lt;code&gt;rust&lt;/code&gt;&lt;/p&gt;&#10;&lt;p&gt;&#10; &lt;code&gt;libwayland-client&lt;/code&gt; &amp;amp; &lt;code&gt;libwayland-server&lt;/code&gt;: C libraries that implement the wire protocol for both components and offer common utilities for handling &lt;code&gt;Wayland&lt;/code&gt; data structures.&lt;/p&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&#10;&lt;div id="outline-container-headline-3" class="outline-3"&gt;&#10;&lt;h3 id="headline-3"&gt;&#10;Wayland Protocol&#10;&lt;/h3&gt;&#10;&lt;div id="outline-text-headline-3" class="outline-text-3"&gt;&#10;&lt;p&gt;&#10;The &lt;code&gt;wayland&lt;/code&gt; protocol is actually easy to understand and very elegant. I will explain the &lt;code&gt;interfaces&lt;/code&gt; first and then I will go over the &lt;code&gt;wiring protocol&lt;/code&gt; and it will start to click.&lt;/p&gt;&#10;&lt;div id="outline-container-headline-4" class="outline-4"&gt;&#10;&lt;h4 id="headline-4"&gt;&#10;Interfaces (XML files)&#10;&lt;/h4&gt;&#10;&lt;div id="outline-text-headline-4" class="outline-text-4"&gt;&#10;&lt;p&gt;&#10;We discussed earlier that there is an &lt;code&gt;xml&lt;/code&gt; file which is &lt;code&gt;wayland.xml&lt;/code&gt; (we call it &lt;code&gt;core&lt;/code&gt;). There are so many other &lt;code&gt;xml&lt;/code&gt; files as well which we call extensions to &lt;code&gt;wayland&lt;/code&gt;, like &lt;code&gt;xdg-shell&lt;/code&gt; which is defines the functionality needed to create windows that can be dragged, resized, etc, in a &lt;code&gt;wayland&lt;/code&gt; desktop. You can browse these &lt;code&gt;xml&lt;/code&gt; files locally, they will be usually in &lt;code&gt;/usr/share/wayland-protocols/&lt;/code&gt;.&lt;/p&gt;&#10;&lt;p&gt;&#10;I find it sometimes very helpful to peak at &lt;a href="https://wayland.app/protocols/"&gt;Wayland Protocols Explorer&lt;/a&gt;, it&amp;#39;s very elegant and it shows all popular &lt;code&gt;Wayland&lt;/code&gt; protocols. I know there are so many protocols, but nobody is expecting you to know them all. You should just be able to read the documentation and know how to use it.&lt;/p&gt;&#10;&lt;p&gt;&#10;You might notice that there are labels to these protocols, and they are listed under a certain subdirectories in the &lt;code&gt;wayland-prtocols&lt;/code&gt; directory locally.&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Core: this is the core &lt;code&gt;wayland&lt;/code&gt; protocols&lt;/li&gt;&#10;&lt;li&gt;Stable: [TODO]&lt;/li&gt;&#10;&lt;li&gt;Staging: [TODO]&lt;/li&gt;&#10;&lt;li&gt;Unstable: [TODO]&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;The &lt;code&gt;XML&lt;/code&gt; file format defines &lt;code&gt;interfaces&lt;/code&gt;, each &lt;code&gt;interface&lt;/code&gt; has many &lt;code&gt;requests&lt;/code&gt;, and &lt;code&gt;events&lt;/code&gt;. Let&amp;#39;s explain this with an example form the core &lt;code&gt;wayland.xml&lt;/code&gt;.&lt;/p&gt;&#10;&lt;p&gt;&#10;There are many interfaces, one of them is &lt;code&gt;wl_surface&lt;/code&gt;, below is the code truncated.&lt;/p&gt;&#10;&lt;div class="src src-xml"&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-xml" data-lang="xml"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="cp"&gt;&amp;lt;?xml version=&amp;#34;1.0&amp;#34; encoding=&amp;#34;UTF-8&amp;#34;?&amp;gt;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nt"&gt;&amp;lt;protocol&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;&amp;#34;wayland&amp;#34;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nt"&gt;&amp;lt;interface&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;&amp;#34;wl_display&amp;#34;&lt;/span&gt; &lt;span class="na"&gt;version=&lt;/span&gt;&lt;span class="s"&gt;&amp;#34;1&amp;#34;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &#9;...&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nt"&gt;&amp;lt;/interface&amp;gt;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; ....&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nt"&gt;&amp;lt;interface&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;&amp;#34;wl_surface&amp;#34;&lt;/span&gt; &lt;span class="na"&gt;version=&lt;/span&gt;&lt;span class="s"&gt;&amp;#34;7&amp;#34;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &#9;&lt;span class="nt"&gt;&amp;lt;description&lt;/span&gt; &lt;span class="na"&gt;summary=&lt;/span&gt;&lt;span class="s"&gt;&amp;#34;an onscreen surface&amp;#34;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &#9; A surface is a rectangular area that may be displayed on zero&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &#9; or more outputs, and shown any number of times at the compositor&amp;#39;s&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &#9; ....&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &#9;&lt;span class="nt"&gt;&amp;lt;/description&amp;gt;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nt"&gt;&amp;lt;enum&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;&amp;#34;error&amp;#34;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nt"&gt;&amp;lt;description&lt;/span&gt; &lt;span class="na"&gt;summary=&lt;/span&gt;&lt;span class="s"&gt;&amp;#34;wl_surface error values&amp;#34;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; These errors can be emitted in response to wl_surface requests.&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nt"&gt;&amp;lt;/description&amp;gt;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nt"&gt;&amp;lt;entry&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;&amp;#34;invalid_scale&amp;#34;&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;&amp;#34;0&amp;#34;&lt;/span&gt; &lt;span class="na"&gt;summary=&lt;/span&gt;&lt;span class="s"&gt;&amp;#34;buffer scale value is invalid&amp;#34;&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &#9; ....&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nt"&gt;&amp;lt;/enum&amp;gt;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nt"&gt;&amp;lt;/interface&amp;gt;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nt"&gt;&amp;lt;/protocol&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&#10;</description></item></channel></rss>