view/xwayland: avoid focusing views that don't want focus

XWayland views can self-declare that they don't want keyboard focus via
the ICCCM WM_HINTS property. Most of the logic is already in place to
avoid giving focus to such views (e.g. taskbars).

Add a couple of missing pieces to make this work:

- Hook up view_isfocusable() to look at WM_HINTS for XWayland views
- Adjust desktop_focus_topmost_mapped_view() to skip unfocusable views
This commit is contained in:
John Lindgren 2023-09-23 11:51:47 -04:00 committed by Johan Malm
parent d503370a77
commit 7e72bf975f
10 changed files with 29 additions and 13 deletions

View file

@ -30,6 +30,16 @@ xwayland_view_get_size_hints(struct view *view)
};
}
static bool
xwayland_view_wants_focus(struct view *view)
{
xcb_icccm_wm_hints_t *hints = xwayland_surface_from_view(view)->hints;
if (!hints) {
return true;
}
return (bool)hints->input;
}
static struct wlr_xwayland_surface *
top_parent_of(struct view *view)
{
@ -505,7 +515,7 @@ xwayland_view_unmap(struct view *view, bool client_request)
view->mapped = false;
wl_list_remove(&view->commit.link);
wlr_scene_node_set_enabled(&view->scene_tree->node, false);
desktop_focus_topmost_mapped_view(view->server);
desktop_focus_topmost_view(view->server);
/*
* If the view was explicitly unmapped by the client (rather
@ -634,6 +644,7 @@ static const struct view_impl xwayland_view_impl = {
.get_root = xwayland_view_get_root,
.append_children = xwayland_view_append_children,
.get_size_hints = xwayland_view_get_size_hints,
.wants_focus = xwayland_view_wants_focus,
};
void