Fix pid lookup for the Kill action

Before this patch, labwc would happily kill itself when the user
called the `Kill` action when any xwayland view had focus.

The reason this happened was that wlroots creates the xwayland
wayland client via socketpair() and thus a lookup of the pid
of the socket connection would return the pid of labwc itself.

This patch fixes that by implementing different pid lookup
mechanisms based on the view implementation backend.

Fixes: #1739
This commit is contained in:
Consolatis 2024-04-22 17:43:46 +02:00 committed by Johan Malm
parent a109e6e3e8
commit 3f10857496
4 changed files with 37 additions and 5 deletions

View file

@ -838,6 +838,19 @@ xwayland_view_set_fullscreen(struct view *view, bool fullscreen)
fullscreen);
}
static pid_t
xwayland_view_get_pid(struct view *view)
{
assert(view);
struct wlr_xwayland_surface *xwayland_surface =
xwayland_surface_from_view(view);
if (!xwayland_surface) {
return -1;
}
return xwayland_surface->pid;
}
static const struct view_impl xwayland_view_impl = {
.configure = xwayland_view_configure,
.close = xwayland_view_close,
@ -856,6 +869,7 @@ static const struct view_impl xwayland_view_impl = {
.wants_focus = xwayland_view_wants_focus,
.has_strut_partial = xwayland_view_has_strut_partial,
.contains_window_type = xwayland_view_contains_window_type,
.get_pid = xwayland_view_get_pid,
};
void