From e072fbc6d98784e5610aa88251a15f64e30bbcae Mon Sep 17 00:00:00 2001 From: Brian Ashworth Date: Wed, 6 Jun 2018 20:10:42 -0400 Subject: Switch output storing from list_t to wl_list --- include/sway/output.h | 2 ++ include/sway/tree/layout.h | 2 +- sway/commands/output.c | 5 ++--- sway/desktop/output.c | 15 ++++----------- sway/ipc-server.c | 5 ++--- sway/tree/layout.c | 2 +- 6 files changed, 12 insertions(+), 19 deletions(-) diff --git a/include/sway/output.h b/include/sway/output.h index 22c84039..70f746dc 100644 --- a/include/sway/output.h +++ b/include/sway/output.h @@ -29,6 +29,8 @@ struct sway_output { struct wl_listener damage_destroy; struct wl_listener damage_frame; + struct wl_list link; + pid_t bg_pid; }; diff --git a/include/sway/tree/layout.h b/include/sway/tree/layout.h index 069a02cc..cd131056 100644 --- a/include/sway/tree/layout.h +++ b/include/sway/tree/layout.h @@ -31,7 +31,7 @@ struct sway_root { struct wlr_texture *debug_tree; - list_t *outputs; + struct wl_list outputs; // sway_output::link struct { struct wl_signal new_container; diff --git a/sway/commands/output.c b/sway/commands/output.c index 6c789cc9..f955bf90 100644 --- a/sway/commands/output.c +++ b/sway/commands/output.c @@ -82,9 +82,8 @@ struct cmd_results *cmd_output(int argc, char **argv) { // will be applied during normal "new output" event from wlroots. char identifier[128]; bool all = strcmp(output->name, "*") == 0; - list_t *sway_outputs = root_container.sway_root->outputs; - for (int i = 0; i < sway_outputs->length; ++i) { - struct sway_output *sway_output = sway_outputs->items[i]; + struct sway_output *sway_output; + wl_list_for_each(sway_output, &root_container.sway_root->outputs, link) { output_get_identifier(identifier, sizeof(identifier), sway_output); wlr_log(L_DEBUG, "Checking identifier %s", identifier); if (all || strcmp(sway_output->wlr_output->name, output->name) == 0 diff --git a/sway/desktop/output.c b/sway/desktop/output.c index cb53a980..3142bdb4 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c @@ -1157,10 +1157,6 @@ void output_damage_whole_container(struct sway_output *output, wlr_output_damage_add_box(output->damage, &box); } -static int find_output(const void *output1, const void *output2) { - return output1 == output2 ? 0 : 1; -} - static void damage_handle_destroy(struct wl_listener *listener, void *data) { struct sway_output *output = wl_container_of(listener, output, damage_destroy); @@ -1172,12 +1168,9 @@ static void handle_destroy(struct wl_listener *listener, void *data) { if (output->swayc) { container_destroy(output->swayc); } - int index = list_seq_find(root_container.sway_root->outputs, find_output, - output); - if (index >= 0 && index < root_container.sway_root->outputs->length) { - wlr_log(L_DEBUG, "Removing %s from outputs list", - output->wlr_output->name); - list_del(root_container.sway_root->outputs, index); + + if (&output->link) { + wl_list_remove(&output->link); wl_list_remove(&output->destroy.link); output->wlr_output = NULL; free(output); @@ -1219,7 +1212,7 @@ void handle_new_output(struct wl_listener *listener, void *data) { output->wlr_output = wlr_output; wlr_output->data = output; output->server = server; - list_add(root_container.sway_root->outputs, output); + wl_list_insert(&root_container.sway_root->outputs, &output->link); output->damage = wlr_output_damage_create(wlr_output); diff --git a/sway/ipc-server.c b/sway/ipc-server.c index 2a2346b4..241fe742 100644 --- a/sway/ipc-server.c +++ b/sway/ipc-server.c @@ -489,9 +489,8 @@ void ipc_client_handle_command(struct ipc_client *client) { ipc_json_describe_container(container)); } } - for (int i = 0; i < root_container.sway_root->outputs->length; ++i) { - struct sway_output *output = - root_container.sway_root->outputs->items[i]; + struct sway_output *output; + wl_list_for_each(output, &root_container.sway_root->outputs, link) { if (!output->swayc) { json_object_array_add(outputs, ipc_json_describe_disabled_output(output)); diff --git a/sway/tree/layout.c b/sway/tree/layout.c index ce53a515..b54dc2fe 100644 --- a/sway/tree/layout.c +++ b/sway/tree/layout.c @@ -35,7 +35,7 @@ void layout_init(void) { root_container.sway_root = calloc(1, sizeof(*root_container.sway_root)); root_container.sway_root->output_layout = wlr_output_layout_create(); - root_container.sway_root->outputs = create_list(); + wl_list_init(&root_container.sway_root->outputs); wl_list_init(&root_container.sway_root->xwayland_unmanaged); wl_signal_init(&root_container.sway_root->events.new_container); -- cgit v1.2.3-54-g00ecf