v0.3.0 96f3aeb

README.md RawHistoryFolder

WLTurbo - Wayland Client Library for Go

A performance-focused Wayland client library that provides the foundational protocol implementation for building Wayland applications and libraries.

Overview

WLTurbo is a low-level Wayland client library that handles core protocol communication. It serves as the base layer for higher-level libraries like libwldevices-go which implement specific Wayland protocol extensions.

Architecture

WLTurbo provides the foundational Wayland client infrastructure:

  • Core Protocol Objects: Display, Registry, Compositor, Surface, Seat, Region
  • Event Dispatching: Efficient routing of Wayland events to handlers
  • Connection Management: Unix socket communication with the compositor
  • Memory Management: Shared memory support via file descriptor passing

Higher-level protocol implementations (virtual input devices, output management, etc.) are intentionally left to specialized libraries that build on top of WLTurbo.

Generated protocols

protocol/core provides core Wayland (including data-device); protocol/xdgshell provides xdg-shell; protocol/linuxdmabuf provides linux-dmabuf v4 feedback; protocol/drmsyncobj provides linux-drm-syncobj v1; protocol/viewporter provides viewporter; protocol/fractionalscale provides fractional-scale v1; and protocol/textinput provides text-input v3. Bindings handle wire messages and object lifecycle; applications decide compositor policy.

After display.Roundtrip() discovers globals, call display.Registry().BindNegotiated(interfaceName, supportedVersion, proxy) to bind at the lesser of the advertised and supported versions. It returns the negotiated version; use errors.Is(err, wlturbo.ErrGlobalNotFound) to handle absent optional globals.

Features

  • Stream framing: messages split across or coalesced within socket reads are framed exactly; event bodies are not copied.
  • Descriptor ownership: received FDs belong to the event that declares them and are closed if a handler does not take them.
  • Object lifecycle: destroyed objects stay as zombies until delete_id, so events already in flight are dropped instead of failing the connection.
  • Version checks: generated requests newer than the bound object version return ErrVersionTooLow before anything is sent.
  • Allocation-free requests: marshaling fixed-size requests does not allocate.

Quick Start

package main

import (
    "github.com/bnema/wlturbo/wl"
)

func main() {
    // Connect to Wayland display
    display, err := wl.Connect("")
    if err != nil {
        panic(err)
    }
    defer display.Close()

    // Basic event loop. Handlers run inside Dispatch and must not call
    // Dispatch or Roundtrip on the same display.
    for {
        if err := display.Dispatch(); err != nil {
            break
        }
    }
}

For device control and input injection, use libwldevices-go which builds on top of WLTurbo.

Requirements

  • Go 1.27+
  • Linux with Wayland compositor
  • Unix sockets support

License

MIT License - see LICENSE file for details

Contributing

Contributions welcome! Areas of focus:

  • Performance improvements
  • Additional protocol object support
  • Documentation and examples
  • Benchmark suite
source
1# WLTurbo - Wayland Client Library for Go
2
3A performance-focused Wayland client library that provides the foundational protocol implementation for building Wayland applications and libraries.
4
5## Overview
6
7WLTurbo is a low-level Wayland client library that handles core protocol communication. It serves as the base layer for higher-level libraries like [libwldevices-go](https://github.com/bnema/libwldevices-go) which implement specific Wayland protocol extensions.
8
9## Architecture
10
11WLTurbo provides the foundational Wayland client infrastructure:
12
13- **Core Protocol Objects**: Display, Registry, Compositor, Surface, Seat, Region
14- **Event Dispatching**: Efficient routing of Wayland events to handlers
15- **Connection Management**: Unix socket communication with the compositor
16- **Memory Management**: Shared memory support via file descriptor passing
17
18Higher-level protocol implementations (virtual input devices, output management, etc.) are intentionally left to specialized libraries that build on top of WLTurbo.
19
20## Generated protocols
21
22`protocol/core` provides core Wayland (including data-device); `protocol/xdgshell` provides xdg-shell; `protocol/linuxdmabuf` provides linux-dmabuf v4 feedback; `protocol/drmsyncobj` provides linux-drm-syncobj v1; `protocol/viewporter` provides viewporter; `protocol/fractionalscale` provides fractional-scale v1; and `protocol/textinput` provides text-input v3. Bindings handle wire messages and object lifecycle; applications decide compositor policy.
23
24After `display.Roundtrip()` discovers globals, call `display.Registry().BindNegotiated(interfaceName, supportedVersion, proxy)` to bind at the lesser of the advertised and supported versions. It returns the negotiated version; use `errors.Is(err, wlturbo.ErrGlobalNotFound)` to handle absent optional globals.
25
26## Features
27
28- **Stream framing**: messages split across or coalesced within socket reads are framed exactly; event bodies are not copied.
29- **Descriptor ownership**: received FDs belong to the event that declares them and are closed if a handler does not take them.
30- **Object lifecycle**: destroyed objects stay as zombies until `delete_id`, so events already in flight are dropped instead of failing the connection.
31- **Version checks**: generated requests newer than the bound object version return `ErrVersionTooLow` before anything is sent.
32- **Allocation-free requests**: marshaling fixed-size requests does not allocate.
33
34## Quick Start
35
36```go
37package main
38
39import (
40    "github.com/bnema/wlturbo/wl"
41)
42
43func main() {
44    // Connect to Wayland display
45    display, err := wl.Connect("")
46    if err != nil {
47        panic(err)
48    }
49    defer display.Close()
50
51    // Basic event loop. Handlers run inside Dispatch and must not call
52    // Dispatch or Roundtrip on the same display.
53    for {
54        if err := display.Dispatch(); err != nil {
55            break
56        }
57    }
58}
59```
60
61For device control and input injection, use [libwldevices-go](https://github.com/bnema/libwldevices-go) which builds on top of WLTurbo.
62
63## Requirements
64
65- **Go 1.27+**
66- **Linux** with Wayland compositor
67- **Unix sockets** support
68
69## License
70
71MIT License - see LICENSE file for details
72
73## Contributing
74
75Contributions welcome! Areas of focus:
76- Performance improvements
77- Additional protocol object support
78- Documentation and examples
79- Benchmark suite

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 8

↑↓ moveenter openesc close