mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2026-02-23 01:40:43 -05:00
client: Safe cast a "wl_object *" to "wl_proxy *"
Client message observers 4/6 When given an array of wl_arguments for a wl_closure, the ".o" field is an opaque wl_object pointer, which the client code cannot really do anything with, without a potentially unsafe cast that assumes details about the internal implementation. By adding a wl_proxy_from_object() function to the client interface, the client can safely get the wl_proxy pointer. This can be used by client message observers in particular to get the proxy id and class name, for logging those details. Signed-off-by: Lloyd Pique <lpique@google.com>
This commit is contained in:
parent
3df74daed4
commit
e5e7cc57fa
3 changed files with 30 additions and 4 deletions
|
|
@ -294,10 +294,11 @@ client_log_to_stderr_demo(void *user_data, enum wl_client_message_type type,
|
|||
break;
|
||||
case 'o':
|
||||
if (args[i].o) {
|
||||
// Note: server logger should instead cast to
|
||||
// wl_resource, and use wl_resource_get_class
|
||||
// and wl_resource_get_id.
|
||||
arg_proxy = (struct wl_proxy *)(args[i].o);
|
||||
// Note: server logger should instead use
|
||||
// wl_resource_from_object, and then
|
||||
// wl_resource_get_class and
|
||||
// wl_resource_get_id.
|
||||
arg_proxy = wl_proxy_from_object(args[i].o);
|
||||
arg_class = wl_proxy_get_class(arg_proxy);
|
||||
|
||||
fprintf(f, "%s#%u",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue