wl_resource(3)

πŸ’–βœ¨ wl_resource βœ¨πŸ’–

okay bestie, pull up a chair, because we're diving into the wl_resource(3) page from the Wayland crew and it's lowkey iconic πŸ¦‹ this is the thing you read when you want to know how a resource object works on the server side β€” all its little functions, all its data fields, the whole vibe. no cap, it's giving "backstage pass to the compositor" energy πŸ‘‘


🌸 SYNOPSIS 🌸

first things first, you gotta include the header, fr fr:

#include <wayland-server.h>

✨ Public Member Functions ✨

here's the whole squad of functions, copy-pasted exactly so you don't get it twisted:

void wl_resource_post_error_vargs (struct wl_resource *resource,
    uint32_t code, const char *msg, va_list argp)
void wl_resource_post_error (struct wl_resource *resource, uint32_t
    code, const char *msg,...)
const char * wl_resource_get_class (const struct wl_resource *resource)
const struct wl_interface * wl_resource_get_interface (struct
    wl_resource *resource)
struct wl_resource * wl_resource_create (struct wl_client *client, const
    struct wl_interface *interface, int version, uint32_t id)

πŸŽ€ Data Fields πŸŽ€

and the fields inside the struct, absolutely every single one, no skipping:

  • struct wl_object object
  • wl_resource_destroy_func_t destroy
  • struct wl_list link
  • struct wl_signal deprecated_destroy_signal
  • struct wl_client * client
  • void * data
  • int version
  • wl_dispatcher_func_t dispatcher
  • struct wl_priv_signal destroy_signal
  • struct wl_signal destroy_signal

πŸ’… Member Function Documentation πŸ’…

🌈 struct wl_resource * wl_resource_create (struct wl_client * client, const struct wl_interface * interface, int version, uint32_t id)

Create a new resource object β€” yes bestie, it literally makes a whole new resource, main character behavior πŸ’«

Parameters:

  • client β€” The client owner of the new resource. it's their baby 🍼
  • interface β€” The interface of the new resource.
  • version β€” The version of the new resource.
  • id β€” The id of the new resource. If 0, an available id will be used. (so if you pass a big ol' zero, the system picks a free one for you, slay 🫢)
Listeners added with wl_client_add_resource_created_listener will be notified at the end of this function. so like, they get the news at the very end, not before. periodt.

πŸ¦‹ const char * wl_resource_get_class (const struct wl_resource * resource)

Retrieve the interface name (class) of a resource object. it's the name reveal moment ✨

Parameters:

  • resource β€” The resource object

⭐ const struct wl_interface * wl_resource_get_interface (struct wl_resource * resource)

Get the interface of a resource object β€” like asking "so what are you, actually?" πŸ’…

Parameters:

  • resource β€” The resource object

Returns:

  • The interface of the object associated with the resource

Since:

  • 1.24 β€” she's new-ish, a little baby, treat her well πŸŽ€

πŸ”₯ void wl_resource_post_error (struct wl_resource * resource, uint32_t code, const char * msg, ...)

Post a protocol error β€” yeah it's the "bestie we have a problem" function πŸ’€

Parameters:

  • resource β€” The resource object
  • code β€” The error code
  • msg β€” The error message format string
  • ... β€” The format string arguments

πŸ‘‘ void wl_resource_post_error_vargs (struct wl_resource * resource, uint32_t code, const char * msg, va_list argp)

Post a protocol error β€” same energy as above, but you're handing it a whole argument list instead of loose args. va_list girlies rise up πŸ™ˆ

Parameters:

  • resource β€” The resource object
  • code β€” The error code
  • msg β€” The error message format string
  • argp β€” The format string argument list

🧚 Field Documentation 🧚

these fields are listed here with no extra commentary in the original, and honestly? same, they're just vibing 🌸

  • struct wl_client * wl_resource::client
  • void * wl_resource::data
  • struct wl_signal wl_resource::deprecated_destroy_signal
  • wl_resource_destroy_func_t wl_resource::destroy
  • struct wl_priv_signal wl_resource::destroy_signal
  • struct wl_signal wl_resource::destroy_signal
  • wl_dispatcher_func_t wl_resource::dispatcher
  • struct wl_list wl_resource::link
  • struct wl_object wl_resource::object
  • int wl_resource::version
heads up cutie: there are literally two things named wl_resource::destroy_signal in this list β€” one is a struct wl_priv_signal and one is a struct wl_signal. i'm not making that up, that's just what the page says. do not come for me 😭

🌟 Author 🌟

Generated automatically by Doxygen for Wayland from the source code. (not a human, just a lil robot doing its thing πŸ€–πŸ’–)


aaaand that's the whole page bestie, you ate it, you understood it, you're basically a Wayland dev now πŸ’œ this was Wayland, Version 1.26.0, and the page you just read is wl_resource(3) β€” stay hydrated, keep your resources destroyed properly, mwah πŸŽ€βœ¨πŸ¦‹

πŸ“¦ where this page comes from