]> git.mdlowis.com Git - proto/labwc.git/commitdiff
src/view.c: refactor
authorJohan Malm <jgm323@gmail.com>
Fri, 7 Aug 2020 19:39:11 +0000 (20:39 +0100)
committerJohan Malm <jgm323@gmail.com>
Fri, 7 Aug 2020 19:39:11 +0000 (20:39 +0100)
src/view.c

index 0d7b72cea8fa258cc0828425969d8493e99df750..54191de882bd787bdebc2d786dfae537e8cbf26a 100644 (file)
@@ -2,11 +2,13 @@
 
 static bool is_toplevel(struct view *view)
 {
+       if (!view->been_mapped)
+               return false;
        switch (view->type) {
        case LAB_XDG_SHELL_VIEW:
                return view->xdg_surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL;
        case LAB_XWAYLAND_VIEW:
-               return xwl_nr_parents(view) > 0 ? false : true;
+               return xwl_nr_parents(view) == 0;
        }
        return false;
 }
@@ -151,14 +153,13 @@ void view_focus(struct view *view)
        wlr_seat_keyboard_notify_enter(seat, view->surface, keyboard->keycodes,
                                       keyboard->num_keycodes,
                                       &keyboard->modifiers);
+       /* TODO: bring child views to front */
 }
 
 struct view *view_front_toplevel(struct server *server)
 {
        struct view *view;
        wl_list_for_each (view, &server->views, link) {
-               if (!view->been_mapped)
-                       continue;
                if (is_toplevel(view))
                        return view;
        }
@@ -172,7 +173,7 @@ struct view *next_toplevel(struct view *current)
        struct view *view = current;
        do {
                view = wl_container_of(view->link.next, view, link);
-       } while (!view->been_mapped || !is_toplevel(view));
+       } while (!is_toplevel(view));
        return view;
 }