]> git.mdlowis.com Git - proto/labwc.git/commitdiff
xwayland: fix possible loss of focus when multiple views are unmapped
authorJohn Lindgren <john@jlindgren.net>
Wed, 11 Jun 2025 20:12:56 +0000 (16:12 -0400)
committerJohan Malm <johanmalm@users.noreply.github.com>
Thu, 12 Jun 2025 19:33:25 +0000 (20:33 +0100)
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.

src/view-impl-common.c

index 9e8e9a1ed03f71a11e9396b752504da1769c5255..3357367b63b40493dcd9af72f9a370b4a4667e2b 100644 (file)
@@ -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);
        }
 }