From 92abc6a2af57f6f4d10ea1ae1a2ab35c3654b99c Mon Sep 17 00:00:00 2001 From: Olivier Fourdan Date: Wed, 17 Apr 2024 15:47:32 +0200 Subject: [PATCH] xwayland: Use the connector name for XRANDR leases Use the connector name as basis for the Xwayland output name in XRANDR, similar to what we do for regular outputs, instead of the generic "XWAYLAND" name which changes every time the output is leased. Prefix the actual name with "lease-" to distinguish from duplicate names from the regular outputs. v2: avoid duplicate names (Simon) v3: Move the check for duplicates to xwl_output_set_name() (Simon) Signed-off-by: Olivier Fourdan Part-of: (cherry picked from commit 49b8f131f7b1df2f3c4a3bde010d67e0b448246c) --- hw/xwayland/xwayland-drm-lease.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/hw/xwayland/xwayland-drm-lease.c b/hw/xwayland/xwayland-drm-lease.c index 51c92872e..4f9004d8c 100644 --- a/hw/xwayland/xwayland-drm-lease.c +++ b/hw/xwayland/xwayland-drm-lease.c @@ -189,7 +189,11 @@ lease_connector_handle_name(void *data, struct wp_drm_lease_connector_v1 *wp_drm_lease_connector_v1, const char *name) { - /* This space is deliberately left blank */ + struct xwl_output *xwl_output = data; + char rr_output_name[MAX_OUTPUT_NAME] = { 0 }; + + snprintf(rr_output_name, MAX_OUTPUT_NAME, "lease-%s", name); + xwl_output_set_name(xwl_output, rr_output_name); } static void @@ -347,7 +351,7 @@ drm_lease_device_handle_connector(void *data, struct xwl_drm_lease_device *lease_device = data; struct xwl_screen *xwl_screen = lease_device->xwl_screen; struct xwl_output *xwl_output; - char name[256]; + char name[MAX_OUTPUT_NAME] = { 0 }; xwl_output = calloc(1, sizeof *xwl_output); if (xwl_output == NULL) { @@ -355,9 +359,6 @@ drm_lease_device_handle_connector(void *data, return; } - snprintf(name, sizeof name, "XWAYLAND%d", - xwl_screen_get_next_output_serial(xwl_screen)); - xwl_output->lease_device = lease_device; xwl_output->xwl_screen = xwl_screen; xwl_output->lease_connector = connector; @@ -368,7 +369,11 @@ drm_lease_device_handle_connector(void *data, } RRCrtcSetRotations(xwl_output->randr_crtc, ALL_ROTATIONS); xwl_output->randr_output = RROutputCreate(xwl_screen->screen, - name, strlen(name), xwl_output); + name, MAX_OUTPUT_NAME, xwl_output); + snprintf(name, MAX_OUTPUT_NAME, "XWAYLAND%d", + xwl_screen_get_next_output_serial(xwl_screen)); + xwl_output_set_name(xwl_output, name); + if (!xwl_output->randr_output) { ErrorF("Failed creating RandR Output\n"); goto err;