mirror of
				https://github.com/swaywm/sway.git
				synced 2025-11-03 09:01:43 -05:00 
			
		
		
		
	Switch output storing from list_t to wl_list
This commit is contained in:
		
							parent
							
								
									a0bbe67076
								
							
						
					
					
						commit
						e072fbc6d9
					
				
					 6 changed files with 12 additions and 19 deletions
				
			
		| 
						 | 
					@ -29,6 +29,8 @@ struct sway_output {
 | 
				
			||||||
	struct wl_listener damage_destroy;
 | 
						struct wl_listener damage_destroy;
 | 
				
			||||||
	struct wl_listener damage_frame;
 | 
						struct wl_listener damage_frame;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						struct wl_list link;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pid_t bg_pid;
 | 
						pid_t bg_pid;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -31,7 +31,7 @@ struct sway_root {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct wlr_texture *debug_tree;
 | 
						struct wlr_texture *debug_tree;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	list_t *outputs;
 | 
						struct wl_list outputs; // sway_output::link
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct {
 | 
						struct {
 | 
				
			||||||
		struct wl_signal new_container;
 | 
							struct wl_signal new_container;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -82,9 +82,8 @@ struct cmd_results *cmd_output(int argc, char **argv) {
 | 
				
			||||||
	// will be applied during normal "new output" event from wlroots.
 | 
						// will be applied during normal "new output" event from wlroots.
 | 
				
			||||||
	char identifier[128];
 | 
						char identifier[128];
 | 
				
			||||||
	bool all = strcmp(output->name, "*") == 0;
 | 
						bool all = strcmp(output->name, "*") == 0;
 | 
				
			||||||
	list_t *sway_outputs = root_container.sway_root->outputs;
 | 
						struct sway_output *sway_output;
 | 
				
			||||||
	for (int i = 0; i < sway_outputs->length; ++i) {
 | 
						wl_list_for_each(sway_output, &root_container.sway_root->outputs, link) {
 | 
				
			||||||
		struct sway_output *sway_output = sway_outputs->items[i];
 | 
					 | 
				
			||||||
		output_get_identifier(identifier, sizeof(identifier), sway_output);
 | 
							output_get_identifier(identifier, sizeof(identifier), sway_output);
 | 
				
			||||||
		wlr_log(L_DEBUG, "Checking identifier %s", identifier);
 | 
							wlr_log(L_DEBUG, "Checking identifier %s", identifier);
 | 
				
			||||||
		if (all || strcmp(sway_output->wlr_output->name, output->name) == 0
 | 
							if (all || strcmp(sway_output->wlr_output->name, output->name) == 0
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1157,10 +1157,6 @@ void output_damage_whole_container(struct sway_output *output,
 | 
				
			||||||
	wlr_output_damage_add_box(output->damage, &box);
 | 
						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) {
 | 
					static void damage_handle_destroy(struct wl_listener *listener, void *data) {
 | 
				
			||||||
	struct sway_output *output =
 | 
						struct sway_output *output =
 | 
				
			||||||
		wl_container_of(listener, output, damage_destroy);
 | 
							wl_container_of(listener, output, damage_destroy);
 | 
				
			||||||
| 
						 | 
					@ -1172,12 +1168,9 @@ static void handle_destroy(struct wl_listener *listener, void *data) {
 | 
				
			||||||
	if (output->swayc) {
 | 
						if (output->swayc) {
 | 
				
			||||||
		container_destroy(output->swayc);
 | 
							container_destroy(output->swayc);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	int index = list_seq_find(root_container.sway_root->outputs, find_output,
 | 
					
 | 
				
			||||||
			output);
 | 
						if (&output->link) {
 | 
				
			||||||
	if (index >= 0 && index < root_container.sway_root->outputs->length) {
 | 
							wl_list_remove(&output->link);
 | 
				
			||||||
		wlr_log(L_DEBUG, "Removing %s from outputs list",
 | 
					 | 
				
			||||||
				output->wlr_output->name);
 | 
					 | 
				
			||||||
		list_del(root_container.sway_root->outputs, index);
 | 
					 | 
				
			||||||
		wl_list_remove(&output->destroy.link);
 | 
							wl_list_remove(&output->destroy.link);
 | 
				
			||||||
		output->wlr_output = NULL;
 | 
							output->wlr_output = NULL;
 | 
				
			||||||
		free(output);
 | 
							free(output);
 | 
				
			||||||
| 
						 | 
					@ -1219,7 +1212,7 @@ void handle_new_output(struct wl_listener *listener, void *data) {
 | 
				
			||||||
	output->wlr_output = wlr_output;
 | 
						output->wlr_output = wlr_output;
 | 
				
			||||||
	wlr_output->data = output;
 | 
						wlr_output->data = output;
 | 
				
			||||||
	output->server = server;
 | 
						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);
 | 
						output->damage = wlr_output_damage_create(wlr_output);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -489,9 +489,8 @@ void ipc_client_handle_command(struct ipc_client *client) {
 | 
				
			||||||
					ipc_json_describe_container(container));
 | 
										ipc_json_describe_container(container));
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		for (int i = 0; i < root_container.sway_root->outputs->length; ++i) {
 | 
							struct sway_output *output;
 | 
				
			||||||
			struct sway_output *output =
 | 
							wl_list_for_each(output, &root_container.sway_root->outputs, link) {
 | 
				
			||||||
				root_container.sway_root->outputs->items[i];
 | 
					 | 
				
			||||||
			if (!output->swayc) {
 | 
								if (!output->swayc) {
 | 
				
			||||||
				json_object_array_add(outputs,
 | 
									json_object_array_add(outputs,
 | 
				
			||||||
						ipc_json_describe_disabled_output(output));
 | 
											ipc_json_describe_disabled_output(output));
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -35,7 +35,7 @@ void layout_init(void) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	root_container.sway_root = calloc(1, sizeof(*root_container.sway_root));
 | 
						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->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_list_init(&root_container.sway_root->xwayland_unmanaged);
 | 
				
			||||||
	wl_signal_init(&root_container.sway_root->events.new_container);
 | 
						wl_signal_init(&root_container.sway_root->events.new_container);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue