compositor-wayland: Ignore pointer enter on destroyed surface
authorDaniel Stone <daniels@collabora.com>
Fri, 9 Mar 2018 10:08:37 +0000 (10:08 +0000)
committerPekka Paalanen <pekka.paalanen@collabora.co.uk>
Fri, 9 Mar 2018 14:17:47 +0000 (16:17 +0200)
Due to race conditions, it is (vanishingly unlikely but) possible to
receive a wl_pointer.enter event referring to a wl_surface we have just
destroyed. If this happens, wl_surface will be NULL. Detect this, clear
out our focus, and return.

Other pointer and keyboard events are robust against destroyed surfaces.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Cc: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
[Pekka: remove call to input_set_cursor()]
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
libweston/compositor-wayland.c

index 9c401d2e6970d57f074a6bdca65f12a322620fdc..f51f78ddecd4b16160edac0c1727252494bf6a78 100644 (file)
@@ -1525,6 +1525,13 @@ input_handle_pointer_enter(void *data, struct wl_pointer *pointer,
        enum theme_location location;
        double x, y;
 
+       if (!surface) {
+               input->output = NULL;
+               input->has_focus = false;
+               notify_pointer_focus(&input->base, NULL, 0, 0);
+               return;
+       }
+
        x = wl_fixed_to_double(fixed_x);
        y = wl_fixed_to_double(fixed_y);