Skip to content

swaywm/chicken-wlroots

Repository files navigation

chicken-wlroots [WIP]

Chicken Scheme bindings for wlroots.

Building

Dependencies:

Simply run chicken-install in this directory to build and install chicken-wlroots as an egg. To avoid building the egg as root, you can either run chicken-install -sudo to get permissions via sudo, or else change the repository location to a directory that you can write to.

Usage

Memory Management

These are low level bindings. Most wlroots objects allocated via these bindings are not garbage collected (with a few exceptions). You may set up your own memory management scheme using set-finalizer! where appropriate.

The wlroots objects which are garbage collected are:

  • wlr-box
  • wlr-matrix (not actually a wlroots type, but a wrapper for a float[9])

Naming Conventions

Module naming mimics the structure of the wlroots headers. E.g., the module (wlr types wlr-box) exports all of the identifiers declared in the header "wlr/types/wlr_box.h".

SRFI-17 getter/setter procedures are defined for accessing struct members. They take the form structname-membername. For nested structs, only getters are defined.

Constructors for wlroots types take the form make-wlr-type. Constructors are only exported where it makes sense to do so (e.g. wlr-box); in most cases you should use the wlr-*-create functions provided by wlroots.

Procedures use the usual kebab-case convention.

Enums use the convention enum-prefix/kind, e.g. WLR_INPUT_DEVICE_KEYBOARD becomes wlr-input-device/keyboard.

Differences from the C API

For C functions taking output parameters, these bindings remove the output parameters (unless their input value is also meaningful) and return multiple values instead. The order of the returned values is the C return value, followed by the output parameters in order.

Because some wlroots functions take a struct timespec as an argument, these bindings provide a module (wlr time) which exports the clock-gettime function.

Examples

Example programs can be found in the src/examples directory. These are fairly direct translations from C, so do not expect idiomatic Scheme.

To build the examples, run make after installing chicken-wlroots.