xwayland: Clean up drm lease when terminating. #946

This commit is contained in:
Russell Chou 2023-07-17 08:25:39 +00:00 committed by Olivier Fourdan
parent befef003d4
commit ef1812655b

View File

@ -35,6 +35,18 @@
#include "xwayland-screen.h" #include "xwayland-screen.h"
#include "xwayland-output.h" #include "xwayland-output.h"
static void
xwl_randr_lease_cleanup_outputs(RRLeasePtr rrLease)
{
struct xwl_output *output;
int i;
for (i = 0; i < rrLease->numOutputs; ++i) {
output = rrLease->outputs[i]->devPrivate;
output->lease = NULL;
}
}
static void static void
drm_lease_handle_lease_fd(void *data, drm_lease_handle_lease_fd(void *data,
struct wp_drm_lease_v1 *wp_drm_lease_v1, struct wp_drm_lease_v1 *wp_drm_lease_v1,
@ -51,17 +63,12 @@ drm_lease_handle_finished(void *data,
struct wp_drm_lease_v1 *wp_drm_lease_v1) struct wp_drm_lease_v1 *wp_drm_lease_v1)
{ {
struct xwl_drm_lease *lease = (struct xwl_drm_lease *)data; struct xwl_drm_lease *lease = (struct xwl_drm_lease *)data;
struct xwl_output *output;
int i;
if (lease->fd >= 0) { if (lease->fd >= 0) {
RRTerminateLease(lease->rrLease); RRTerminateLease(lease->rrLease);
} else { } else {
AttendClient(lease->client); AttendClient(lease->client);
for (i = 0; i < lease->rrLease->numOutputs; ++i) { xwl_randr_lease_cleanup_outputs(lease->rrLease);
output = lease->rrLease->outputs[i]->devPrivate;
output->lease = NULL;
}
} }
} }
@ -164,6 +171,7 @@ xwl_randr_terminate_lease(ScreenPtr screen, RRLeasePtr lease)
struct xwl_drm_lease *lease_private = lease->devPrivate; struct xwl_drm_lease *lease_private = lease->devPrivate;
if (lease_private) { if (lease_private) {
xwl_randr_lease_cleanup_outputs(lease);
xorg_list_del(&lease_private->link); xorg_list_del(&lease_private->link);
if (lease_private->fd >= 0) if (lease_private->fd >= 0)
close(lease_private->fd); close(lease_private->fd);