Skip to content

drewt/chicken-wayland-server

Repository files navigation

wayland-server

CHICKEN Scheme bindings for the libwayland server API.

Building

Dependencies:

  • CHICKEN 5
  • libwayland

Run chicken-install in this directory to build and install the bindings.

Usage

(import wayland-server)

Naming Conventions

Procedures use the usual kebab-case convention. Predicates get a ? suffix, e.g. wl-list-empty?.

Struct members are available as SRFI-17 getters/setters named struct-name-member-name.

Enums use the convention enum-prefix/kind, e.g. wl-seat-capability/pointer.

Differences from the C API

wl_listener

The make-wl-listener function takes a procedure of one argument and returns a wrapped wl_listener struct. The argument to this procedure is the void* argument that would normally be passed to a regular wl_listener.

In C, you would put your wl_listener inside of another struct and use the wl_container_of macro to access its contents from the listener's notify function. In Scheme, you should set up a lexical environment where your data is available, and then create a lambda to pass to make-wl-listener. Or you could implement the usual callback + user-data convention with a simple wrapper, like so:

(define (*make-wl-listener proc arg)
  (make-wl-listener (lambda (wl-arg) (proc arg wl-arg))))

wl_list

The wl_list_for_each family of macros are available as procedures:

(wl-list-for-each list proc #!optional (convert values))
(wl-list-for-each/safe list proc #!optional (convert values))
(wl-list-for-each/reverse list proc #!optional (convert values))
(wl-list-for-each/reverse-safe list proc #!optional (convert values))

The convert argument should be a function taking a wl_list argument and returning some other data type. It is called on each node and the result is passed to the procedure proc.

A function wl-list->list is provided for converting from wl_list to native Scheme lists.

About

CHICKEN Scheme bindings for the libwayland server API

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published