mirror of
https://github.com/labwc/labwc.git
synced 2026-03-21 05:33:52 -04:00
xwayland: fix possible loss of focus when multiple views are unmapped
Due to the asynchronous nature of view_offer_focus(), there was a race condition that could result in no view remaining active when multiple views were unmapped at once. Check for this and prevent it.
This commit is contained in:
parent
1b937ed247
commit
5a50a02ba3
1 changed files with 9 additions and 1 deletions
|
|
@ -46,7 +46,15 @@ void
|
||||||
view_impl_unmap(struct view *view)
|
view_impl_unmap(struct view *view)
|
||||||
{
|
{
|
||||||
struct server *server = view->server;
|
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);
|
desktop_focus_topmost_view(server);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue