diff options
author | Simon Ser <contact@emersion.fr> | 2023-11-13 10:32:03 +0100 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2023-11-13 10:32:03 +0100 |
commit | 9e5d0f95f88b6774c81dfa4c8775bf7d0f09bf19 (patch) | |
tree | 702edcfc114c51c91f0114fba6e3c6fd8c89971e /tinywl | |
parent | 319e4125ab699c2346c7d1b66ff8d06064ec6ac2 (diff) |
tinywl: fix crash when previously focused surface is not a toplevel
It can be e.g. a popup.
Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3754
Diffstat (limited to 'tinywl')
-rw-r--r-- | tinywl/tinywl.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/tinywl/tinywl.c b/tinywl/tinywl.c index 7d1a3806..6975ee62 100644 --- a/tinywl/tinywl.c +++ b/tinywl/tinywl.c @@ -120,11 +120,10 @@ static void focus_view(struct tinywl_view *view, struct wlr_surface *surface) { * it no longer has focus and the client will repaint accordingly, e.g. * stop displaying a caret. */ - struct wlr_xdg_surface *previous = - wlr_xdg_surface_try_from_wlr_surface(seat->keyboard_state.focused_surface); - assert(previous != NULL && previous->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL); - if (previous->toplevel != NULL) { - wlr_xdg_toplevel_set_activated(previous->toplevel, false); + struct wlr_xdg_toplevel *prev_toplevel = + wlr_xdg_toplevel_try_from_wlr_surface(prev_surface); + if (prev_toplevel != NULL) { + wlr_xdg_toplevel_set_activated(prev_toplevel, false); } } struct wlr_keyboard *keyboard = wlr_seat_get_keyboard(seat); |