Switch output storing from list_t to wl_list

This commit is contained in:
Brian Ashworth 2018-06-06 20:10:42 -04:00
parent a0bbe67076
commit e072fbc6d9
6 changed files with 12 additions and 19 deletions

View file

@ -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;
};

View file

@ -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;

View file

@ -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

View file

@ -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);

View file

@ -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));

View file

@ -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);