<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Tinmc189623</title>
    <description>The latest articles on DEV Community by Tinmc189623 (@tinmc189623).</description>
    <link>https://dev.to/tinmc189623</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4245362%2F0067e37a-d5c8-4dcf-9766-ca8942241b1e.png</url>
      <title>DEV Community: Tinmc189623</title>
      <link>https://dev.to/tinmc189623</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tinmc189623"/>
    <language>en</language>
    <item>
      <title>Running stock libwayland on a from-scratch x86_64 microkernel</title>
      <dc:creator>Tinmc189623</dc:creator>
      <pubDate>Sun, 15 Nov 2026 05:06:01 +0000</pubDate>
      <link>https://dev.to/tinmc189623/running-stock-libwayland-on-a-from-scratch-x8664-microkernel-1ekh</link>
      <guid>https://dev.to/tinmc189623/running-stock-libwayland-on-a-from-scratch-x8664-microkernel-1ekh</guid>
      <description>&lt;p&gt;Zhaoxu OS is a small x86_64 operating system built around the Yuanshuo microkernel. Drivers run in Ring 3. The desktop, called Aqua Desktop Environment, also runs in Ring 3. There is no Linux ABI, no glibc, and no fork/exec. User programs are freestanding ZXE v1 executables loaded at a random base with W^X page permissions.&lt;/p&gt;

&lt;p&gt;For a while the Wayland support was custom. A hand-written client opened &lt;code&gt;/run/wayland-0&lt;/code&gt;, marshalled messages byte by byte, and passed a memfd with &lt;code&gt;SCM_RIGHTS&lt;/code&gt;. That proved the transport, but it was not Wayland compatibility. The goal we set next was stricter: compile the upstream libwayland client core and run it against our server. No rewritten protocol layer. No "Wayland-like" API.&lt;/p&gt;

&lt;p&gt;This is the story of what that took, including the bugs that only appear when your libc is a few hundred lines and your kernel headers are on the same include path as the real ones.&lt;/p&gt;

&lt;h2&gt;
  
  
  The stack
&lt;/h2&gt;

&lt;p&gt;The moving parts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;libwayland 1.23.1: &lt;code&gt;wayland-client.c&lt;/code&gt;, &lt;code&gt;wayland-util.c&lt;/code&gt;, and &lt;code&gt;connection.c&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Generated core and xdg-shell client bindings from &lt;code&gt;wayland-scanner&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;libffi 3.4.6, x86_64 SysV &lt;code&gt;ffi_call&lt;/code&gt; path only.&lt;/li&gt;
&lt;li&gt;A small POSIX compatibility layer for allocation, strings, errno, pthread stubs, sockets, poll, and time.&lt;/li&gt;
&lt;li&gt;Kernel AF_UNIX sockets, a per-process descriptor table, &lt;code&gt;SCM_RIGHTS&lt;/code&gt;, &lt;code&gt;eventfd&lt;/code&gt;, &lt;code&gt;timerfd&lt;/code&gt;, and &lt;code&gt;epoll&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The client binary is statically linked and still has zero dynamic imports. libwayland's public API stays intact, but the implementation underneath is ours.&lt;/p&gt;

&lt;h2&gt;
  
  
  Kernel side: the event loop ABI
&lt;/h2&gt;

&lt;p&gt;libwayland's event loop expects &lt;code&gt;epoll&lt;/code&gt;, &lt;code&gt;eventfd&lt;/code&gt;, and &lt;code&gt;timerfd&lt;/code&gt; to exist. We added them as syscalls 61 through 67:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;eventfd&lt;/code&gt;, &lt;code&gt;timerfd_create&lt;/code&gt;, &lt;code&gt;timerfd_settime&lt;/code&gt;, &lt;code&gt;timerfd_gettime&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;epoll_create1&lt;/code&gt;, &lt;code&gt;epoll_ctl&lt;/code&gt;, &lt;code&gt;epoll_wait&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Descriptors live in a per-process table above 64 (&lt;code&gt;ZFD_BASE&lt;/code&gt;). The legacy VFS keeps its low numbers. An epoll object holds up to 32 registrations, is level-triggered, and waits in 1 ms scheduler slices. That is not going to win a benchmark against Linux, but it is enough for a single-threaded client and it is honest about its limits.&lt;/p&gt;

