forge
Explore
Log in

Don't you dare go Hollow

Fix locking with DPMS-inactive monitors

Browse files at this commit

82fffdea80170571eb5ad176cf0b23eb24b0bc5dIvan MolodetskikhParent: 5b3bfd9
This both enables locking while monitors are powered off (they have no
buffer attached at that point on a TTY, so no sensitive content can
become visible), and fixes the condition below to check even if the
rendering was skipped.
src/niri.rsmodified+12 -12
@@ -2080,8 +2080,12 @@ impl Niri {
2080 } else {2080 } else {
2081 RedrawState::Idle2081 RedrawState::Idle
2082 };2082 };
2083- } else {2083+ }
2084- // Update the lock render state on successful render.2084+
2085+ // Update the lock render state on successful render, or if monitors are inactive. When
2086+ // monitors are inactive on a TTY, they have no framebuffer attached, so no sensitive data
2087+ // from a last render will be visible.
2088+ if res != RenderResult::Skipped || !self.monitors_active {
2085 state.lock_render_state = if is_locked {2089 state.lock_render_state = if is_locked {
2086 LockRenderState::Locked2090 LockRenderState::Locked
2087 } else {2091 } else {
@@ -2092,27 +2096,23 @@ impl Niri {
2092 // If we're in process of locking the session, check if the requirements were met.2096 // If we're in process of locking the session, check if the requirements were met.
2093 match mem::take(&mut self.lock_state) {2097 match mem::take(&mut self.lock_state) {
2094 LockState::Locking(confirmation) => {2098 LockState::Locking(confirmation) => {
2095- if res == RenderResult::Skipped {2099+ if state.lock_render_state == LockRenderState::Unlocked {
2096- if state.lock_render_state == LockRenderState::Unlocked {2100+ // We needed to render a locked frame on this output but failed.
2097- // We needed to render a locked frame on this output but failed.2101+ self.unlock();
2098- self.unlock();
2099- } else {
2100- // Rendering failed but this output is already locked, so it's fine.
2101- self.lock_state = LockState::Locking(confirmation);
2102- }
2103 } else {2102 } else {
2104- // Rendering succeeded, check if this was the last output.2103+ // Check if all outputs are now locked.
2105 let all_locked = self2104 let all_locked = self
2106 .output_state2105 .output_state
2107 .values()2106 .values()
2108 .all(|state| state.lock_render_state == LockRenderState::Locked);2107 .all(|state| state.lock_render_state == LockRenderState::Locked);
2109 2108
2110 if all_locked {2109 if all_locked {
2110+ // All outputs are locked, report success.
2111 let lock = confirmation.ext_session_lock().clone();2111 let lock = confirmation.ext_session_lock().clone();
2112 confirmation.lock();2112 confirmation.lock();
2113 self.lock_state = LockState::Locked(lock);2113 self.lock_state = LockState::Locked(lock);
2114 } else {2114 } else {
2115- // Still waiting.2115+ // Still waiting for other outputs.
2116 self.lock_state = LockState::Locking(confirmation);2116 self.lock_state = LockState::Locking(confirmation);
2117 }2117 }
2118 }2118 }