I’ve just released ocaml-wayland, a pure OCaml Wayland implementation. You can get it with:
opam install wayland
Wayland is a communications system intended for use between processes on a single computer. It is mainly used by graphical applications (clients) to talk to display servers, but nothing about it is specific to graphics and it could be used for other things.
A Wayland protocol is defined by writing a schema file. Typed bindings can then be created automatically from that for various languages. Wayland’s main interesting feature is that you can pass file descriptors as message arguments. For example, to send a frame of video you can get a file descriptor to some shared memory, draw the image to it, and then pass the FD to the server for rendering, with no need to copy the data.
The ocaml-wayland library can be used to write applications, display servers, or proxies. The example in the repository opens a window showing some scrolling squares. Clicking reverses the direction and pressing keys changes the colours.
I used the library to write wayland-virtwl-proxy, which allows applications running in VMs to open windows directly on the host desktop, as described in my recent blog post “Qubes-lite with KVM and Wayland”.
Note that, unlike the older X11 protocol, Wayland doesn’t provide any graphics primitives (such as drawing rectangles or text). Instead, applications render the window contents however they please and then simply share the buffer with the compositor. So if you want to write a normal application using it, you’ll need to find or write a separate GUI toolkit too.