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 link
  • wl_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 πŸ’œ

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 🫢✨πŸ’