compositor: add wlr_surface_queue_lazy_leave()

And also wlr_surface_process_lazy_leaves()

This is motivated by fixing inconsistent enter/leave events sent by
wlr_scene when there are multiple scenes active with distinct outputs.
This commit is contained in:
Isaac Freund 2026-03-27 10:40:32 +01:00
parent f295d0322a
commit 8e44489bf7
No known key found for this signature in database
GPG key ID: 86DED400DDFD7A11
2 changed files with 69 additions and 0 deletions

View file

@ -1084,6 +1084,7 @@ void wlr_surface_send_enter(struct wlr_surface *surface,
wl_list_for_each(surface_output, &surface->current_outputs, link) {
if (surface_output->output == output) {
surface_output->lazy_leave = false;
return;
}
}
@ -1129,6 +1130,45 @@ void wlr_surface_send_leave(struct wlr_surface *surface,
}
}
void wlr_surface_queue_lazy_leave(struct wlr_surface *surface, struct wlr_output *output) {
struct wlr_surface_output *surface_output;
wl_list_for_each(surface_output, &surface->current_outputs, link) {
if (surface_output->output == output) {
surface_output->lazy_leave = true;
}
}
}
void wlr_surface_process_lazy_leaves(struct wlr_surface *surface) {
// Only send leave events if at least one output would remain entered.
bool send_leave_events = false;
struct wlr_surface_output *surface_output;
wl_list_for_each(surface_output, &surface->current_outputs, link) {
if (!surface_output->lazy_leave) {
send_leave_events = true;
}
}
if (!send_leave_events) {
return;
}
struct wl_client *client = wl_resource_get_client(surface->resource);
struct wlr_surface_output *tmp;
wl_list_for_each_safe(surface_output, tmp, &surface->current_outputs, link) {
if (surface_output->lazy_leave) {
struct wl_resource *resource;
wl_resource_for_each(resource, &surface_output->output->resources) {
if (client == wl_resource_get_client(resource)) {
wl_surface_send_leave(surface->resource, resource);
}
}
surface_output_destroy(surface_output);
break;
}
}
}
void wlr_surface_send_frame_done(struct wlr_surface *surface,
const struct timespec *when) {
struct wl_resource *resource, *tmp;