wlrfx/scenefx/Using it GitHub Discord

← scenefx

Using scenefx in your project

Because scenefx mirrors wlroots' own scene-graph types, adopting it is mostly a matter of linking against it instead of relying on wlr_scene directly, then calling the extra functions it adds for the effects you want.

Add it as a subproject

The common pattern — used by SwayFX itself — is to vendor scenefx as a meson subproject and fall back to it if the system package isn't found:

subproject('scenefx', required: false)
scenefx = dependency('scenefx-0.4', fallback: 'scenefx')

Or clone it directly into subprojects/:

mkdir -p subprojects
git clone https://github.com/wlrfx/scenefx.git subprojects/scenefx

Enable the unstable API

scenefx's headers are marked unstable, same as the wlroots scene API they extend — you'll need to define this to use them:

-DWLR_USE_UNSTABLE

Basic usage

A rounded, colored rectangle with a drop shadow behind it:

#include <scenefx/types/wlr_scene.h>

struct wlr_scene *scene = wlr_scene_create();

float fill[4]   = { 0.12f, 0.12f, 0.12f, 1.0f };
float shadow[4] = { 0.0f, 0.0f, 0.0f, 0.5f };

struct wlr_scene_shadow *drop_shadow = wlr_scene_shadow_create(
    &scene->tree, 300, 200, /* corner_radius */ 12,
    /* blur_sigma */ 20.0f, shadow);

struct wlr_scene_rect *rect =
    wlr_scene_rect_create(&scene->tree, 300, 200, fill);
wlr_scene_rect_set_corner_radius(rect, 12);

Rounding an existing surface (e.g. an XDG toplevel's buffer) works the same way:

wlr_scene_buffer_set_corner_radius(scene_buffer, 12);

Blur is tuned globally on the scene, then applied per-node with a blur scene node:

wlr_scene_set_blur_radius(scene, 5);
struct wlr_scene_blur *blur =
    wlr_scene_blur_create(&scene->tree, 300, 200);

This covers the shape of the API — the full function list (sizing, clipping, per-corner radii, transparency masks, and more) is in scenefx/types/wlr_scene.h in the repo.

Heads up: this is illustrative usage, not a tutorial verified against a working compositor. Cross-check against the header on GitHub and the current SwayFX source before shipping anything.