[PATCH 1/2] Support specifying custom directories for the client and server sockets through environment variables.

Imran Zaman imran.zaman at gmail.com
Thu Oct 16 09:23:39 PDT 2014


This is in order to support nested compositor architectures
where system compositor using drm-backend is shared among
multiple child compositors using wayland-backend.

Signed-off-by: Imran Zaman <imran.zaman at gmail.com>
---
 src/wayland-client.c | 5 ++++-
 src/wayland-server.c | 5 ++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/wayland-client.c b/src/wayland-client.c
index b0f77b9..07db370 100644
--- a/src/wayland-client.c
+++ b/src/wayland-client.c
@@ -700,7 +700,9 @@ connect_to_socket(const char *name)
 	const char *runtime_dir;
 	int name_size, fd;
 
-	runtime_dir = getenv("XDG_RUNTIME_DIR");
+	runtime_dir = getenv("WAYLAND_CLIENT_DIR");
+	if (runtime_dir == NULL)
+		runtime_dir = getenv("XDG_RUNTIME_DIR");
 	if (!runtime_dir) {
 		wl_log("error: XDG_RUNTIME_DIR not set in the environment.\n");
 		/* to prevent programs reporting
@@ -723,6 +725,7 @@ connect_to_socket(const char *name)
 	name_size =
 		snprintf(addr.sun_path, sizeof addr.sun_path,
 			 "%s/%s", runtime_dir, name) + 1;
+	unsetenv("WAYLAND_CLIENT_DIR");
 
 	assert(name_size > 0);
 	if (name_size > (int)sizeof addr.sun_path) {
diff --git a/src/wayland-server.c b/src/wayland-server.c
index 674aeca..09e8903 100644
--- a/src/wayland-server.c
+++ b/src/wayland-server.c
@@ -1080,7 +1080,9 @@ 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_DIR");
+	if (runtime_dir == NULL)
+		runtime_dir = getenv("XDG_RUNTIME_DIR");
 	if (!runtime_dir) {
 		wl_log("error: XDG_RUNTIME_DIR not set in the environment\n");
 
@@ -1093,6 +1095,7 @@ wl_socket_init_for_display_name(struct wl_socket *s, const char *name)
 	s->addr.sun_family = AF_LOCAL;
 	name_size = snprintf(s->addr.sun_path, sizeof s->addr.sun_path,
 			     "%s/%s", runtime_dir, name) + 1;
+	unsetenv("WAYLAND_SERVER_DIR");
 
 	s->display_name = (s->addr.sun_path + name_size - 1) - strlen(name);
 
-- 
1.9.1



More information about the wayland-devel mailing list