[PATCH wayland] client: add wl_proxy_get_version function
Jason Ekstrand
jason at jlekstrand.net
Sun Oct 5 17:29:00 PDT 2014
Remi,
While this would probably be nice, your approach isn't going to work. The
version provided in wl_interface is the version that was compiled into
libwayland, not the version requested when the global was bound. In order
to get this correct, it requires a bit more tracking. I did implement this
a while ago but it never got merged. You can find it here:
http://lists.freedesktop.org/archives/wayland-devel/2014-April/014004.html
--Jason Ekstrand
On Sun, Oct 5, 2014 at 2:02 AM, Rémi Denis-Courmont <remi at remlab.net> wrote:
> 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
>
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/wayland-devel/attachments/20141005/383e0526/attachment.html>
More information about the wayland-devel
mailing list