Output: fix possible assertion failure on enable

Currently if we disable an output due to a wlr-output-power-management
protocol request we do not update Output.lock_render_state properly.

This is fine if the output is also re-enabled using the
wlr-output-power-management protocol but causes an assertion failure
if it is re-enabled using wlr-output-management instead.
This commit is contained in:
Isaac Freund
2024-04-08 13:34:47 +02:00
parent 3594fe501e
commit b0e54c6396
2 changed files with 42 additions and 16 deletions

View File

@ -432,7 +432,7 @@ fn handleRequestState(listener: *wl.Listener(*wlr.Output.event.RequestState), ev
pub fn applyState(output: *Output, state: *wlr.Output.State) error{CommitFailed}!void {
// We need to be precise about this state change to make assertions
// in handleEnableDisable() possible.
// in updateLockRenderStateOnEnableDisable() possible.
const enable_state_change = state.committed.enabled and
(state.enabled != output.wlr_output.enabled);
@ -452,6 +452,18 @@ pub fn applyState(output: *Output, state: *wlr.Output.State) error{CommitFailed}
}
fn handleEnableDisable(output: *Output) void {
output.updateLockRenderStateOnEnableDisable();
if (output.wlr_output.enabled) {
// Add the output to root.active_outputs and the output layout if it has not
// already been added.
server.root.activateOutput(output);
} else {
server.root.deactivateOutput(output);
}
}
pub fn updateLockRenderStateOnEnableDisable(output: *Output) void {
// We can't assert the current state of normal_content/locked_content
// here as this output may be newly created.
if (output.wlr_output.enabled) {
@ -467,16 +479,11 @@ fn handleEnableDisable(output: *Output) void {
output.locked_content.node.setEnabled(true);
},
}
// Add the output to root.active_outputs and the output layout if it has not
// already been added.
server.root.activateOutput(output);
} else {
// Disabling and re-enabling an output always blanks it.
output.lock_render_state = .blanked;
output.normal_content.node.setEnabled(false);
output.locked_content.node.setEnabled(true);
server.root.deactivateOutput(output);
}
}