Skip to content

Commit

Permalink
fixup: Start fixing output which can't be disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
joggee-fr authored and Jonathan GUILLOT committed Jul 24, 2023
1 parent 66db610 commit d091a94
Showing 1 changed file with 21 additions and 22 deletions.
43 changes: 21 additions & 22 deletions output.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d091a94

Please sign in to comment.