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 <[email protected]> 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 <[email protected]> > --- > 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 > [email protected] > http://lists.freedesktop.org/mailman/listinfo/wayland-devel >
_______________________________________________ wayland-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/wayland-devel
