# xquartz/wayland architecture

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

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

## Overview

Wayland defines a compositor–client protocol and provides libraries implementing its client and server sides. The main workflow is a client connecting to a compositor, sending protocol requests and buffer-related data, and receiving events; the compositor handles input and forwards relevant events to clients. The repository also includes protocol metadata and scanner tooling, shared-memory support, EGL integration, and cursor-theme loading. Some runtime links are documented rather than visible in the excerpts, so those are marked unverified.

Main entry points: [`src/wayland-server.c`](https://github.com/xquartz/wayland/blob/main-apple/src/wayland-server.c) (Server API), [`src/wayland-client.c`](https://github.com/xquartz/wayland/blob/main-apple/src/wayland-client.c) (Client API), [`src/connection.c`](https://github.com/xquartz/wayland/blob/main-apple/src/connection.c) (Wire connection), [`cursor/wayland-cursor.c`](https://github.com/xquartz/wayland/blob/main-apple/cursor/wayland-cursor.c) (Cursor themes)

## Diagram (Mermaid)

```mermaid
flowchart TD

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

subgraph group_client["Client runtime"]
  node_client_api["Client API<br/>[wayland-client.c]"]
  node_client_header["Client API declarations"]
  node_connection["Wire connection<br/>[connection.c]"]
  node_os_support["OS support<br/>[wayland-os.c]"]
  node_shared_util["Shared utilities<br/>[wayland-util.c]"]
  node_private_protocol["Protocol encoding<br/>[wayland-private.h]"]
end

subgraph group_server["Server runtime"]
  node_server_api["Server API<br/>[wayland-server.c]"]
  node_server_header["Server API declarations"]
  node_event_loop["Event loop<br/>[event-loop.c]"]
  node_shm["Shared memory<br/>[wayland-shm.c]"]
end

subgraph group_extensions["Client extensions"]
  node_cursor_theme["Cursor themes<br/>[wayland-cursor.c]"]
  node_xcursor["Xcursor loading<br/>[xcursor.c]"]
  node_cursor_data["Built-in cursor data<br/>[cursor-data.h]"]
  node_cursor_os["Cursor OS support<br/>[os-compatibility.c]"]
  node_egl["Wayland EGL window<br/>[wayland-egl.c]"]
  node_egl_backend["EGL backend interface"]
end

node_client_app(("Client application"))
node_compositor(("Compositor"))

node_client_app -.->|"uses"| node_client_api
node_client_api -.->|"transfers messages"| node_connection
node_client_api -->|"marshals requests"| node_private_protocol
node_client_api -->|"implements API"| node_client_header
node_client_api -->|"uses OS support"| node_os_support
node_connection -->|"uses"| node_shared_util
node_connection -->|"uses OS support"| node_os_support
node_compositor -.->|"uses"| node_server_api
node_server_api -.->|"exchanges messages"| node_connection
node_server_api -->|"implements API"| node_server_header
node_server_api -->|"uses"| node_shared_util
node_server_api -->|"uses OS support"| node_os_support
node_shm -->|"uses server API"| node_server_api
node_event_loop -->|"uses server API"| node_server_header
node_client_app -->|"follows protocol"| node_protocol_xml
node_compositor -->|"follows protocol"| node_protocol_xml
node_scanner -.->|"reads definitions"| node_protocol_xml
node_cursor_theme -->|"loads themes"| node_xcursor
node_cursor_theme -->|"uses built-in data"| node_cursor_data
node_cursor_theme -->|"allocates shared files"| node_cursor_os
node_egl -->|"uses backend interface"| node_egl_backend
node_egl -.->|"provides EGL integration"| node_client_app

click node_protocol_xml "https://github.com/xquartz/wayland/blob/main-apple/protocol/wayland.xml"
click node_scanner "https://github.com/xquartz/wayland/blob/main-apple/src/scanner.c"
click node_client_api "https://github.com/xquartz/wayland/blob/main-apple/src/wayland-client.c"
click node_client_header "https://github.com/xquartz/wayland/blob/main-apple/src/wayland-client-core.h"
click node_connection "https://github.com/xquartz/wayland/blob/main-apple/src/connection.c"
click node_os_support "https://github.com/xquartz/wayland/blob/main-apple/src/wayland-os.c"
click node_shared_util "https://github.com/xquartz/wayland/blob/main-apple/src/wayland-util.c"
click node_server_api "https://github.com/xquartz/wayland/blob/main-apple/src/wayland-server.c"
click node_server_header "https://github.com/xquartz/wayland/blob/main-apple/src/wayland-server-core.h"
click node_event_loop "https://github.com/xquartz/wayland/blob/main-apple/src/event-loop.c"
click node_shm "https://github.com/xquartz/wayland/blob/main-apple/src/wayland-shm.c"
click node_private_protocol "https://github.com/xquartz/wayland/blob/main-apple/src/wayland-private.h"
click node_cursor_theme "https://github.com/xquartz/wayland/blob/main-apple/cursor/wayland-cursor.c"
click node_xcursor "https://github.com/xquartz/wayland/blob/main-apple/cursor/xcursor.c"
click node_cursor_data "https://github.com/xquartz/wayland/blob/main-apple/cursor/cursor-data.h"
click node_cursor_os "https://github.com/xquartz/wayland/blob/main-apple/cursor/os-compatibility.c"
click node_egl "https://github.com/xquartz/wayland/blob/main-apple/egl/wayland-egl.c"
click node_egl_backend "https://github.com/xquartz/wayland/blob/main-apple/egl/wayland-egl-backend.h"

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_xml,node_scanner,node_client_app toneBlue
class node_client_api,node_client_header,node_connection,node_os_support,node_shared_util,node_private_protocol toneAmber
class node_server_api,node_server_header,node_event_loop,node_shm toneMint
class node_cursor_theme,node_xcursor,node_cursor_data,node_cursor_os,node_egl,node_egl_backend toneRose
class node_compositor toneIndigo
```

## Components

### Protocol

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

### Client runtime

- [Client API](https://github.com/xquartz/wayland/blob/main-apple/src/wayland-client.c): `src/wayland-client.c`
- [Client API declarations](https://github.com/xquartz/wayland/blob/main-apple/src/wayland-client-core.h): `src/wayland-client-core.h`
- [Wire connection](https://github.com/xquartz/wayland/blob/main-apple/src/connection.c): `src/connection.c`
- [OS support](https://github.com/xquartz/wayland/blob/main-apple/src/wayland-os.c): `src/wayland-os.c`
- [Shared utilities](https://github.com/xquartz/wayland/blob/main-apple/src/wayland-util.c): `src/wayland-util.c`
- [Protocol encoding](https://github.com/xquartz/wayland/blob/main-apple/src/wayland-private.h): `src/wayland-private.h`

### Server runtime

- [Server API](https://github.com/xquartz/wayland/blob/main-apple/src/wayland-server.c): `src/wayland-server.c`
- [Server API declarations](https://github.com/xquartz/wayland/blob/main-apple/src/wayland-server-core.h): `src/wayland-server-core.h`
- [Event loop](https://github.com/xquartz/wayland/blob/main-apple/src/event-loop.c): `src/event-loop.c`
- [Shared memory](https://github.com/xquartz/wayland/blob/main-apple/src/wayland-shm.c): `src/wayland-shm.c`

### Client extensions

- [Cursor themes](https://github.com/xquartz/wayland/blob/main-apple/cursor/wayland-cursor.c): `cursor/wayland-cursor.c`
- [Xcursor loading](https://github.com/xquartz/wayland/blob/main-apple/cursor/xcursor.c): `cursor/xcursor.c`
- [Built-in cursor data](https://github.com/xquartz/wayland/blob/main-apple/cursor/cursor-data.h): `cursor/cursor-data.h`
- [Cursor OS support](https://github.com/xquartz/wayland/blob/main-apple/cursor/os-compatibility.c): `cursor/os-compatibility.c`
- [Wayland EGL window](https://github.com/xquartz/wayland/blob/main-apple/egl/wayland-egl.c): `egl/wayland-egl.c`
- [EGL backend interface](https://github.com/xquartz/wayland/blob/main-apple/egl/wayland-egl-backend.h): `egl/wayland-egl-backend.h`

### Other components

- **Client application**
- **Compositor**

## Connections

- Client application → Client API: uses
- Client API → Wire connection: transfers messages
- Client API → Protocol encoding: marshals requests (evidence: `src/wayland-client.c`)
- Client API → Client API declarations: implements API
- Client API → OS support: uses OS support (evidence: `src/wayland-client.c`)
- Wire connection → Shared utilities: uses (evidence: `src/connection.c`)
- Wire connection → OS support: uses OS support (evidence: `src/connection.c`)
- Compositor → Server API: uses (evidence: `README.md`)
- Server API → Wire connection: exchanges messages
- Server API → Server API declarations: implements API (evidence: `src/wayland-server.c`)
- Server API → Shared utilities: uses (evidence: `src/wayland-server.c`)
- Server API → OS support: uses OS support (evidence: `src/wayland-server.c`)
- Shared memory → Server API: uses server API (evidence: `src/wayland-shm.c`)
- Event loop → Server API declarations: uses server API (evidence: `src/event-loop.c`)
- Client application → Protocol definition: follows protocol (evidence: `README.md`)
- Compositor → Protocol definition: follows protocol (evidence: `README.md`)
- Protocol scanner → Protocol definition: reads definitions
- Cursor themes → Xcursor loading: loads themes (evidence: `cursor/wayland-cursor.c`)
- Cursor themes → Built-in cursor data: uses built-in data (evidence: `cursor/wayland-cursor.c`)
- Cursor themes → Cursor OS support: allocates shared files (evidence: `cursor/wayland-cursor.c`)
- Wayland EGL window → EGL backend interface: uses backend interface (evidence: `egl/wayland-egl.c`)
- Wayland EGL window → Client application: provides EGL integration
