hn.today

Write your own Wayland compositor: Rendering windows

nekidev.github.io3 points0 comments
Screenshot of Write your own Wayland compositor: Rendering windows

This installment of a wlroots tutorial begins adding window support to a minimal Wayland compositor. It sets up the XDG shell global so clients can create top-level windows, and explains that top-levels represent the main windows in a hierarchy while popups and dropdowns belong to them. Because the tutorial uses wlroots 0.19, protocol globals are created at versions below the latest available: XDG shell version 6, shared memory version 2, and wl_compositor version 6. It also shows how to generate XDG protocol code with wayland-scanner and inspect the compositor’s advertised globals with wayland-info.

A test with weston-simple-shm exposes the globals clients need to draw: enabling wl_shm alone leads to a crash, and Wayland debug logs help reveal the missing wl_compositor global, which lets clients create surfaces. Once that global is added, the client can create a surface, assign it an XDG top-level role, and commit it; the compositor’s new-toplevel listener then fires. The next step is to track windows in compositor-owned wrapper structures, linking each wrapper into a list and listening for its destruction. Rendering still requires handling the XDG surface’s initial configure handshake: clients provide properties such as title and app identity and suggest a preferred size, while the compositor ultimately determines the size.

Read on nekidev.github.io0 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in Programming

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.