From ec2b32f49bf1692448633b1217a80a2afdda3742 Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Mon, 28 Nov 2011 15:12:34 +0200 Subject: [PATCH] compositor: eliminate wlsc_surface::shell_priv Remove shell_priv member from wlsc_surface, and replace it by a search through the wl_surface destroy_listener_list. This technique avoids any "extension" members in the wlsc_surface structure. Signed-off-by: Pekka Paalanen --- compositor/compositor.h | 2 -- compositor/shell.c | 25 +++++++++++++++++-------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/compositor/compositor.h b/compositor/compositor.h index fde253c..c47e1bc 100644 --- a/compositor/compositor.h +++ b/compositor/compositor.h @@ -275,8 +275,6 @@ struct wlsc_surface { struct wl_buffer *buffer; struct wl_listener buffer_destroy_listener; - - void *shell_priv; }; void diff --git a/compositor/shell.c b/compositor/shell.c index ffa21b4..0d4b182 100644 --- a/compositor/shell.c +++ b/compositor/shell.c @@ -90,12 +90,6 @@ struct wlsc_move_grab { int32_t dx, dy; }; -static struct shell_surface * -get_shell_surface(struct wlsc_surface *surface) -{ - return surface->shell_priv; -} - static void move_grab_motion(struct wl_grab *grab, uint32_t time, int32_t x, int32_t y) @@ -390,6 +384,23 @@ shell_handle_surface_destroy(struct wl_listener *listener, wl_resource_destroy(&shsurf->resource, time); } +static struct shell_surface * +get_shell_surface(struct wlsc_surface *surface) +{ + struct wl_list *lst = &surface->surface.resource.destroy_listener_list; + struct wl_listener *listener; + + /* search the destroy listener list for our callback */ + wl_list_for_each(listener, lst, link) { + if (listener->func == shell_handle_surface_destroy) { + return container_of(listener, struct shell_surface, + surface_destroy_listener); + } + } + + return NULL; +} + static void shell_create_shell_surface(struct wl_client *client, struct wl_resource *resource, @@ -422,8 +433,6 @@ shell_create_shell_surface(struct wl_client *client, shsurf->type = SHELL_SURFACE_NORMAL; - surface->shell_priv = shsurf; - wl_client_add_resource(client, &shsurf->resource); } -- 2.7.4