[PATCH] client: add wl_proxy_get_version function

Rémi Denis-Courmont remi at remlab.net
Sun Oct 5 01:57:15 PDT 2014


In some scenarii, a component will obtain a reference to a proxy
object created by another component. It may then be necessary to
check the interface version of the proxy object at run-time to
determine if a certain interface request is supported by the proxy
object.

For instance, a media player GUI can pass a wl_surface to a video
playback library. If the video is rotated, the library will want to
use wl_surface.set_buffer_transform, which is only available in
version 2 of wl_surface.

Signed-off-by: Rémi Denis-Courmont <remi at remlab.net>
---
 src/wayland-client.c | 13 +++++++++++++
 src/wayland-client.h |  1 +
 2 files changed, 14 insertions(+)

diff --git a/src/wayland-client.c b/src/wayland-client.c
index b0f77b9..51216ae 100644
--- a/src/wayland-client.c
+++ b/src/wayland-client.c
@@ -1721,6 +1721,19 @@ wl_proxy_get_class(struct wl_proxy *proxy)
 	return proxy->object.interface->name;
 }
 
+/** Get the interface version of a proxy object
+ *
+ * \param proxy The proxy object
+ * \return The interface version of the object associated with the proxy
+ *
+ * \memberof wl_proxy
+ */
+WL_EXPORT uint32_t
+wl_proxy_get_version(struct wl_proxy *proxy)
+{
+	return proxy->object.interface->version;
+}
+
 /** Assign a proxy to an event queue
  *
  * \param proxy The proxy object
diff --git a/src/wayland-client.h b/src/wayland-client.h
index 0801a81..60d87e6 100644
--- a/src/wayland-client.h
+++ b/src/wayland-client.h
@@ -146,6 +146,7 @@ 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);
 const char *wl_proxy_get_class(struct wl_proxy *proxy);
+uint32_t wl_proxy_get_version(struct wl_proxy *proxy);
 void wl_proxy_set_queue(struct wl_proxy *proxy, struct wl_event_queue *queue);
 
 #include "wayland-client-protocol.h"
-- 
2.1.1



More information about the wayland-devel mailing list