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 <p.zabel@pengutronix.de>
(cherry picked from commit b72785e1f6)
This commit is contained in:
Philipp Zabel 2023-12-11 14:45:03 +01:00 committed by Marius Vlad
parent ab1987f41e
commit 5324ace933

View file

@ -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);