From 9d8ca321d6913c2dd084f683e2845f9b4ad7ca66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Mon, 4 Jan 2021 18:32:00 +0100 Subject: [PATCH] =?UTF-8?q?input:=20don=E2=80=99t=20assert=20when=20receiv?= =?UTF-8?q?ing=20a=20button=20release=20without=20a=20press=20event?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- input.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/input.c b/input.c index b1154e9f..fe9e143a 100644 --- a/input.c +++ b/input.c @@ -1537,6 +1537,11 @@ wl_pointer_button(void *data, struct wl_pointer *wl_pointer, assert(it->item.button != button); #endif + /* + * Remember which surface "owns" this button, so that we can + * send motion and button release events to that surface, even + * if the pointer is no longer over it. + */ tll_push_back( seat->mouse.buttons, ((struct button_tracker){ @@ -1559,7 +1564,21 @@ wl_pointer_button(void *data, struct wl_pointer *wl_pointer, break; } } - assert(have_button); + + if (!have_button) { + /* + * Seen on Sway with slurp + * + * 1. Run slurp + * 2. Press, and hold left mouse button + * 3. Press escape, to cancel slurp + * 4. Release mouse button + * 5. BAM! + */ + LOG_WARN("stray button release event"); + return; + } + seat->mouse.last_released_button = button; }