* 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);
struct view *desktop_view_at(struct server *server, double lx, double ly,
struct wlr_surface **surface, double *sx,
double *sy, int *view_area);
void desktop_focus_view(struct view *view)
{
- if (!view)
+ if (!view) {
+ seat_focus_surface(NULL);
return;
+ }
if (view->minimized)
view_unminimize(view); /* this will unmap+focus */
else if (view->mapped)
return (view->mapped || view->minimized);
}
-static int has_focusable_view(struct wl_list *wl_list)
+static bool has_focusable_view(struct wl_list *wl_list)
{
struct view *view;
wl_list_for_each (view, wl_list, link) {
return view;
}
+static bool has_mapped_view(struct wl_list *wl_list)
+{
+ struct view *view;
+ wl_list_for_each (view, wl_list, link) {
+ if (view->mapped)
+ return true;
+ }
+ return false;
+}
+
+struct view *desktop_next_mapped_view(struct view *current)
+{
+ BUG_ON(!current);
+ struct server *server = current->server;
+ if (!has_mapped_view(&server->views))
+ return NULL;
+ struct view *view = first_view(server);
+ 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)
+{
+ BUG_ON(!current);
+ struct view *view = desktop_next_mapped_view(current);
+ desktop_focus_view(view);
+}
+
static bool _view_at(struct view *view, double lx, double ly,
struct wlr_surface **surface, double *sx, double *sy)
{
{
view->mapped = false;
wl_list_remove(&view->commit.link);
- desktop_focus_view(desktop_next_view(view->server, view));
+ desktop_focus_next_mapped_view(view);
}
static const struct view_impl xdg_toplevel_view_impl = {
{
view->mapped = false;
wl_list_remove(&view->commit.link);
- desktop_focus_view(desktop_next_view(view->server, view));
+ desktop_focus_next_mapped_view(view);
}
static const struct view_impl xwl_view_impl = {