From 1491ec42daf942350727fe6e158ac6ead669f643 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Wed, 30 Dec 2020 10:19:50 +0100 Subject: [PATCH] backend/x11: always open render node If we get an authenticated primary node from the X11 server, don't use it because we can't authenticate our Wayland clients with it. Instead, open a render node. Closes: https://github.com/swaywm/wlroots/issues/2576 --- backend/x11/backend.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/backend/x11/backend.c b/backend/x11/backend.c index 11cc4fa9..cd607e16 100644 --- a/backend/x11/backend.c +++ b/backend/x11/backend.c @@ -7,6 +7,7 @@ #include #include #include +#include #include @@ -268,6 +269,23 @@ static int query_dri3_drm_fd(struct wlr_x11_backend *x11) { return -1; } + if (drmGetNodeTypeFromFd(drm_fd) != DRM_NODE_RENDER) { + char *render_name = drmGetRenderDeviceNameFromFd(drm_fd); + if (render_name == NULL) { + close(drm_fd); + return -1; + } + + close(drm_fd); + drm_fd = open(render_name, O_RDWR | O_CLOEXEC); + if (drm_fd < 0) { + free(render_name); + return -1; + } + + free(render_name); + } + return drm_fd; }