clients: Drop corresponding touch points when destroying windows
authorJeffy Chen <jeffy.chen@rock-chips.com>
Mon, 2 Sep 2019 02:15:26 +0000 (10:15 +0800)
committerDaniel Stone <daniel@fooishbar.org>
Thu, 21 Nov 2019 16:54:38 +0000 (16:54 +0000)
This is to avoid memory leaking of these touch points.

Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
clients/window.c

index 1c5a81f1ee1f500182407159a1440d16ac0f0d3a..3d1e8e4a28c7e3fed327f7257907c7d3c7eb3324 100644 (file)
@@ -1568,8 +1568,18 @@ window_destroy(struct window *window)
        wl_list_remove(&window->redraw_task.link);
 
        wl_list_for_each(input, &display->input_list, link) {
-               if (input->touch_focus == window)
+               if (input->touch_focus == window) {
+                       struct touch_point *tp, *tmp;
+
+                       wl_list_for_each_safe(tp, tmp,
+                                             &input->touch_point_list,
+                                             link) {
+                               wl_list_remove(&tp->link);
+                               free(tp);
+                       }
+
                        input->touch_focus = NULL;
+               }
                if (input->pointer_focus == window)
                        input->pointer_focus = NULL;
                if (input->keyboard_focus == window)