[PATCH wayland v2] Introduce WAYLAND_SERVER_SOCKET_DIR to change socket directory without changing XDG_RUNTIME_DIR.
Marek Chalupa
mchqwerty at gmail.com
Thu Aug 6 02:42:18 PDT 2015
Hey,
Just to clarify my review of this series. I like WAYLAND_DISPLAY being
able to handle absolute paths. I'm in for adding
WAYLAND_SERVER_SOCKET_DIR, because currently it is the only way how to
customize wl_display_add_socket_auto (In the future we could add
something like wl_display_add_socket_auto2 that would take as a
parameter directory where to create the socket).
I'm not enthusiastic about adding WAYLAND_SERVER_SOCKET, because there's
this thing:
* client ignores WAYLAND_SERVER_SOCKET and uses WAYLAND_DISPLAY
* server uses WAYLAND_DISPLAY and WAYLAND_SERVER_SOCKET as synonyms
(the later has preference, but the functionality is the same)
This looks like a mess to me. If I understand it you set WAYLAND_DISPLAY
to parent compositor's socket, WAYLAND_SERVER_SOCKET to nested
compositor's socket and than spawn the nested compositor and it will
create WAYLAND_SERVER_SOCKET and connect to WAYLAND_DISPLAY.
I think that it'd be better to implement this functionality in the
compositor instead of using env vars. And if you want to use env vars,
you can always use WAYLAND_SOCKET when spawning the nested compositor so
that it will connect to it (plus export WAYLAND_DISPLAY or
WAYLAND_SERVER_SOCKET_DIR and the nested compositor will create the
socket according to it). Or is there a reason why that wouldn't work?
I said before, I don't want to block that patch if there are people that
like it.
Cheers,
Marek
On 07/29/2015 11:23 AM, Davide Bettio wrote:
> Introduce WAYLAND_SERVER_SOCKET_DIR to change socket
> directory without changing XDG_RUNTIME_DIR. This might be useful to change
> socket directory in case wl_display_add_socket_auto is used. For example
> this
> will change the socket path for weston without using any command line
> argument. This envvar is ignored when WAYLAND_SERVER_SOCKET is set to an
> absolute path.
>
> Signed-off-by: Davide Bettio <davide.bettio at ispirata.com>
> ---
> src/wayland-server.c | 18 +++++++++++-------
> 1 file changed, 11 insertions(+), 7 deletions(-)
>
> diff --git a/src/wayland-server.c b/src/wayland-server.c
> index d73792a..3f1d74f 100644
> --- a/src/wayland-server.c
> +++ b/src/wayland-server.c
> @@ -1098,9 +1098,13 @@ wl_socket_init_for_display_name(struct wl_socket
> *s, const char *name)
> int name_size;
> const char *runtime_dir;
>
> - runtime_dir = getenv("XDG_RUNTIME_DIR");
> + runtime_dir = getenv("WAYLAND_SERVER_SOCKET_DIR");
> if (!runtime_dir) {
> - wl_log("error: XDG_RUNTIME_DIR not set in the environment\n");
> + runtime_dir = getenv("XDG_RUNTIME_DIR");
> + }
> + if (!runtime_dir) {
> + wl_log("error: Neither XDG_RUNTIME_DIR nor
> WAYLAND_SERVER_SOCKET_DIR have"
> + "been set in the environment\n");
>
> /* to prevent programs reporting
> * "failed to add socket: Success" */
> @@ -1225,14 +1229,14 @@ wl_display_add_socket_auto(struct wl_display
> *display)
> * and WAYLAND_DISPLAY env variable for the socket name. If
> WAYLAND_DISPLAY and
> * WAYLAND_SERVER_SOCKET are not set, then default wayland-0 is used.
> *
> - * The Unix socket will be created in the directory pointed to by
> environment
> - * variable XDG_RUNTIME_DIR. If XDG_RUNTIME_DIR is not set, then this
> function
> - * fails and returns -1.
> + * The Unix socket will be created in the directory pointed to by
> either environment
> + * variable WAYLAND_SERVER_SOCKET_DIR or XDG_RUNTIME_DIR. If the none
> of the is set,
> + * then this function fails and returns -1.
> *
> - * The length of socket path, i.e., the path set in XDG_RUNTIME_DIR and
> the
> + * The length of socket path, e.g., the path set in XDG_RUNTIME_DIR and
> the
> * socket name, must not exceed the maxium length of a Unix socket path.
> * The function also fails if the user do not have write permission in
> the
> - * XDG_RUNTIME_DIR path or if the socket name is already in use.
> + * wayland socket path or if the socket name is already in use.
> *
> * \memberof wl_display
> */
More information about the wayland-devel
mailing list