[PATCH wayland 4/5] Add a resource creation signal

Giulio Camuffo giuliocamuffo at gmail.com
Mon Mar 7 17:31:34 UTC 2016


---
 src/wayland-server-core.h |  4 ++++
 src/wayland-server.c      | 20 ++++++++++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/src/wayland-server-core.h b/src/wayland-server-core.h
index 4201b2c..9af2481 100644
--- a/src/wayland-server-core.h
+++ b/src/wayland-server-core.h
@@ -217,6 +217,10 @@ wl_client_get_object(struct wl_client *client, uint32_t id);
 void
 wl_client_post_no_memory(struct wl_client *client);
 
+void
+wl_client_add_resource_created_listener(struct wl_client *client,
+                                        struct wl_listener *listener);
+
 /** \class wl_listener
  *
  * \brief A single listener for Wayland signals
diff --git a/src/wayland-server.c b/src/wayland-server.c
index a5527eb..56e17c3 100644
--- a/src/wayland-server.c
+++ b/src/wayland-server.c
@@ -81,6 +81,7 @@ struct wl_client {
 	struct wl_signal destroy_signal;
 	struct ucred ucred;
 	int error;
+	struct wl_signal resource_created_signal;
 };
 
 struct wl_display {
@@ -421,6 +422,7 @@ wl_client_create(struct wl_display *display, int fd)
 	if (client == NULL)
 		return NULL;
 
+	wl_signal_init(&client->resource_created_signal);
 	client->display = display;
 	client->source = wl_event_loop_add_fd(display->loop, fd,
 					      WL_EVENT_READABLE,
@@ -1451,6 +1453,7 @@ wl_resource_create(struct wl_client *client,
 		return NULL;
 	}
 
+	wl_signal_emit(&client->resource_created_signal, resource);
 	return resource;
 }
 
@@ -1564,6 +1567,23 @@ wl_client_from_link(struct wl_list *link)
 	return wl_container_of(link, (struct wl_client *)0, link);
 }
 
+/** Add a listener for the client's resource creation signal
+ *
+ * \param client The client object
+ * \param listener The listener to be added
+ *
+ * When a new resource is created for this client the listener
+ * will be notified, carrying the new resource as the data argument.
+ *
+ * \memberof wl_client
+ */
+WL_EXPORT void
+wl_client_add_resource_created_listener(struct wl_client *client,
+					struct wl_listener *listener)
+{
+	wl_signal_add(&client->resource_created_signal, listener);
+}
+
 /** \cond */ /* Deprecated functions below. */
 
 uint32_t
-- 
2.7.2



More information about the wayland-devel mailing list