Implement iterators per container type

This introduces the following `for_each` functions:

* root_for_each_workspace
* root_for_each_container
* output_for_each_workspace
* output_for_each_container
* workspace_for_each_container

And introduces the following `find` functions:

* root_find_output
* root_find_workspace
* root_find_container
* output_find_workspace
* output_find_container
* workspace_find_container
* container_find_child

And removes the following functions:

* container_descendants
* container_for_each_descendant
* container_find

This change is preparing the way for demoting sway_container. Eventually
these functions will accept and return sway_outputs, sway_workspaces and
sway_containers (meaning a C_CONTAINER or C_VIEW).

This change also makes it easy to handle abnormalities like the
workspace floating list, root's scratchpad list and (once implemented)
root's saved workspaces list for when there's no connected outputs.
This commit is contained in:
Ryan Dwyer 2018-08-17 19:48:34 +10:00
parent d4a32800d5
commit d6cd79c342
18 changed files with 268 additions and 110 deletions

View file

@ -313,9 +313,6 @@ static void handle_new_drag_icon(struct wl_listener *listener, void *data) {
static void collect_focus_iter(struct sway_container *con, void *data) {
struct sway_seat *seat = data;
if (con->type > C_WORKSPACE) {
return;
}
struct sway_seat_container *seat_con =
seat_container_from_container(seat, con);
if (!seat_con) {
@ -349,7 +346,8 @@ struct sway_seat *seat_create(struct sway_input_manager *input,
// init the focus stack
wl_list_init(&seat->focus_stack);
container_for_each_descendant(&root_container, collect_focus_iter, seat);
root_for_each_workspace(collect_focus_iter, seat);
root_for_each_container(collect_focus_iter, seat);
wl_signal_add(&root_container.sway_root->events.new_container,
&seat->new_container);