wl_listener(3)
π wl_listener(3) π
okay bestie, welcome to the wl_listener page from the Wayland Library Functions Manual β yes it's a section 3, yes it's a C struct, no you don't have to be scared π«Ά
β¨ NAME β¨
wl_listener β a single listener for Wayland signals. that's it, that's the whole vibe π
πΈ SYNOPSIS πΈ
#include <wayland-server-core.h>
π Data Fields π
struct wl_list linkwl_notify_func_t notify
π¦ Detailed Description π¦
so. a single listener for Wayland signals. that's the headline, but let me actually explain it because it's lowkey iconic.
wl_listener is literally the way you listen for wl_signal notifications. tons of Wayland objects use wl_listener to tell you when significant stuff happens β like an object getting destroyed π. main character events only.
Clients should create wl_listener objects manually, and can register them as listeners to signals using wl_signal_add() β that works assuming the signal is directly accessible. but for opaque structs like wl_event_loop, adding a listener should be done through the provided accessor methods instead. don't be out here poking at opaque structs, that's not the move π
β οΈ important: a listener can only listen to one signal at a time. no multitasking. pick your signal and commit, periodt.
struct wl_listener your_listener;
your_listener.notify = your_callback_method;
// Direct access
wl_signal_add(&some_object->destroy_signal, &your_listener);
// Accessor access
wl_event_loop *loop = ...;
wl_event_loop_add_destroy_listener(loop, &your_listener);
and if your listener is chillin' inside a larger struct, you can use wl_container_of to get a pointer back to it β this is the classic glow-up move, obsessed:
void your_listener(struct wl_listener *listener, void *data)
{
struct your_data *data;
your_data = wl_container_of(listener, data, your_member_name);
}
need to remove a listener from a signal? use wl_list_remove(). simple as that π§
wl_list_remove(&your_listener.link);
π See also π
wl_signal
π Field Documentation π
π struct wl_list wl_listener::link
part of wl_signal::listener_list β it's the little chain link that hooks you into the signal's list, iykyk βοΈβ¨
β wl_notify_func_t wl_listener::notify
callback function pointer. this is the one that actually does the thing when the signal fires π₯
π Author π
Generated automatically by Doxygen for Wayland from the source code. not a human author, just a robot doing its little robot thing, and honestly? slay π€π
and that's the page bestie!! πΈ this one's from Wayland, Version 1.26.0 β the wl_listener(3) moment, brought to you by the Library Functions Manual. go forth and listen to your signals, no cap π«Άβ¨π
π¦ where this page comes from
- arch rolling: wayland-docs 1.26.0-1 Β· MIT
- fedora 43: wayland-devel 1.26.0-1.fc43 Β· MIT
- fedora 43: wayland-devel 1.26.0-1.fc43 Β· MIT
- fedora 44: wayland-devel 1.26.0-1.fc44 Β· MIT
- fedora 44: wayland-devel 1.26.0-1.fc44 Β· MIT
- nixpkgs unstable: wayland 1.26.0
- ubuntu stonking: libwayland-doc 1.26.0-1 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms