diff --git a/src/view-impl-common.c b/src/view-impl-common.c index 9e8e9a1e..3357367b 100644 --- a/src/view-impl-common.c +++ b/src/view-impl-common.c @@ -46,7 +46,15 @@ void view_impl_unmap(struct view *view) { struct server *server = view->server; - if (view == server->active_view) { + /* + * When exiting an xwayland application with multiple views + * mapped, a race condition can occur: after the topmost view + * is unmapped, the next view under it is offered focus, but is + * also unmapped before accepting focus (so server->active_view + * remains NULL). To avoid being left with no active view at + * all, check for that case also. + */ + if (view == server->active_view || !server->active_view) { desktop_focus_topmost_view(server); } }