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>
Client message observers 3/6
Adds code demonstrating how to replicate the output produced by the internal
wl_closure_print() using the client message observer interface.
If you run protocol-logger-test with "WAYLAND_DEBUG=client", you can see the
client messages logged to stderr twice, with the same strings.
Signed-off-by: Lloyd Pique <lpique@google.com>
Client message observers 2/6
Introduce a client message observer interface, strongly resembling the server
protocol logger interface added in commit 450f06e2.
This means a new pair of public API functions:
* wl_display_create_client_observer(): allows a client to register an observer
function, which is called for messages that are received or sent.
* wl_client_observer_destroy() which destroys the observer created by the prior
function.
With these changes, a client can set and clear an observer at run-time, and can
use it to log client messages to a location other than stderr.
The existing protocol-logger-test has also been revised and extended to demonstrate
using the new API for test use, to validate the sequence of messages sent and
received by the client, on top of the existing checks to do the same for the
server messages.
Signed-off-by: Lloyd Pique <lpique@google.com>
The [spec][1] reads:
> All paths set in these environment variables must be absolute. If an
> implementation encounters a relative path in any of these variables it should
> consider the path invalid and ignore it.
and
> If $XDG_DATA_HOME is either not set or empty, a default equal to
> $HOME/.local/share should be used.
Testing that the path is absolute also entails that is is non-empty.
[1]: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
Signed-off-by: Antonin Décimo <antonin.decimo@gmail.com>
The new wl_display_add_protocol_logger allows to set a function as
a logger, which will get called when a new request is received or an
event is sent.
This is akin to setting WAYLAND_DEBUG=1, but more powerful because it
can be enabled at run time and allows to show the log e.g. in a UI view.
A test is added for the new functionality.
Signed-off-by: Giulio Camuffo <giulio.camuffo@kdab.com>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Yong Bakos <ybakos@humanoriented.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>