compositor: add weston_surface_set_label_func()
When printing out logs from Weston's actions, mainly for debugging, it
can be very difficult to identify the different surfaces. Inspecting
the configure function pointer is not useful, as the configure functions
may live in modules.
Add vfunc get_label to weston_surface, which will produce a short,
human-readable description of the surface, which allows identifying it
better, rather than just looking at the surface size, for instance.
Set the label function from most parts of Weston, to identify cursors and
drag icons, and panels, backgrounds, screensavers and lock surfaces, and
the desktop shell's application surfaces.
v2: renamed 'description' to 'label', so we get
weston_surface_set_label_func().
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
diff --git a/src/input.c b/src/input.c
index 59943fe..d3bfa5e 100644
--- a/src/input.c
+++ b/src/input.c
@@ -431,6 +431,7 @@
wl_list_remove(&pointer->sprite_destroy_listener.link);
surface->configure = NULL;
surface->configure_private = NULL;
+ weston_surface_set_label_func(surface, NULL);
weston_view_destroy(pointer->sprite);
pointer->sprite = NULL;
}
@@ -1582,6 +1583,13 @@
grab->interface->frame(grab);
}
+static int
+pointer_cursor_surface_get_label(struct weston_surface *surface,
+ char *buf, size_t len)
+{
+ return snprintf(buf, len, "cursor");
+}
+
static void
pointer_cursor_surface_configure(struct weston_surface *es,
int32_t dx, int32_t dy)
@@ -1653,6 +1661,8 @@
surface->configure = pointer_cursor_surface_configure;
surface->configure_private = pointer;
+ weston_surface_set_label_func(surface,
+ pointer_cursor_surface_get_label);
pointer->sprite = weston_view_create(surface);
pointer->hotspot_x = x;
pointer->hotspot_y = y;