]> git.mdlowis.com Git - proto/labwc.git/commitdiff
xwayland: validate PID before activating unmanaged surface
authorJohan Malm <jgm323@gmail.com>
Wed, 19 Apr 2023 19:40:40 +0000 (20:40 +0100)
committerJohan Malm <johanmalm@users.noreply.github.com>
Fri, 21 Apr 2023 14:59:36 +0000 (15:59 +0100)
Check that an unmanaged surface trying to grab focus is actually a child
of the topmost mapped view.

include/labwc.h
src/desktop.c
src/xwayland-unmanaged.c

index 9abe32b2ac1ae387c813b1455278204929ac112d..d6bd36c1eadbbc13463763ec8b8ac58092031c44 100644 (file)
@@ -374,6 +374,7 @@ void foreign_toplevel_update_outputs(struct view *view);
 void desktop_focus_and_activate_view(struct seat *seat, struct view *view);
 void desktop_arrange_all_views(struct server *server);
 void desktop_focus_output(struct output *output);
+struct view *desktop_topmost_mapped_view(struct server *server);
 
 enum lab_cycle_dir {
        LAB_CYCLE_DIR_NONE,
index 5a4acffae35209c3d73df154ddb76348d8584713..bab5d725afaee1910a84ff6f4666ae58701d6584 100644 (file)
@@ -200,8 +200,8 @@ desktop_cycle_view(struct server *server, struct view *start_view,
        return NULL;
 }
 
-static struct view *
-topmost_mapped_view(struct server *server)
+struct view *
+desktop_topmost_mapped_view(struct server *server)
 {
        struct view *view;
        struct wl_list *node_list;
@@ -242,7 +242,7 @@ desktop_focused_view(struct server *server)
 void
 desktop_focus_topmost_mapped_view(struct server *server)
 {
-       struct view *view = topmost_mapped_view(server);
+       struct view *view = desktop_topmost_mapped_view(server);
        desktop_focus_and_activate_view(&server->seat, view);
        if (view) {
                view_move_to_front(view);
index a26a8f7d3c7652221b0fd51f14d0e6a2fec53d4b..9aaf42d6fa6631f41885322886524ec7884aa843 100644 (file)
@@ -166,6 +166,20 @@ unmanaged_handle_request_activate(struct wl_listener *listener, void *data)
        struct xwayland_unmanaged *unmanaged = xsurface->data;
        struct server *server = unmanaged->server;
        struct seat *seat = &server->seat;
+
+       /*
+        * Validate that the unmanaged surface trying to grab focus is actually
+        * a child of the topmost mapped view before granting the request.
+        */
+       struct view *view = desktop_topmost_mapped_view(server);
+       if (view && view->type == LAB_XWAYLAND_VIEW) {
+               struct wlr_xwayland_surface *surf =
+                       wlr_xwayland_surface_from_wlr_surface(view->surface);
+               if (surf && surf->pid != xsurface->pid) {
+                       return;
+               }
+       }
+
        seat_focus_surface(seat, xsurface->surface);
 }