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<n>" 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 <ofourdan@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1492>
(cherry picked from commit 49b8f131f7)
This commit is contained in:
Olivier Fourdan 2024-04-17 15:47:32 +02:00 committed by Alan Coopersmith
parent 1298899953
commit 92abc6a2af

View file

@ -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;