]> git.mdlowis.com Git - proto/labwc.git/commitdiff
xwayland: guard against mapping view without surface
authorJohan Malm <jgm323@gmail.com>
Fri, 4 Aug 2023 20:58:52 +0000 (21:58 +0100)
committerJohan Malm <johanmalm@users.noreply.github.com>
Sat, 5 Aug 2023 14:25:00 +0000 (15:25 +0100)
...which may occur if a user minimizes an xwayland view (typically a
child view such as a dialog) at the same time as the client sends a
request-unmap, which xwayland clients sometimes do without actually
requesting destroy and just leave them dangling.

src/xwayland.c

index a8d4b8ef52c071103b26fb8dbcac4d02c54c0e7e..d456ac52827651e071a41517eab38757d510e743 100644 (file)
@@ -410,14 +410,23 @@ top_left_edge_boundary_check(struct view *view)
 static void
 xwayland_view_map(struct view *view)
 {
+       struct wlr_xwayland_surface *xwayland_surface = xwayland_surface_from_view(view);
        if (view->mapped) {
                return;
        }
+       if (!xwayland_surface->surface) {
+               /*
+                * We may get here if a user minimizes an xwayland dialog at the
+                * same time as the client requests unmap, which xwayland
+                * clients sometimes do without actually requesting destroy
+                * even if they don't intend to use that view/surface anymore
+                */
+               wlr_log(WLR_DEBUG, "Cannot map view without wlr_surface");
+               return;
+       }
        view->mapped = true;
        ensure_initial_geometry_and_output(view);
        wlr_scene_node_set_enabled(&view->scene_tree->node, true);
-       struct wlr_xwayland_surface *xwayland_surface =
-               xwayland_surface_from_view(view);
        if (!view->fullscreen && xwayland_surface->fullscreen) {
                view_set_fullscreen(view, true);
        }