define focused_view function and use it for keyboard actions

This commit is contained in:
bi4k8 2021-09-19 22:20:54 +00:00 committed by Johan Malm
parent a15a56bfe1
commit 815cd4aa46
3 changed files with 26 additions and 6 deletions

View file

@ -212,6 +212,25 @@ topmost_mapped_view(struct server *server)
return view;
}
struct view *
focused_view(struct server *server)
{
struct seat *seat = &server->seat;
struct wlr_surface *focused_surface;
focused_surface = seat->seat->keyboard_state.focused_surface;
if (!focused_surface) {
return NULL;
}
struct view *view;
wl_list_for_each (view, &server->views, link) {
if (view->surface == focused_surface) {
return view;
}
}
return NULL;
}
void
desktop_focus_topmost_mapped_view(struct server *server)
{