&lt;p&gt;A detail that matters for compatibility: libwayland often passes names such as &lt;code&gt;O_NONBLOCK&lt;/code&gt; and &lt;code&gt;MSG_DONTWAIT&lt;/code&gt; straight through. The kernel has to agree with those values. It also has to agree about when they apply, which brings us to the first real bug.&lt;/p&gt;

&lt;h2&gt;
  
  
  The socket drain that blocked forever
&lt;/h2&gt;

&lt;p&gt;The stock client connected, sent 24 bytes, received 136 bytes of registry globals, and then stopped. No error. No crash. The serial log simply ended after the receive.&lt;/p&gt;

&lt;p&gt;The client was stuck in &lt;code&gt;wl_connection_read&lt;/code&gt;. That function drains the display socket in a loop:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="n"&gt;len&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;wl_os_recvmsg_cloexec&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;connection&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;fd&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;msg&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;MSG_DONTWAIT&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;MSG_DONTWAIT&lt;/code&gt; is per call. The descriptor itself is blocking. Our kernel ignored the flags argument on &lt;code&gt;recvmsg&lt;/code&gt;, so the first call read the available data and the second call slept forever waiting for more.&lt;/p&gt;

&lt;p&gt;The fix is small, but it is the kind of small that takes a while to find:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;nonblock&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;entry&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;flags&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="no"&gt;ZFD_O_NONBLOCK&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt;
               &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;flags&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="no"&gt;ZMSG_DONTWAIT&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;sendmsg&lt;/code&gt; needed the same treatment. After that the client received the registry, bound &lt;code&gt;wl_compositor&lt;/code&gt; and &lt;code&gt;wl_shm&lt;/code&gt;, submitted a 320x240 frame through &lt;code&gt;SCM_RIGHTS&lt;/code&gt;, and exited 0.&lt;/p&gt;

&lt;h2&gt;
  
  
  The include path that ate libc
&lt;/h2&gt;

&lt;p&gt;The second bug was entirely a build problem. Our stock sources were compiled with the kernel include directory on the command line, because the demo needed &lt;code&gt;userlib.h&lt;/code&gt; and the ZXE entry point. That directory contains a kernel header named &lt;code&gt;poll.h&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The compiler saw:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="cp"&gt;#include &amp;lt;poll.h&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and resolved it to the kernel's definition, which declares &lt;code&gt;ZPOLLIN&lt;/code&gt;, &lt;code&gt;ZPOLLOUT&lt;/code&gt;, and &lt;code&gt;struct zpollfd&lt;/code&gt;. libwayland then failed with errors like "array type has incomplete element type struct pollfd" and "POLLOUT undeclared".&lt;/p&gt;

&lt;p&gt;The fix was to stop mixing the two worlds. The upstream libwayland objects, libffi, and the compatibility layer compile with only the third-party and user include paths. Only the demo and &lt;code&gt;userlib.c&lt;/code&gt; see &lt;code&gt;kernel/include&lt;/code&gt;. It sounds obvious once you have the error message. It is much less obvious when a single compiler invocation is building five different layers of the system.&lt;/p&gt;

&lt;h2&gt;
  
  
  Porting libffi without a libc
&lt;/h2&gt;

&lt;p&gt;libwayland does not call listeners directly. It builds a &lt;code&gt;ffi_cif&lt;/code&gt; and calls &lt;code&gt;ffi_call&lt;/code&gt;, because the event signature is only known at runtime.&lt;/p&gt;

&lt;p&gt;Porting all of libffi would have been unnecessary. The client only needs the SysV call path:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;ffi_prep_cif&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;ffi_type_*&lt;/code&gt; descriptors&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;ffi_call&lt;/code&gt; and the &lt;code&gt;ffi_call_unix64&lt;/code&gt; assembly entry&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Closure support, Windows EFI entry points, and the trampoline code are not used. We compile the objects with &lt;code&gt;-fvisibility=hidden&lt;/code&gt;, place every function in its own section, and link with &lt;code&gt;--gc-sections&lt;/code&gt;. That lets the linker drop the unused Windows and closure code instead of dragging in undefined symbols.&lt;/p&gt;

