view: add view_wants_focus enum (NEVER/ALWAYS/OFFER) and function

This allows identifying XWayland views using the ICCCM "Globally Active"
input model. Later commits will improve handling of these views.

No functional change in this commit.
This commit is contained in:
John Lindgren 2023-10-15 01:11:12 -04:00 committed by Johan Malm
parent 8bb2e2123f
commit dd7f563a50
3 changed files with 79 additions and 20 deletions

View file

@ -143,6 +143,16 @@ view_array_append(struct server *server, struct wl_array *views,
}
}
enum view_wants_focus
view_wants_focus(struct view *view)
{
assert(view);
if (view->impl->wants_focus) {
return view->impl->wants_focus(view);
}
return VIEW_WANTS_FOCUS_ALWAYS;
}
bool
view_is_focusable(struct view *view)
{
@ -150,7 +160,7 @@ view_is_focusable(struct view *view)
if (!view->surface) {
return false;
}
if (view->impl->wants_focus && !view->impl->wants_focus(view)) {
if (view_wants_focus(view) != VIEW_WANTS_FOCUS_ALWAYS) {
return false;
}
return (view->mapped || view->minimized);