From 5324ace9334c6efa4ccc1b41d655d14f4bf51e2a Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Mon, 11 Dec 2023 14:45:03 +0100 Subject: [PATCH] libweston-desktop: Work around crash when opening popup menu Fix a crash when right-clicking on a weston-terminal, where weston_desktop_seat_popup_grab_add_surface() is called with seat->popup_grab.keyboard.keyboard == NULL in case there is no keyboard connected. Signed-off-by: Philipp Zabel (cherry picked from commit b72785e1f651769de7184fe14925ee21e947ce5a) --- libweston/desktop/seat.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libweston/desktop/seat.c b/libweston/desktop/seat.c index bc6b310af..7edc23080 100644 --- a/libweston/desktop/seat.c +++ b/libweston/desktop/seat.c @@ -538,6 +538,9 @@ weston_desktop_seat_popup_grab_add_surface(struct weston_desktop_seat *seat, wl_list_insert(&seat->popup_grab.surfaces, link); + if (!seat->popup_grab.keyboard.keyboard) + return; + desktop_surface = weston_desktop_seat_popup_grab_get_topmost_surface(seat); surface = weston_desktop_surface_get_surface(desktop_surface); @@ -558,6 +561,9 @@ weston_desktop_seat_popup_grab_remove_surface(struct weston_desktop_seat *seat, struct weston_desktop_surface *desktop_surface; struct weston_surface *surface; + if (!seat->popup_grab.keyboard.keyboard) + return; + desktop_surface = weston_desktop_seat_popup_grab_get_topmost_surface(seat); surface = weston_desktop_surface_get_surface(desktop_surface);