xdg-decoration: free old configure structs

This commit is contained in:
Isaac Freund 2020-06-24 15:19:26 +02:00 committed by Simon Ser
parent 86e20f48c6
commit a7f48aab69

View file

@ -111,8 +111,9 @@ static void toplevel_decoration_handle_surface_ack_configure(
wl_container_of(listener, decoration, surface_ack_configure); wl_container_of(listener, decoration, surface_ack_configure);
struct wlr_xdg_surface_configure *surface_configure = data; struct wlr_xdg_surface_configure *surface_configure = data;
// First find the ack'ed configure
bool found = false; bool found = false;
struct wlr_xdg_toplevel_decoration_v1_configure *configure; struct wlr_xdg_toplevel_decoration_v1_configure *configure, *tmp;
wl_list_for_each(configure, &decoration->configure_list, link) { wl_list_for_each(configure, &decoration->configure_list, link) {
if (configure->surface_configure == surface_configure) { if (configure->surface_configure == surface_configure) {
found = true; found = true;
@ -122,6 +123,14 @@ static void toplevel_decoration_handle_surface_ack_configure(
if (!found) { if (!found) {
return; return;
} }
// Then remove old configures from the list
wl_list_for_each_safe(configure, tmp, &decoration->configure_list, link) {
if (configure->surface_configure == surface_configure) {
break;
}
wl_list_remove(&configure->link);
free(configure);
}
decoration->current_mode = configure->mode; decoration->current_mode = configure->mode;