&lt;p&gt;There is one more piece: &lt;code&gt;ffi_call&lt;/code&gt; uses the platform's calling convention, so the generated code must match the ABI. On x86_64 SysV that means the first six integer arguments in registers, with &lt;code&gt;rdi&lt;/code&gt;/&lt;code&gt;rsi&lt;/code&gt; for the listener's &lt;code&gt;data&lt;/code&gt; and &lt;code&gt;target&lt;/code&gt;. We verified the path with a tiny self-test in the same binary:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="nf"&gt;ffi_prep_cif&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;cif&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;FFI_DEFAULT_ABI&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;ffi_type_sint32&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;types&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nf"&gt;ffi_call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;cif&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;FFI_FN&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ffi_add&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;values&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The client prints &lt;code&gt;ffi 42&lt;/code&gt; before it even connects. If that line is wrong, the rest of the event dispatch is not worth debugging.&lt;/p&gt;

&lt;h2&gt;
  
  
  Generating the protocol bindings
&lt;/h2&gt;

&lt;p&gt;The release tarball does not ship generated protocol files, and we did not want a checked-in blob whose provenance was unclear. We built &lt;code&gt;wayland-scanner&lt;/code&gt; from the same source with libxml2 and expat, then generated:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;wayland-client-protocol.h&lt;/code&gt; and &lt;code&gt;wayland-protocol.c&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;xdg-shell-client-protocol.h&lt;/code&gt; and &lt;code&gt;xdg-shell-protocol.c&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The generated files are vendored, so a normal build does not need the scanner. The XML files stay next to them under &lt;code&gt;protocol/&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  FreeType and the header that was included twice
&lt;/h2&gt;

&lt;p&gt;The desktop also needed a real font engine. We vendored FreeType 2.13.3, configured for memory faces only: no zlib, PNG, bzip2, HarfBuzz, Brotli, environment properties, or file-stream support. The image carries the TrueType, CFF, sfnt, psnames, psaux, and smooth rasterizer modules. Only MiSans, MiSans Global, and Inter are accepted as fonts.&lt;/p&gt;

&lt;p&gt;The first attempt returned error 11 from &lt;code&gt;FT_New_Memory_Face&lt;/code&gt;. Error 11 is &lt;code&gt;FT_Err_Missing_Module&lt;/code&gt;, which is not what you expect for a perfectly valid TTF.&lt;/p&gt;

&lt;p&gt;The cause was a custom &lt;code&gt;ftmodule.h&lt;/code&gt;. I had given it an include guard, like any sane header. But &lt;code&gt;ftinit.c&lt;/code&gt; includes that file twice on purpose: once to declare the module symbols and once to expand the module array. The guard made the second include expand to nothing, so the array was empty. FreeType initialized successfully and then had no driver for any font.&lt;/p&gt;

&lt;p&gt;Removing the guard fixed it. The file now says so in a comment, because it is the sort of thing that will otherwise be reintroduced by the next person who sees a header without a guard.&lt;/p&gt;

&lt;p&gt;A second issue was optimization. With this freestanding configuration, the smooth rasterizer crashed inside &lt;code&gt;FT_Render_Glyph&lt;/code&gt; at &lt;code&gt;-O1&lt;/code&gt; and &lt;code&gt;-O2&lt;/code&gt;, while the same code at &lt;code&gt;-O0&lt;/code&gt; rendered correctly. The rest of FreeType is happy with &lt;code&gt;-O2&lt;/code&gt;, so only &lt;code&gt;smooth.c&lt;/code&gt; is compiled at &lt;code&gt;-O0&lt;/code&gt;. I would rather have a working, slightly slower rasterizer than a fast one that faults on a CJK glyph.&lt;/p&gt;

&lt;h2&gt;
  
  
  Text that bobbed and flipped
&lt;/h2&gt;

&lt;p&gt;The first FreeType-backed desktop build had a more visible problem: glyphs were vertically offset, and some looked flipped. The baseline was not stable across characters.&lt;/p&gt;

&lt;p&gt;The adapter was passing &lt;code&gt;slot-&amp;gt;bitmap_top&lt;/code&gt; directly as the offset from the top of the line. &lt;code&gt;bitmap_top&lt;/code&gt; is measured upward from the baseline. &lt;code&gt;render.c&lt;/code&gt; expects a downward offset from the line top. Positive values therefore pushed glyphs below the line, and the amount changed with each glyph's height. That is the bobbing.&lt;/p&gt;

