desktop: refactor desktop_focus_topmost_mapped_view()

Rename from desktop_focus_next_mapped_view() to
desktop_focus_topmost_mapped_view() and only take struct server as
argument.
This commit is contained in:
Johan Malm 2020-10-31 14:32:31 +00:00
parent 11ce73f2d6
commit 5f9c5a9d01
4 changed files with 12 additions and 12 deletions

View file

@ -232,7 +232,7 @@ void desktop_focus_view(struct seat *seat, struct view *view);
* Note: If current==NULL, the list's second view is returned
*/
struct view *desktop_next_view(struct server *server, struct view *current);
void desktop_focus_next_mapped_view(struct view *current);
void desktop_focus_topmost_mapped_view(struct server *server);
struct view *desktop_view_at(struct server *server, double lx, double ly,
struct wlr_surface **surface, double *sx,
double *sy, int *view_area);

View file

@ -156,26 +156,26 @@ has_mapped_view(struct wl_list *wl_list)
return false;
}
struct view *
desktop_next_mapped_view(struct view *current)
static struct view *
topmost_mapped_view(struct server *server)
{
assert(current);
struct server *server = current->server;
if (!has_mapped_view(&server->views)) {
return NULL;
}
struct view *view = first_view(server);
/* start from tail of server->views */
struct view *view = wl_container_of(server->views.prev, view, link);
do {
view = wl_container_of(view->link.next, view, link);
} while (&view->link == &server->views || !view->mapped);
return view;
}
void
desktop_focus_next_mapped_view(struct view *current)
desktop_focus_topmost_mapped_view(struct server *server)
{
assert(current);
struct view *view = desktop_next_mapped_view(current);
desktop_focus_view(&current->server->seat, view);
struct view *view = topmost_mapped_view(server);
desktop_focus_view(&server->seat, view);
}
static bool

View file

@ -203,7 +203,7 @@ xdg_toplevel_view_unmap(struct view *view)
{
view->mapped = false;
wl_list_remove(&view->commit.link);
desktop_focus_next_mapped_view(view);
desktop_focus_topmost_mapped_view(view->server);
}
static const struct view_impl xdg_toplevel_view_impl = {

View file

@ -120,7 +120,7 @@ unmap(struct view *view)
{
view->mapped = false;
wl_list_remove(&view->commit.link);
desktop_focus_next_mapped_view(view);
desktop_focus_topmost_mapped_view(view->server);
}
static const struct view_impl xwl_view_impl = {