[PATCH] compositor-wayland: Ignore pointer enter on destroyed surface

Daniel Stone daniels at collabora.com
Fri Mar 9 10:08:37 UTC 2018


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 at collabora.com>
Cc: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
---
 libweston/compositor-wayland.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
index 9c401d2e6..964b84e4b 100644
--- a/libweston/compositor-wayland.c
+++ b/libweston/compositor-wayland.c
@@ -1525,6 +1525,14 @@ 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);
+		input_set_cursor(input);
+		return;
+	}
+
 	x = wl_fixed_to_double(fixed_x);
 	y = wl_fixed_to_double(fixed_y);
 
-- 
2.16.2



More information about the wayland-devel mailing list