From f0d9116fc88510d04a223f2428d28c225b9abdb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Tue, 11 Oct 2011 22:44:23 -0400 Subject: [PATCH] x11: Add a destroy listener for X11 surfaces --- compositor/shell.c | 1 + compositor/xserver-launcher.c | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/compositor/shell.c b/compositor/shell.c index 7c35fd0f..2dfe95b0 100644 --- a/compositor/shell.c +++ b/compositor/shell.c @@ -952,6 +952,7 @@ shell_init(struct wlsc_compositor *ec) if (shell == NULL) return -1; + memset(shell, 0, sizeof *shell); shell->compositor = ec; shell->shell.activate = activate; shell->shell.lock = lock; diff --git a/compositor/xserver-launcher.c b/compositor/xserver-launcher.c index 81d70ce4..47c60600 100644 --- a/compositor/xserver-launcher.c +++ b/compositor/xserver-launcher.c @@ -87,6 +87,7 @@ struct wlsc_wm { struct wlsc_wm_window { xcb_window_t id; struct wlsc_surface *surface; + struct wl_listener surface_destroy_listener; }; static void @@ -567,6 +568,17 @@ wlsc_xserver_cleanup(struct wlsc_process *process, int status) } } +static void +surface_destroy(struct wl_listener *listener, + struct wl_resource *resource, uint32_t time) +{ + struct wlsc_wm_window *window = + container_of(listener, + struct wlsc_wm_window, surface_destroy_listener); + + fprintf(stderr, "surface for xid %d destroyed\n", window->id); +} + static void xserver_set_window_id(struct wl_client *client, struct wl_resource *resource, struct wl_resource *surface_resource, uint32_t id) @@ -588,7 +600,9 @@ xserver_set_window_id(struct wl_client *client, struct wl_resource *resource, fprintf(stderr, "set_window_id %d for surface %p\n", id, surface); window->surface = (struct wlsc_surface *) surface; - /* FIXME: Do we need a surface destroy listener? */ + window->surface_destroy_listener.func = surface_destroy; + wl_list_insert(surface->resource.destroy_listener_list.prev, + &window->surface_destroy_listener.link); } static const struct xserver_interface xserver_implementation = {