xwayland: make the output serials belong to the screen

Xwayland uses an output serial number it increments each time a new
Wayland output is added.

On server regeneration, that static value is not cleared, and therfore
the output numbers keep increasing each time the Xserver restarts.

To avoid that issue, make the output serial part of the xwl_screen,
which gets recreated on server regeneration, so that index is reset to 0
automatically on server regeneration.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
This commit is contained in:
Olivier Fourdan 2022-05-17 18:40:11 +02:00
parent a4aba5ab30
commit eae3c06c23
5 changed files with 18 additions and 15 deletions

View File

@ -336,6 +336,7 @@ drm_lease_device_handle_connector(void *data,
struct wp_drm_lease_connector_v1 *connector)
{
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];
@ -345,18 +346,19 @@ drm_lease_device_handle_connector(void *data,
return;
}
snprintf(name, sizeof name, "XWAYLAND%d", xwl_get_next_output_serial());
snprintf(name, sizeof name, "XWAYLAND%d",
xwl_screen_get_next_output_serial(xwl_screen));
xwl_output->lease_device = lease_device;
xwl_output->xwl_screen = lease_device->xwl_screen;
xwl_output->xwl_screen = xwl_screen;
xwl_output->lease_connector = connector;
xwl_output->randr_crtc = RRCrtcCreate(lease_device->xwl_screen->screen, xwl_output);
xwl_output->randr_crtc = RRCrtcCreate(xwl_screen->screen, xwl_output);
if (!xwl_output->randr_crtc) {
ErrorF("Failed creating RandR CRTC\n");
goto err;
}
RRCrtcSetRotations(xwl_output->randr_crtc, ALL_ROTATIONS);
xwl_output->randr_output = RROutputCreate(lease_device->xwl_screen->screen,
xwl_output->randr_output = RROutputCreate(xwl_screen->screen,
name, strlen(name), xwl_output);
if (!xwl_output->randr_output) {
ErrorF("Failed creating RandR Output\n");
@ -373,7 +375,7 @@ drm_lease_device_handle_connector(void *data,
&lease_connector_listener,
xwl_output);
xorg_list_append(&xwl_output->link, &lease_device->xwl_screen->output_list);
xorg_list_append(&xwl_output->link, &xwl_screen->output_list);
return;
err:

View File

@ -768,7 +768,8 @@ xwl_output_create(struct xwl_screen *xwl_screen, uint32_t id)
xwl_output->server_output_id = id;
wl_output_add_listener(xwl_output->output, &output_listener, xwl_output);
snprintf(name, sizeof name, "XWAYLAND%d", xwl_get_next_output_serial());
snprintf(name, sizeof name, "XWAYLAND%d",
xwl_screen_get_next_output_serial(xwl_screen));
xwl_output->xwl_screen = xwl_screen;
xwl_output->randr_crtc = RRCrtcCreate(xwl_screen->screen, xwl_output);
@ -1011,10 +1012,3 @@ xwl_screen_init_xdg_output(struct xwl_screen *xwl_screen)
xorg_list_for_each_entry(it, &xwl_screen->output_list, link)
xwl_output_get_xdg_output(it);
}
int
xwl_get_next_output_serial(void)
{
static int output_name_serial = 0;
return output_name_serial++;
}

View File

@ -94,6 +94,4 @@ void xwl_output_set_window_randr_emu_props(struct xwl_screen *xwl_screen,
void xwl_screen_init_xdg_output(struct xwl_screen *xwl_screen);
int xwl_get_next_output_serial(void);
#endif /* XWAYLAND_OUTPUT_H */

View File

@ -580,6 +580,13 @@ xwl_screen_roundtrip(struct xwl_screen *xwl_screen)
xwl_give_up("could not connect to wayland server\n");
}
int
xwl_screen_get_next_output_serial(struct xwl_screen *xwl_screen)
{
return xwl_screen->output_name_serial++;
}
Bool
xwl_screen_init(ScreenPtr pScreen, int argc, char **argv)
{

View File

@ -48,6 +48,7 @@ struct xwl_screen {
int width;
int height;
int depth;
int output_name_serial;
ScreenPtr screen;
int wm_client_id;
int expecting_event;
@ -140,5 +141,6 @@ void xwl_screen_roundtrip (struct xwl_screen *xwl_screen);
void xwl_surface_damage(struct xwl_screen *xwl_screen,
struct wl_surface *surface,
int32_t x, int32_t y, int32_t width, int32_t height);
int xwl_screen_get_next_output_serial(struct xwl_screen * xwl_screen);
#endif /* XWAYLAND_SCREEN_H */