# wayland-mirror/wayland architecture

> Architecture diagram of the GitHub repository wayland-mirror/wayland, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/wayland-mirror/wayland
- Repository: https://github.com/wayland-mirror/wayland

## Overview

Wayland is both a compositor–client protocol and the C libraries that implement its transport and runtime. The main workflow is a client sending protocol requests and buffer-management messages to a compositor, which handles them and forwards relevant input events back to clients; clients render their own content. The repository also includes protocol-description tooling and optional cursor and EGL support. Internal relationships below are limited to README statements and source-index references or excerpts; some feature internals were not sampled.

Main entry points: [`src/wayland-client.c`](https://github.com/wayland-mirror/wayland/blob/main/src/wayland-client.c) (Client library), [`src/wayland-server.c`](https://github.com/wayland-mirror/wayland/blob/main/src/wayland-server.c) (Server library), [`src/connection.c`](https://github.com/wayland-mirror/wayland/blob/main/src/connection.c) (Wire connection), [`src/wayland-util.c`](https://github.com/wayland-mirror/wayland/blob/main/src/wayland-util.c) (Protocol utilities)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_protocol["Protocol"]
  node_protocol_spec["Protocol definition<br/>[wayland.xml]"]
  node_scanner["Protocol scanner<br/>[scanner.c]"]
end

subgraph group_runtime["Core runtime"]
  node_client["Client library<br/>[wayland-client.c]"]
  node_server["Server library<br/>[wayland-server.c]"]
  node_connection["Wire connection<br/>[connection.c]"]
  node_event_loop["Event loop<br/>[event-loop.c]"]
  node_shm["Shared memory<br/>[wayland-shm.c]"]
end

subgraph group_features["Client features"]
  node_cursor["Cursor themes<br/>[wayland-cursor.c]"]
  node_xcursor["Xcursor loading<br/>[xcursor.c]"]
  node_egl["EGL window support<br/>[wayland-egl.c]"]
end

subgraph group_support["Shared support"]
  node_util["Protocol utilities<br/>[wayland-util.c]"]
  node_os["OS compatibility<br/>[wayland-os.c]"]
end

node_client_app(("Client app"))
node_compositor(("Compositor"))

node_client_app -->|"sends requests"| node_client
node_client -->|"exchanges protocol"| node_compositor
node_compositor -->|"forwards input"| node_client
node_compositor -->|"uses library"| node_server
node_client -->|"uses transport"| node_connection
node_server -->|"uses transport"| node_connection
node_server -->|"uses event loop"| node_event_loop
node_client -->|"uses utilities"| node_util
node_server -->|"uses utilities"| node_util
node_connection -->|"uses utilities"| node_util
node_connection -->|"uses OS helpers"| node_os
node_event_loop -->|"uses OS helpers"| node_os
node_shm -->|"uses OS helpers"| node_os
node_cursor -->|"loads images"| node_xcursor
node_cursor -->|"creates buffers"| node_client
node_egl -->|"uses utilities"| node_util

click node_protocol_spec "https://github.com/wayland-mirror/wayland/blob/main/protocol/wayland.xml"
click node_scanner "https://github.com/wayland-mirror/wayland/blob/main/src/scanner.c"
click node_client "https://github.com/wayland-mirror/wayland/blob/main/src/wayland-client.c"
click node_server "https://github.com/wayland-mirror/wayland/blob/main/src/wayland-server.c"
click node_connection "https://github.com/wayland-mirror/wayland/blob/main/src/connection.c"
click node_event_loop "https://github.com/wayland-mirror/wayland/blob/main/src/event-loop.c"
click node_shm "https://github.com/wayland-mirror/wayland/blob/main/src/wayland-shm.c"
click node_util "https://github.com/wayland-mirror/wayland/blob/main/src/wayland-util.c"
click node_os "https://github.com/wayland-mirror/wayland/blob/main/src/wayland-os.c"
click node_cursor "https://github.com/wayland-mirror/wayland/blob/main/cursor/wayland-cursor.c"
click node_xcursor "https://github.com/wayland-mirror/wayland/blob/main/cursor/xcursor.c"
click node_egl "https://github.com/wayland-mirror/wayland/blob/main/egl/wayland-egl.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_protocol_spec,node_scanner,node_client_app toneBlue
class node_client,node_server,node_connection,node_event_loop,node_shm toneAmber
class node_cursor,node_xcursor,node_egl toneMint
class node_util,node_os toneRose
class node_compositor toneIndigo
```

## Components

### Protocol

- [Protocol definition](https://github.com/wayland-mirror/wayland/blob/main/protocol/wayland.xml): `protocol/wayland.xml`
- [Protocol scanner](https://github.com/wayland-mirror/wayland/blob/main/src/scanner.c): `src/scanner.c`

### Core runtime

- [Client library](https://github.com/wayland-mirror/wayland/blob/main/src/wayland-client.c): `src/wayland-client.c`
- [Server library](https://github.com/wayland-mirror/wayland/blob/main/src/wayland-server.c): `src/wayland-server.c`
- [Wire connection](https://github.com/wayland-mirror/wayland/blob/main/src/connection.c): `src/connection.c`
- [Event loop](https://github.com/wayland-mirror/wayland/blob/main/src/event-loop.c): `src/event-loop.c`
- [Shared memory](https://github.com/wayland-mirror/wayland/blob/main/src/wayland-shm.c): `src/wayland-shm.c`

### Client features

- [Cursor themes](https://github.com/wayland-mirror/wayland/blob/main/cursor/wayland-cursor.c): `cursor/wayland-cursor.c`
- [Xcursor loading](https://github.com/wayland-mirror/wayland/blob/main/cursor/xcursor.c): `cursor/xcursor.c`
- [EGL window support](https://github.com/wayland-mirror/wayland/blob/main/egl/wayland-egl.c): `egl/wayland-egl.c`

### Shared support

- [Protocol utilities](https://github.com/wayland-mirror/wayland/blob/main/src/wayland-util.c): `src/wayland-util.c`
- [OS compatibility](https://github.com/wayland-mirror/wayland/blob/main/src/wayland-os.c): `src/wayland-os.c`

### Other components

- **Client app**
- **Compositor**

## Connections

- Client app → Client library: sends requests (evidence: `README.md`)
- Client library → Compositor: exchanges protocol (evidence: `README.md`)
- Compositor → Client library: forwards input (evidence: `README.md`)
- Compositor → Server library: uses library (evidence: `README.md`)
- Client library → Wire connection: uses transport (evidence: `src/wayland-client.c`)
- Server library → Wire connection: uses transport (evidence: `src/wayland-server.c`)
- Server library → Event loop: uses event loop (evidence: `src/event-loop.c`)
- Client library → Protocol utilities: uses utilities (evidence: `src/wayland-client.c`)
- Server library → Protocol utilities: uses utilities (evidence: `src/wayland-server.c`)
- Wire connection → Protocol utilities: uses utilities (evidence: `src/connection.c`)
- Wire connection → OS compatibility: uses OS helpers (evidence: `src/connection.c`)
- Event loop → OS compatibility: uses OS helpers (evidence: `src/event-loop.c`)
- Shared memory → OS compatibility: uses OS helpers (evidence: `src/wayland-shm.c`)
- Cursor themes → Xcursor loading: loads images (evidence: `cursor/wayland-cursor.c`)
- Cursor themes → Client library: creates buffers (evidence: `cursor/wayland-cursor.c`)
- EGL window support → Protocol utilities: uses utilities (evidence: `egl/wayland-egl.c`)
