diff options
| author | Dima Ryazanov <dima@gmail.com> | 2015-08-12 19:34:31 -0700 |
|---|---|---|
| committer | Pekka Paalanen <pekka.paalanen@collabora.co.uk> | 2015-08-14 10:14:05 +0300 |
| commit | fb7e13021730d0a5516ecbd3712ea4235e05d24d (patch) | |
| tree | 61caa1d4d04b7a99a8a5d5bd9a56ee1340d32600 /src/wayland-client.c | |
| parent | wayland-client : Fix queue_release not to call proxy_destroy (diff) | |
| download | wayland-fb7e13021730d0a5516ecbd3712ea4235e05d24d.tar wayland-fb7e13021730d0a5516ecbd3712ea4235e05d24d.tar.gz wayland-fb7e13021730d0a5516ecbd3712ea4235e05d24d.tar.bz2 wayland-fb7e13021730d0a5516ecbd3712ea4235e05d24d.tar.lz wayland-fb7e13021730d0a5516ecbd3712ea4235e05d24d.tar.xz wayland-fb7e13021730d0a5516ecbd3712ea4235e05d24d.tar.zst wayland-fb7e13021730d0a5516ecbd3712ea4235e05d24d.zip | |
client: require WAYLAND_DISPLAY to be set
Although defaulting to wayland-0 seems convenient, it has an undesirable
side effect: clients may unintentionally connect to the wrong compositor.
Generally, it's safer to fail instead. Here's a real example:
In Fedora 22, Gtk+ prefers Wayland over X11, though the default session is still
a normal X11 Gnome session. When you launch a Gtk+ app, it will try Wayland,
fail, then try X11, and succesfully start up. That works fine.
Now suppose you launch Weston while running the Gnome session. Suddenly, all
of the Gtk+ apps launched from Gnome will show up inside Weston instead.
That's unexpected. There's also no good way to prevent that from happening
(other than perhaps setting WAYLAND_DISPLAY to an invalid value when launching
an app).
Not using wayland-0 as the default will solve that problem: an app launched
from the X11 Gnome session will use the X11 backend regardless of whether
there's a wayland compositor running at the same time.
Everything else should work as before. The compositor already sets
the WAYLAND_DISPLAY when starting the session, so the lack of the default value
should not make a difference to the user.
Signed-off-by: Dima Ryazanov <dima@gmail.com>
Acked-by: Pekka Paalanen <ppaalanen@gmail.com>
Acked-by: Giulio Camuffo <giuliocamuffo@gmail.com>
Acked-by: Daniel Stone <daniel@fooishbar.org>
Acked-by: Jasper St. Pierre <jstpierre@mecheye.net>
Reviewed-by: Ryo Munakata <ryomnktml@gmail.com>
[Pekka: dropped the wayland-server.c hunk, adjusted summary]
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Diffstat (limited to 'src/wayland-client.c')
| -rw-r--r-- | src/wayland-client.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/wayland-client.c b/src/wayland-client.c index 09c594a..ffbca4b 100644 --- a/src/wayland-client.c +++ b/src/wayland-client.c @@ -764,8 +764,11 @@ connect_to_socket(const char *name) if (name == NULL) name = getenv("WAYLAND_DISPLAY"); - if (name == NULL) - name = "wayland-0"; + if (name == NULL) { + wl_log("error: WAYLAND_DISPLAY not set in the environment.\n"); + errno = ENOENT; + return -1; + } fd = wl_os_socket_cloexec(PF_LOCAL, SOCK_STREAM, 0); if (fd < 0) @@ -869,8 +872,7 @@ wl_display_connect_to_fd(int fd) * \return A \ref wl_display object or \c NULL on failure * * Connect to the Wayland display named \c name. If \c name is \c NULL, - * its value will be replaced with the WAYLAND_DISPLAY environment - * variable if it is set, otherwise display "wayland-0" will be used. + * its value will be replaced with the WAYLAND_DISPLAY environment variable. * * \memberof wl_display */ |