&lt;p&gt;The correct conversion is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="n"&gt;i32&lt;/span&gt; &lt;span class="n"&gt;ascent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i32&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;g_face&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;metrics&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ascender&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;32&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;by&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i8&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ascent&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="n"&gt;slot&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;bitmap_top&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Advances were also being truncated in one path and rounded in another. They are now rounded consistently, so spacing stops drifting.&lt;/p&gt;

&lt;p&gt;The fix is three lines. The screenshot that confirmed it was worth the build time: the welcome window, calculator, menu bar, and Dock all render upright text sitting on the baseline.&lt;/p&gt;

&lt;h2&gt;
  
  
  The cursor that disappeared when you stopped moving
&lt;/h2&gt;

&lt;p&gt;The compositor draws the pointer into a system-RAM back buffer, presents only damaged rectangles, and restores the pixels under the previous cursor before each repaint. That design is fine until a damage repaint arrives with no new mouse packet.&lt;/p&gt;

&lt;p&gt;The loop was doing this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;ready&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;mouse_ready&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ready&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;dwc_cursor_draw&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mx&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;my&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ready&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;dwc_present_cursor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mx&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;my&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;else&lt;/span&gt;
    &lt;span class="nf"&gt;dwc_hide_cursor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A stationary mouse can still have valid coordinates, but there may be no fresh report. On a repaint triggered by the clock or an animation, &lt;code&gt;ready&lt;/code&gt; could be false and the cursor was hidden. If nothing moved afterwards, it stayed hidden.&lt;/p&gt;

&lt;p&gt;The fix is to remember that a pointer has been seen at all:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;mouse_ready&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;g_pointer_seen&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;ready&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;g_pointer_seen&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now the pointer is composited at its last known position even when the latest sample contains no new data. Six framebuffer captures taken 450 ms apart differ only in the menu-bar clock area; the cursor rectangle is byte-identical.&lt;/p&gt;

&lt;h2&gt;
  
  
  What runs today
&lt;/h2&gt;

&lt;p&gt;The regression client prints:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[wlstock] ffi 42
[wlstock] connected
[wlstock] registry requested
[wlstock] globals bound
[wlstock] frame committed
[wlstock] WLSTOCK exit 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On the server side:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[wayland] commit 320x240 stride=1280 first=0x0x00000000ff3366cc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That is upstream libwayland's client core, upstream libffi, and generated xdg-shell bindings running on a kernel with no Linux ABI. FreeType runs the desktop font path, and the text and cursor are stable in real framebuffer captures.&lt;/p&gt;

&lt;p&gt;There are still open items. dma-buf and GPU composition are blocked on the test host: the Windows QEMU &lt;code&gt;virtio-gpu-gl&lt;/code&gt; device offers the virgl feature but its virglrenderer does not register guest resources, so &lt;code&gt;SET_SCANOUT&lt;/code&gt; returns &lt;code&gt;0x1203&lt;/code&gt;. Vulkan and OpenGL are not implemented yet. Unmodified stock applications such as &lt;code&gt;weston-terminal&lt;/code&gt; still need more of the POSIX surface, including &lt;code&gt;shm_open&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Things I would tell the next person
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;"Stock compatibility" is mostly an ABI scavenger hunt. The interesting bugs are in flag semantics, header resolution, and error paths, not in the protocol itself.&lt;/li&gt;
&lt;li&gt;Kernel headers and libc headers must not share an include path. A file named &lt;code&gt;poll.h&lt;/code&gt; is enough to cost you an afternoon.&lt;/li&gt;
&lt;li&gt;If a third-party header is included twice by design, do not add an include guard. Read the including file first.&lt;/li&gt;
&lt;li&gt;Vendored C code compiles differently under freestanding flags. Test the real glyph, not just the return code.&lt;/li&gt;
&lt;li&gt;A frame counter and a diff against the previous framebuffer are more useful than a screenshot. Six images told us more about the cursor than a day of reading the compositor.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Zhaoxu OS is a Nexsteaduser project. Contact: &lt;a href="mailto:admin@nexsteaduser.com"&gt;admin@nexsteaduser.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Copyright © 2026 Nexsteaduser. All Rights Reserved.&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>computerscience</category>
      <category>development</category>
    </item>
  </channel>
</rss>
