Free output on removal, log add/remove

master
Kenny Levinsen 2020-10-04 00:56:17 +02:00
parent 5761b05c1b
commit daf27a5f11
1 changed files with 4 additions and 1 deletions

5
main.c
View File

@ -172,6 +172,7 @@ static void registry_handle_global(void *data, struct wl_registry *registry,
(void)version; (void)version;
struct context *ctx = (struct context *)data; struct context *ctx = (struct context *)data;
if (strcmp(interface, wl_output_interface.name) == 0) { if (strcmp(interface, wl_output_interface.name) == 0) {
fprintf(stderr, "adding output %d\n", name);
struct output *output = calloc(1, sizeof(struct output)); struct output *output = calloc(1, sizeof(struct output));
output->id = name; output->id = name;
output->wl_output = wl_registry_bind(registry, name, output->wl_output = wl_registry_bind(registry, name,
@ -194,13 +195,15 @@ static void registry_handle_global_remove(void *data,
struct output *output, *tmp; struct output *output, *tmp;
wl_list_for_each_safe(output, tmp, &ctx->outputs, link) { wl_list_for_each_safe(output, tmp, &ctx->outputs, link) {
if (output->id == name) { if (output->id == name) {
fprintf(stderr, "removing output %d\n", name);
wl_list_remove(&output->link);
if (output->gamma_control != NULL) { if (output->gamma_control != NULL) {
zwlr_gamma_control_v1_destroy(output->gamma_control); zwlr_gamma_control_v1_destroy(output->gamma_control);
} }
if (output->table_fd != -1) { if (output->table_fd != -1) {
close(output->table_fd); close(output->table_fd);
} }
wl_list_remove(&output->link); free(output);
break; break;
} }
} }