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