From f9188a2c8b2cd26c1002521e6d6fcfd49ad8eb60 Mon Sep 17 00:00:00 2001 From: project-repo Date: Fri, 15 Sep 2023 15:38:29 +0200 Subject: [PATCH] Implement switching from permanent and peripheral Destroy the output if it is not attached. --- keybinding.c | 5 +++-- output.c | 15 +++++++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/keybinding.c b/keybinding.c index ee76b9a..61aceeb 100644 --- a/keybinding.c +++ b/keybinding.c @@ -1549,11 +1549,12 @@ keybinding_configure_output(struct cg_server *server, struct cg_output *output, *tmp_output; wl_list_for_each_safe(output, tmp_output, &server->outputs, link) { if(strcmp(config->output_name, output->name) == 0) { + int output_num=output_get_num(output); output_configure(server, output); - ipc_send_event(output->server, + ipc_send_event(server, "{\"event_name\":\"configure_output\",\"output\":\"%" "s\",\"output_id\":%d}", - cfg->output_name, output_get_num(output)); + cfg->output_name, output_num); return; } } diff --git a/output.c b/output.c index 955a4a8..881d9e4 100644 --- a/output.c +++ b/output.c @@ -127,11 +127,13 @@ output_destroy(struct cg_output *output) { char *outp_name = strdup(output->name); int outp_num = output_get_num(output); + if(output->destroyed == false) { + wl_list_remove(&output->destroy.link); + wl_list_remove(&output->mode.link); + wl_list_remove(&output->commit.link); + wl_list_remove(&output->frame.link); + } output->destroyed = true; - wl_list_remove(&output->destroy.link); - wl_list_remove(&output->mode.link); - wl_list_remove(&output->commit.link); - wl_list_remove(&output->frame.link); enum output_role role = output->role; if(role == OUTPUT_ROLE_PERMANENT) { wlr_output_layout_get_box(server->output_layout, output->wlr_output, @@ -279,6 +281,11 @@ output_apply_config(struct cg_server *server, struct cg_output *output, if(config->role != OUTPUT_ROLE_DEFAULT) { output->role = config->role; + if((output->role == OUTPUT_ROLE_PERIPHERAL)&&(output->destroyed == true)) { + output_destroy(output); + wlr_output_destroy(wlr_output); + return; + } } if(output->wlr_output->enabled) {