[PATCH wayland 3/3] wayland-client: Add wl_proxy_get_listener

Rob Bradford robert.bradford at intel.com
Mon Jul 22 09:30:52 PDT 2013


From: Rob Bradford <rob at linux.intel.com>

This is the mirror function to wl_proxy_add_listener and is useful
inside client libraries to differentiate events on listeners for which
multiple proxies have been created.
---
 src/wayland-client.c | 19 +++++++++++++++++++
 src/wayland-client.h |  1 +
 2 files changed, 20 insertions(+)

diff --git a/src/wayland-client.c b/src/wayland-client.c
index 2887a40..fa74918 100644
--- a/src/wayland-client.c
+++ b/src/wayland-client.c
@@ -325,6 +325,25 @@ wl_proxy_add_listener(struct wl_proxy *proxy,
 	return 0;
 }
 
+/** Get a proxy's listener
+ *
+ * \param proxy The proxy object
+ * \return The address of the proxy's listener or NULL if no listener is set
+ *
+ * Gets the address to the proxy's listener; which is the listener set with
+ * \ref wl_proxy_add_listener.
+ *
+ * This function is useful in client with multiple listeners on the same
+ * interface to allow the identification of which code to eexecute.
+ *
+ * \memberof wl_proxy
+ */
+WL_EXPORT const void *
+wl_proxy_get_listener(struct wl_proxy *proxy)
+{
+	return proxy->object.implementation;
+}
+
 /** Prepare a request to be sent to the compositor
  *
  * \param proxy The proxy object
diff --git a/src/wayland-client.h b/src/wayland-client.h
index 216773a..32ed373 100644
--- a/src/wayland-client.h
+++ b/src/wayland-client.h
@@ -128,6 +128,7 @@ struct wl_proxy *wl_proxy_create(struct wl_proxy *factory,
 void wl_proxy_destroy(struct wl_proxy *proxy);
 int wl_proxy_add_listener(struct wl_proxy *proxy,
 			  void (**implementation)(void), void *data);
+const void *wl_proxy_get_listener(struct wl_proxy *proxy);
 void wl_proxy_set_user_data(struct wl_proxy *proxy, void *user_data);
 void *wl_proxy_get_user_data(struct wl_proxy *proxy);
 uint32_t wl_proxy_get_id(struct wl_proxy *proxy);
-- 
1.8.3.1



More information about the wayland-devel mailing list