wayland-client: Support WAYLAND_DEBUG client side as well
authorKristian Høgsberg <krh@bitplanet.net>
Thu, 10 Feb 2011 17:27:35 +0000 (12:27 -0500)
committerKristian Høgsberg <krh@bitplanet.net>
Thu, 10 Feb 2011 17:27:35 +0000 (12:27 -0500)
wayland/wayland-client.c

index 7bb6451..e3198c7 100644 (file)
@@ -95,6 +95,8 @@ struct wl_display {
        uint32_t key;
 };
 
        uint32_t key;
 };
 
+static int wl_debug = 0;
+
 static int
 connection_update(struct wl_connection *connection,
                  uint32_t mask, void *data)
 static int
 connection_update(struct wl_connection *connection,
                  uint32_t mask, void *data)
@@ -203,6 +205,12 @@ wl_proxy_marshal(struct wl_proxy *proxy, uint32_t opcode, ...)
        va_end(ap);
 
        wl_closure_send(closure, proxy->display->connection);
        va_end(ap);
 
        wl_closure_send(closure, proxy->display->connection);
+
+       if (wl_debug) {
+               fprintf(stderr, " -> ");
+               wl_closure_print(closure, &proxy->object);
+       }
+
        wl_closure_destroy(closure);
 }
 
        wl_closure_destroy(closure);
 }
 
@@ -334,8 +342,13 @@ wl_display_connect(const char *name)
        struct sockaddr_un addr;
        socklen_t size;
        const char *runtime_dir;
        struct sockaddr_un addr;
        socklen_t size;
        const char *runtime_dir;
+       const char *debug;
        size_t name_size;
 
        size_t name_size;
 
+       debug = getenv("WAYLAND_DEBUG");
+       if (debug)
+               wl_debug = 1;
+
        display = malloc(sizeof *display);
        if (display == NULL)
                return NULL;
        display = malloc(sizeof *display);
        if (display == NULL)
                return NULL;
@@ -480,6 +493,9 @@ handle_event(struct wl_display *display,
        closure = wl_connection_demarshal(display->connection,
                                          size, display->objects, message);
 
        closure = wl_connection_demarshal(display->connection,
                                          size, display->objects, message);
 
+       if (wl_debug)
+               wl_closure_print(closure, &proxy->object);
+
        wl_list_for_each(listener, &proxy->listener_list, link)
                wl_closure_invoke(closure, &proxy->object,
                                  listener->implementation[opcode],
        wl_list_for_each(listener, &proxy->listener_list, link)
                wl_closure_invoke(closure, &proxy->object,
                                  listener->implementation[opcode],