[PATCH 4/5] compositor: create an attach listener for weston_surfaces

Ander Conselvan de Oliveira ander.conselvan.de.oliveira at intel.com
Tue Mar 13 08:23:58 PDT 2012


For drag icons, and possibly cursor surfaces in the future, there is a
need to update information stored on the input device when an attach
happens with non-zero (sx,sy). To avoid adding input specific code into
surface_attach(), create a listener mechanism instead.
---
 src/compositor.c |    6 ++++++
 src/compositor.h |    8 ++++++++
 2 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/src/compositor.c b/src/compositor.c
index f18386a..0fa7280 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -237,6 +237,8 @@ weston_surface_create(struct weston_compositor *compositor)
 	pixman_region32_init(&surface->transform.boundingbox);
 	surface->geometry.dirty = 1;
 
+	wl_list_init(&surface->attach_listener_list);
+
 	return surface;
 }
 
@@ -1128,6 +1130,10 @@ surface_attach(struct wl_client *client,
 	struct weston_surface *es = resource->data;
 	struct weston_shell *shell = es->compositor->shell;
 	struct wl_buffer *buffer;
+	struct weston_surface_attach_listener *al;
+
+	wl_list_for_each(al, &es->attach_listener_list, link)
+		al->func(al, es, sx, sy);
 
 	if (!buffer_resource && !es->output)
 		return;
diff --git a/src/compositor.h b/src/compositor.h
index bc32561..a1cd3bf 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -248,6 +248,12 @@ struct weston_region {
 	pixman_region32_t region;
 };
 
+struct weston_surface_attach_listener {
+	struct wl_list link;
+	void (*func)(struct weston_surface_attach_listener *listener,
+		     struct weston_surface *es, int sx, int sy);
+};
+
 /* Using weston_surface transformations
  *
  * To add a transformation to a surface, create a struct weston_transform, and
@@ -335,6 +341,8 @@ struct weston_surface {
 	struct wl_listener buffer_destroy_listener;
 
 	int force_configure;
+
+	struct wl_list attach_listener_list;
 };
 
 void
-- 
1.7.4.1



More information about the wayland-devel mailing list