git.lucas.co / cce-lock
session locker (ext-session-lock + PAM)
git clone https://git.lucas.co/cce-lock.git

commit88f48535dbcaf51a867c085d2c1161e8b0445548
parent45c599934e
authorLucas Galante <lsgalante12@gmail.com>
date2026-09-25 15:54
fix: a lost lock surface leaves the output unpainted instead of panicking

VkRenderer::new panics when the display connection under the surface is
already dead (ERROR_SURFACE_LOST_KHR). Use cce-ui's try_new: on the
error the output just stays unpainted, the next configure tries again,
and a dead connection ends the main loop's dispatch as it always has --
never an unlock, and no new exit path in a locker.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

 src/main.rs | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/main.rs b/src/main.rs
index e411055..2fac31b 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -503,8 +503,15 @@ impl Dispatch<ExtSessionLockSurfaceV1, u32> for AppState {
                     out.wl_surface.set_buffer_scale(out.scale as i32);
                     let conn_ptr = _conn.backend().display_id().as_ptr() as *mut std::ffi::c_void;
                     let surf_ptr = out.wl_surface.id().as_ptr() as *mut std::ffi::c_void;
-                    out.renderer =
-                        Some(unsafe { VkRenderer::new(conn_ptr, surf_ptr, pw, ph, 0.0) });
+                    // A lost surface means the connection is dying under us.
+                    // Never an unlock, and not an exit either: the output just
+                    // stays unpainted (`draw` skips it), the next configure
+                    // tries again, and a dead connection ends the main loop's
+                    // dispatch the way it always has — still locked.
+                    match unsafe { VkRenderer::try_new(conn_ptr, surf_ptr, pw, ph, 0.0) } {
+                        Ok(r) => out.renderer = Some(r),
+                        Err(lost) => log::warn!("output {id}: {lost}; not painting it"),
+                    }
                 }
             }
             state.draw(*id);