<p dir="ltr"><br>
On Nov 26, 2015 1:23 PM, "Derek Foreman" <<a href="mailto:derekf@osg.samsung.com">derekf@osg.samsung.com</a>> wrote:<br>
><br>
> This sets wl_display's version (for proxy version query purposes)<br>
> to 0. Any proxy created with unversioned API (this happens when<br>
> a client compiled with old headers links against new wayland)<br>
> will inherit this 0.<br>
><br>
> This gives us a way for new libraries linked by old clients to<br>
> realize they can't know a proxy's version.<br>
><br>
> wl_display's version being unqueryable (always returning 0) is<br>
> an acceptable side effect, since it's a special object you can't<br>
> bind specific versions of anyway.<br>
><br>
> Signed-off-by: Derek Foreman <<a href="mailto:derekf@osg.samsung.com">derekf@osg.samsung.com</a>></p>
<p dir="ltr">Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>></p>
<p dir="ltr">> ---<br>
><br>
> This follows on Jason's proxy version patch that I rebased<br>
> and reposted a little while ago.<br>
><br>
> src/wayland-client.c | 33 +++++++++++++++++++++++++++++++--<br>
> 1 file changed, 31 insertions(+), 2 deletions(-)<br>
><br>
> diff --git a/src/wayland-client.c b/src/wayland-client.c<br>
> index f2df0b9..5ba6edc 100644<br>
> --- a/src/wayland-client.c<br>
> +++ b/src/wayland-client.c<br>
> @@ -928,7 +928,25 @@ wl_display_connect_to_fd(int fd)<br>
> display->proxy.queue = &display->default_queue;<br>
> display->proxy.flags = 0;<br>
> display->proxy.refcount = 1;<br>
> - display->proxy.version = 1;<br>
> +<br>
> + /* We set this version to 0 for backwards compatibility.<br>
> + *<br>
> + * If a client is using old versions of protocol headers,<br>
> + * it will use unversioned API to create proxies. Those<br>
> + * proxies will inherit this 0.<br>
> + *<br>
> + * A client could be passing these proxies into library<br>
> + * code newer than the headers that checks proxy<br>
> + * versions. When the proxy version is reported as 0<br>
> + * the library will know that it can't reliably determine<br>
> + * the proxy version, and should do whatever fallback is<br>
> + * required.<br>
> + *<br>
> + * This trick forces wl_display to always report 0, but<br>
> + * since it's a special object that we can't bind<br>
> + * specific versions of anyway, this should be fine.<br>
> + */<br>
> + display->proxy.version = 0;<br>
><br>
> display->connection = wl_connection_create(display->fd);<br>
> if (display->connection == NULL)<br>
> @@ -1923,7 +1941,18 @@ wl_proxy_get_user_data(struct wl_proxy *proxy)<br>
> /** Get the protocol object version of a proxy object<br>
> *<br>
> * \param proxy The proxy object<br>
> - * \return The protocol object version of the proxy<br>
> + * \return The protocol object version of the proxy or 0<br>
> + *<br>
> + * Gets the protocol object version of a proxy object, or 0<br>
> + * if the proxy was created with unversioned API.<br>
> + *<br>
> + * A returned value of 0 means that no version information is<br>
> + * available, so the caller must make safe assumptions about<br>
> + * the object's real version.<br>
> + *<br>
> + * wl_display's version will always return 0.<br>
> + *<br>
> + * \note This should not normally be used by non-generated code.<br>
> *<br>
> * \memberof wl_proxy<br>
> */<br>
> --<br>
> 2.6.2<br>
><br>
</p>