diff --git a/output.c b/output.c index dd72af3c..736b5808 100644 --- a/output.c +++ b/output.c @@ -108,14 +108,18 @@ static bool output_apply_config(struct cg_output *output, struct wlr_output_configuration_head_v1 *head, bool test_only) { wlr_output_enable(output->wlr_output, head->state.enabled); - wlr_output_set_scale(output->wlr_output, head->state.scale); - wlr_output_set_transform(output->wlr_output, head->state.transform); - if (head->state.mode) { - wlr_output_set_mode(output->wlr_output, head->state.mode); - } else { - wlr_output_set_custom_mode(output->wlr_output, head->state.custom_mode.width, - head->state.custom_mode.height, head->state.custom_mode.refresh); + if (head->state.enabled) { + /* Do not mess with these parameters for output to be disabled */ + wlr_output_set_scale(output->wlr_output, head->state.scale); + wlr_output_set_transform(output->wlr_output, head->state.transform); + + if (head->state.mode) { + wlr_output_set_mode(output->wlr_output, head->state.mode); + } else { + wlr_output_set_custom_mode(output->wlr_output, head->state.custom_mode.width, + head->state.custom_mode.height, head->state.custom_mode.refresh); + } } if (test_only) { @@ -125,7 +129,11 @@ output_apply_config(struct cg_output *output, struct wlr_output_configuration_he } /* Apply output configuration */ - wlr_output_layout_add(output->server->output_layout, head->state.output, head->state.x, head->state.y); + if (head->state.enabled) { + wlr_output_layout_add(output->server->output_layout, head->state.output, head->state.x, head->state.y); + } else { + wlr_output_layout_remove(output->server->output_layout, output->wlr_output); + } if (!wlr_output_commit(output->wlr_output)) { return false; @@ -154,16 +162,11 @@ static void handle_output_commit(struct wl_listener *listener, void *data) { struct cg_output *output = wl_container_of(listener, output, commit); - struct wlr_output_event_commit *event = data; - - if (!output->wlr_output->enabled) { - return; - } - if (event->committed & (WLR_OUTPUT_STATE_TRANSFORM | WLR_OUTPUT_STATE_SCALE)) { - view_position_all(output->server); - update_output_manager_config(output->server); - } + /* Notes: + * - output layout change will be called next if needed to position the views + * - always update output manager configuration even if the output is now disabled */ + update_output_manager_config(output->server); } static void @@ -292,11 +295,7 @@ handle_new_output(struct wl_listener *listener, void *data) } output_enable(output); - - struct cg_view *view; - wl_list_for_each (view, &output->server->views, link) { - view_position(view); - } + view_position_all(output->server); } void