xdg-shell: handle serial wrapping overflow

This commit is contained in:
Isaac Freund 2020-06-24 15:19:05 +02:00 committed by Simon Ser
parent b937c7b05e
commit 86e20f48c6
2 changed files with 21 additions and 13 deletions

View file

@ -107,17 +107,13 @@ static void xdg_surface_handle_ack_configure(struct wl_client *client,
return; return;
} }
// First find the ack'ed configure
bool found = false; bool found = false;
struct wlr_xdg_surface_configure *configure, *tmp; struct wlr_xdg_surface_configure *configure, *tmp;
wl_list_for_each_safe(configure, tmp, &surface->configure_list, link) { wl_list_for_each(configure, &surface->configure_list, link) {
if (configure->serial < serial) { if (configure->serial == serial) {
wlr_signal_emit_safe(&surface->events.ack_configure, configure);
xdg_surface_configure_destroy(configure);
} else if (configure->serial == serial) {
found = true; found = true;
break; break;
} else {
break;
} }
} }
if (!found) { if (!found) {
@ -126,6 +122,14 @@ static void xdg_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;
}
wlr_signal_emit_safe(&surface->events.ack_configure, configure);
xdg_surface_configure_destroy(configure);
}
switch (surface->role) { switch (surface->role) {
case WLR_XDG_SURFACE_ROLE_NONE: case WLR_XDG_SURFACE_ROLE_NONE:

View file

@ -156,16 +156,13 @@ static void xdg_surface_handle_ack_configure(struct wl_client *client,
return; return;
} }
// First find the ack'ed configure
bool found = false; bool found = false;
struct wlr_xdg_surface_v6_configure *configure, *tmp; struct wlr_xdg_surface_v6_configure *configure, *tmp;
wl_list_for_each_safe(configure, tmp, &surface->configure_list, link) { wl_list_for_each(configure, &surface->configure_list, link) {
if (configure->serial < serial) { if (configure->serial == serial) {
xdg_surface_configure_destroy(configure);
} else if (configure->serial == serial) {
found = true; found = true;
break; break;
} else {
break;
} }
} }
if (!found) { if (!found) {
@ -174,6 +171,13 @@ static void xdg_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;
}
xdg_surface_configure_destroy(configure);
}
switch (surface->role) { switch (surface->role) {
case WLR_XDG_SURFACE_V6_ROLE_NONE: case WLR_XDG_SURFACE_V6_ROLE_NONE: