Commit cfe0ae65c9382212efcc9efb1b03ca4f0e78adda Parent: 6cccc312a5939aafbf8d2f7ec5afeeab80d2b6ff Author: mcol <mcol@posteo.net> Date: 2021-02-06 21:01:58 +0000 Committer: mcol <mcol@posteo.net> Committed: 2021-02-06 21:01:58 +0000 clean up view_to_desk
src/desk.c Modified
@@ -40,6 +40,7 @@ wimp.desk_count--; } + void configure_desks(int wanted) { while (wanted > wimp.desk_count) { add_desk(); @@ -70,22 +71,28 @@ } -void view_to_desk(struct view *view, int index) { +static struct desk *desk_from_index(int index) { struct desk *desk; - wimp.can_steal_focus = false; - wl_list_for_each(desk, &wimp.desks, link) { if (desk->index == index) { - wl_list_remove(&view->link); - desk == wimp.current_desk ? map_view(view) : unmap_view(view); - wl_list_insert(&desk->views, &view->link); - break; + return desk; } } + return NULL; +} - wimp.can_steal_focus = true; - if (!wl_list_empty(&wimp.current_desk->views)) { - struct view *next_view = wl_container_of(wimp.current_desk->views.next, view, link); - focus_view(next_view, next_view->surface->surface); + +void view_to_desk(struct view *view, int index) { + wimp.can_steal_focus = false; + struct desk *desk = desk_from_index(index); + if (desk) { + wl_list_remove(&view->link); + desk == wimp.current_desk ? map_view(view) : unmap_view(view); + wl_list_insert(&desk->views, &view->link); + wimp.can_steal_focus = true; + if (!wl_list_empty(&wimp.current_desk->views)) { + struct view *next_view = wl_container_of(wimp.current_desk->views.next, view, link); + focus_view(next_view, next_view->surface->surface); + } } }