From 82fffdea80170571eb5ad176cf0b23eb24b0bc5d Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Wed, 21 Feb 2024 07:40:50 +0400 Subject: Fix locking with DPMS-inactive monitors 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.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/niri.rs b/src/niri.rs index d88893a9..ec9444b9 100644 --- a/src/niri.rs +++ b/src/niri.rs @@ -2080,8 +2080,12 @@ impl Niri { } else { RedrawState::Idle }; - } else { - // Update the lock render state on successful render. + } + + // Update the lock render state on successful render, or if monitors are inactive. When + // monitors are inactive on a TTY, they have no framebuffer attached, so no sensitive data + // from a last render will be visible. + if res != RenderResult::Skipped || !self.monitors_active { state.lock_render_state = if is_locked { LockRenderState::Locked } else { @@ -2092,27 +2096,23 @@ impl Niri { // If we're in process of locking the session, check if the requirements were met. match mem::take(&mut self.lock_state) { LockState::Locking(confirmation) => { - if res == RenderResult::Skipped { - if state.lock_render_state == LockRenderState::Unlocked { - // We needed to render a locked frame on this output but failed. - self.unlock(); - } else { - // Rendering failed but this output is already locked, so it's fine. - self.lock_state = LockState::Locking(confirmation); - } + if state.lock_render_state == LockRenderState::Unlocked { + // We needed to render a locked frame on this output but failed. + self.unlock(); } else { - // Rendering succeeded, check if this was the last output. + // Check if all outputs are now locked. let all_locked = self .output_state .values() .all(|state| state.lock_render_state == LockRenderState::Locked); if all_locked { + // All outputs are locked, report success. let lock = confirmation.ext_session_lock().clone(); confirmation.lock(); self.lock_state = LockState::Locked(lock); } else { - // Still waiting. + // Still waiting for other outputs. self.lock_state = LockState::Locking(confirmation); } } -- cgit