Implement switching from permanent and peripheral

Destroy the output if it is not attached.
This commit is contained in:
project-repo 2023-09-15 15:38:29 +02:00
commit f9188a2c8b
2 changed files with 14 additions and 6 deletions

View file

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

View file

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