Skip to content

Commit

Permalink
Fix apply_output_config return value when enabling output
Browse files Browse the repository at this point in the history
apply_output_config would call output_enable and always return true,
even if the output couldn't be enabled.
  • Loading branch information
emersion authored and ddevault committed Oct 27, 2019
1 parent 43bd8dc commit 58a40ce
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion include/sway/output.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ struct sway_output *all_output_by_name_or_id(const char *name_or_id);

void output_sort_workspaces(struct sway_output *output);

void output_enable(struct sway_output *output, struct output_config *oc);
bool output_enable(struct sway_output *output, struct output_config *oc);

void output_disable(struct sway_output *output);

Expand Down
3 changes: 1 addition & 2 deletions sway/config/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,7 @@ bool apply_output_config(struct output_config *oc, struct sway_output *output) {
if (!oc || oc->dpms_state != DPMS_OFF) {
wlr_output_enable(wlr_output, true);
}
output_enable(output, oc);
return true;
return output_enable(output, oc);
}

if (oc && oc->dpms_state == DPMS_ON) {
Expand Down
10 changes: 6 additions & 4 deletions sway/tree/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ static void restore_workspaces(struct sway_output *output) {
struct sway_workspace *ws = root->noop_output->workspaces->items[0];
workspace_detach(ws);
output_add_workspace(output, ws);

// If the floater was made floating while on the NOOP output, its width
// and height will be zero and it should be reinitialized as a floating
// container to get the appropriate size and location. Additionally, if
Expand Down Expand Up @@ -104,9 +104,9 @@ struct sway_output *output_create(struct wlr_output *wlr_output) {
return output;
}

void output_enable(struct sway_output *output, struct output_config *oc) {
bool output_enable(struct sway_output *output, struct output_config *oc) {
if (!sway_assert(!output->enabled, "output is already enabled")) {
return;
return false;
}
struct wlr_output *wlr_output = output->wlr_output;
size_t len = sizeof(output->layers) / sizeof(output->layers[0]);
Expand All @@ -117,7 +117,7 @@ void output_enable(struct sway_output *output, struct output_config *oc) {
output->enabled = true;
if (!apply_output_config(oc, output)) {
output->enabled = false;
return;
return false;
}

output->configured = true;
Expand Down Expand Up @@ -155,6 +155,8 @@ void output_enable(struct sway_output *output, struct output_config *oc) {

arrange_layers(output);
arrange_root();

return true;
}

static void evacuate_sticky(struct sway_workspace *old_ws,
Expand Down

0 comments on commit 58a40ce

Please sign in to comment.