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

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