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/data-device.c b/src/data-device.c
index d28325d..a0913a2 100644
--- a/src/data-device.c
+++ b/src/data-device.c
@@ -214,6 +214,13 @@
weston_view_set_position(drag->icon, fx, fy);
}
+static int
+pointer_drag_surface_get_label(struct weston_surface *surface,
+ char *buf, size_t len)
+{
+ return snprintf(buf, len, "pointer drag icon");
+}
+
static void
pointer_drag_surface_configure(struct weston_surface *es,
int32_t sx, int32_t sy)
@@ -226,6 +233,13 @@
drag_surface_configure(&drag->base, pointer, NULL, es, sx, sy);
}
+static int
+touch_drag_surface_get_label(struct weston_surface *surface,
+ char *buf, size_t len)
+{
+ return snprintf(buf, len, "touch drag icon");
+}
+
static void
touch_drag_surface_configure(struct weston_surface *es, int32_t sx, int32_t sy)
{
@@ -351,6 +365,7 @@
weston_view_unmap(drag->icon);
drag->icon->surface->configure = NULL;
+ weston_surface_set_label_func(drag->icon->surface, NULL);
pixman_region32_clear(&drag->icon->surface->pending.input);
wl_list_remove(&drag->icon_destroy_listener.link);
weston_view_destroy(drag->icon);
@@ -560,6 +575,8 @@
icon->configure = pointer_drag_surface_configure;
icon->configure_private = drag;
+ weston_surface_set_label_func(icon,
+ pointer_drag_surface_get_label);
} else {
drag->base.icon = NULL;
}
@@ -615,6 +632,8 @@
icon->configure = touch_drag_surface_configure;
icon->configure_private = drag;
+ weston_surface_set_label_func(icon,
+ touch_drag_surface_get_label);
} else {
drag->base.icon = NULL;
}