mirror of
https://github.com/swaywm/sway.git
synced 2026-04-26 06:46:26 -04:00
config/output: reconfigure on commit failure
If the wlr_output_commit fails and the output was previously enabled, we re-enable the output. If the output was previously enabled, then it was also configured. Without reenabling or reconfiguring the output, the output is left in an invalid state. This adds the missing reconfiguring step. This also adds safe guards in output_disable to prevent removing an output index that is not in the list.
This commit is contained in:
parent
1d149230ea
commit
23cbd72571
2 changed files with 38 additions and 17 deletions
|
|
@ -397,14 +397,22 @@ bool apply_output_config(struct output_config *oc, struct sway_output *output) {
|
||||||
|
|
||||||
struct wlr_output *wlr_output = output->wlr_output;
|
struct wlr_output *wlr_output = output->wlr_output;
|
||||||
|
|
||||||
|
// Store some information so we can restore in case the commit fails.
|
||||||
bool was_enabled = output->enabled;
|
bool was_enabled = output->enabled;
|
||||||
|
bool was_configured = output->configured;
|
||||||
|
double old_x = 0, old_y = 0;
|
||||||
|
|
||||||
if (oc && !oc->enabled) {
|
if (oc && !oc->enabled) {
|
||||||
// Output is configured to be disabled
|
// Output is configured to be disabled
|
||||||
sway_log(SWAY_DEBUG, "Disabling output %s", oc->name);
|
sway_log(SWAY_DEBUG, "Disabling output %s", oc->name);
|
||||||
if (output->enabled) {
|
if (output->enabled) {
|
||||||
output_disable(output);
|
output_disable(output);
|
||||||
|
if (was_configured) {
|
||||||
|
wlr_output_layout_output_coords(
|
||||||
|
root->output_layout, wlr_output, &old_x, &old_y);
|
||||||
wlr_output_layout_remove(root->output_layout, wlr_output);
|
wlr_output_layout_remove(root->output_layout, wlr_output);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
output->enabled = true;
|
output->enabled = true;
|
||||||
}
|
}
|
||||||
|
|
@ -417,11 +425,16 @@ bool apply_output_config(struct output_config *oc, struct sway_output *output) {
|
||||||
|
|
||||||
sway_log(SWAY_DEBUG, "Committing output %s", wlr_output->name);
|
sway_log(SWAY_DEBUG, "Committing output %s", wlr_output->name);
|
||||||
if (!wlr_output_commit(wlr_output)) {
|
if (!wlr_output_commit(wlr_output)) {
|
||||||
// Failed to commit output changes, maybe the output is missing a CRTC.
|
// Failed to commit output changes. Restore the output. If this was an
|
||||||
// Leave the output disabled for now and try again when the output gets
|
// attempt to enable and was caused by a lack of a CRTC, it will be
|
||||||
// the mode we asked for.
|
// retried when the output mode we asked for gets set.
|
||||||
sway_log(SWAY_ERROR, "Failed to commit output %s", wlr_output->name);
|
sway_log(SWAY_ERROR, "Failed to commit output %s. Restoring output.",
|
||||||
|
wlr_output->name);
|
||||||
output->enabled = was_enabled;
|
output->enabled = was_enabled;
|
||||||
|
if (was_configured) {
|
||||||
|
wlr_output_layout_add(root->output_layout, wlr_output, old_x, old_y);
|
||||||
|
output_configure(output);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -254,16 +254,20 @@ void output_disable(struct sway_output *output) {
|
||||||
sway_log(SWAY_DEBUG, "Disabling output '%s'", output->wlr_output->name);
|
sway_log(SWAY_DEBUG, "Disabling output '%s'", output->wlr_output->name);
|
||||||
wl_signal_emit(&output->events.destroy, output);
|
wl_signal_emit(&output->events.destroy, output);
|
||||||
|
|
||||||
|
if (output->configured) {
|
||||||
output_evacuate(output);
|
output_evacuate(output);
|
||||||
|
|
||||||
root_for_each_container(untrack_output, output);
|
root_for_each_container(untrack_output, output);
|
||||||
|
|
||||||
int index = list_find(root->outputs, output);
|
int index = list_find(root->outputs, output);
|
||||||
|
if (index >= 0) {
|
||||||
list_del(root->outputs, index);
|
list_del(root->outputs, index);
|
||||||
|
} else {
|
||||||
|
sway_log(SWAY_ERROR, "Output %s was configured, but unlisted",
|
||||||
|
output->wlr_output->name);
|
||||||
|
}
|
||||||
|
|
||||||
output->enabled = false;
|
|
||||||
output->configured = false;
|
output->configured = false;
|
||||||
output->current_mode = NULL;
|
|
||||||
|
|
||||||
arrange_root();
|
arrange_root();
|
||||||
|
|
||||||
|
|
@ -271,6 +275,10 @@ void output_disable(struct sway_output *output) {
|
||||||
// an output that goes offline should stop sending events as long as the
|
// an output that goes offline should stop sending events as long as the
|
||||||
// output remains offline.
|
// output remains offline.
|
||||||
input_manager_configure_all_inputs();
|
input_manager_configure_all_inputs();
|
||||||
|
}
|
||||||
|
|
||||||
|
output->enabled = false;
|
||||||
|
output->current_mode = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void output_begin_destroy(struct sway_output *output) {
|
void output_begin_destroy(struct sway_output *output) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue