diff --git a/wayland/connection.c b/wayland/connection.c index 0f2051ab..4f6a8454 100644 --- a/wayland/connection.c +++ b/wayland/connection.c @@ -34,6 +34,7 @@ #include #include #include +#include #include "wayland-util.h" #include "connection.h" @@ -684,12 +685,23 @@ wl_closure_send(struct wl_closure *closure, struct wl_connection *connection) } void -wl_closure_print(struct wl_closure *closure, struct wl_object *target) +wl_closure_print(struct wl_closure *closure, struct wl_object *target, int send) { union wl_value *value; + char buffer[4] = "\0"; int i; + struct timespec tp; + unsigned int time; - fprintf(stderr, "%s@%d.%s(", + if (send) + sprintf(buffer, " -> "); + + clock_gettime(CLOCK_REALTIME, &tp); + time = (tp.tv_sec * 1000000L) + (tp.tv_nsec / 1000); + + fprintf(stderr, "[%10.3f] %s%s@%d.%s(", + time / 1000.0, + buffer, target->interface->name, target->id, closure->message->name); diff --git a/wayland/connection.h b/wayland/connection.h index 413977df..5f4588bd 100644 --- a/wayland/connection.h +++ b/wayland/connection.h @@ -61,7 +61,7 @@ wl_closure_invoke(struct wl_closure *closure, void wl_closure_send(struct wl_closure *closure, struct wl_connection *connection); void -wl_closure_print(struct wl_closure *closure, struct wl_object *target); +wl_closure_print(struct wl_closure *closure, struct wl_object *target, int send); void wl_closure_destroy(struct wl_closure *closure); diff --git a/wayland/wayland-client.c b/wayland/wayland-client.c index e8266e16..ce27a904 100644 --- a/wayland/wayland-client.c +++ b/wayland/wayland-client.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -201,10 +202,8 @@ wl_proxy_marshal(struct wl_proxy *proxy, uint32_t opcode, ...) wl_closure_send(closure, proxy->display->connection); - if (wl_debug) { - fprintf(stderr, " -> "); - wl_closure_print(closure, &proxy->object); - } + if (wl_debug) + wl_closure_print(closure, &proxy->object, true); wl_closure_destroy(closure); } @@ -523,7 +522,7 @@ handle_event(struct wl_display *display, size, display->objects, message); if (wl_debug) - wl_closure_print(closure, &proxy->object); + wl_closure_print(closure, &proxy->object, false); wl_closure_invoke(closure, &proxy->object, proxy->object.implementation[opcode], diff --git a/wayland/wayland-server.c b/wayland/wayland-server.c index 176859b0..d4fdfc74 100644 --- a/wayland/wayland-server.c +++ b/wayland/wayland-server.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -108,10 +109,8 @@ wl_client_post_event(struct wl_client *client, struct wl_object *sender, wl_closure_send(closure, client->connection); - if (wl_debug) { - fprintf(stderr, " -> "); - wl_closure_print(closure, sender); - } + if (wl_debug) + wl_closure_print(closure, sender, true); wl_closure_destroy(closure); } @@ -202,7 +201,7 @@ wl_client_connection_data(int fd, uint32_t mask, void *data) if (wl_debug) - wl_closure_print(closure, object); + wl_closure_print(closure, object, false); wl_closure_invoke(closure, object, object->implementation[opcode], client);