layer-shell: handle serial wrapping overflow

This commit is contained in:
Isaac Freund 2020-06-24 15:18:00 +02:00 committed by Simon Ser
parent 4a4da256dd
commit b937c7b05e
1 changed files with 13 additions and 9 deletions

View File

@ -58,20 +58,17 @@ static void layer_surface_handle_ack_configure(struct wl_client *client,
struct wl_resource *resource, uint32_t serial) {
struct wlr_layer_surface_v1 *surface = layer_surface_from_resource(resource);
bool found = false;
struct wlr_layer_surface_v1_configure *configure, *tmp;
if (!surface || surface->closed) {
return;
}
wl_list_for_each_safe(configure, tmp, &surface->configure_list, link) {
if (configure->serial < serial) {
layer_surface_configure_destroy(configure);
} else if (configure->serial == serial) {
// First find the ack'ed configure
bool found = false;
struct wlr_layer_surface_v1_configure *configure, *tmp;
wl_list_for_each(configure, &surface->configure_list, link) {
if (configure->serial == serial) {
found = true;
break;
} else {
break;
}
}
if (!found) {
@ -80,6 +77,13 @@ static void layer_surface_handle_ack_configure(struct wl_client *client,
"wrong configure serial: %u", serial);
return;
}
// Then remove old configures from the list
wl_list_for_each_safe(configure, tmp, &surface->configure_list, link) {
if (configure->serial == serial) {
break;
}
layer_surface_configure_destroy(configure);
}
if (surface->acked_configure) {
layer_surface_configure_destroy(surface->acked_configure);