tinyds: Use WAYLAND_DISPLAY and WAYLAND_SOCKET for wl backend 80/278180/1
authorSeunghun Lee <shiin.lee@samsung.com>
Mon, 25 Apr 2022 07:06:21 +0000 (16:06 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Mon, 18 Jul 2022 05:58:33 +0000 (14:58 +0900)
Instead of assuming the name of wayland display server by iterating
arbitrary number of names, it uses values of WAYLAND_DISPLAY and
WAYLAND_SOCKET environments.

The library of wayland-client uses these values when trying to connect
to wayland server.

Change-Id: Ieea1e2e55755ec10b6743568abf274e6a64aaf28

src/examples/tinyds.c

index 735fc30..1c5ca4f 100644 (file)
@@ -160,18 +160,10 @@ main(void)
 static struct ds_backend *
 create_wl_backend(struct wl_display *display)
 {
-    struct ds_backend *backend = NULL;
-    char name[512];
-    int i;
-
-    for (i = 0; i < 5; i++) {
-        snprintf(name, sizeof name, "wayland-%d", i);
-        backend = ds_wl_backend_create(display, name);
-        if (backend)
-            break;
-    }
+    if (!getenv("WAYLAND_DISPLAY") && !getenv("WAYLAND_SOCKET"))
+        return NULL;
 
-    return backend;
+    return ds_wl_backend_create(display, NULL);
 }
 
 static void