From 7cdcf1941567f387a4408a61c949d57906685dcb Mon Sep 17 00:00:00 2001 From: JorySeverijnse Date: Fri, 6 Mar 2026 22:08:38 +0100 Subject: [PATCH] Add diagnostic logging to troubleshoot screenshot display issue --- src/lock.rs | 11 ++++++----- src/main.rs | 43 ++++++++++++++++++++++--------------------- src/render.rs | 14 ++++++++++---- 3 files changed, 38 insertions(+), 30 deletions(-) diff --git a/src/lock.rs b/src/lock.rs index 728f759..b432675 100644 --- a/src/lock.rs +++ b/src/lock.rs @@ -124,14 +124,15 @@ impl LockedSurface { // Set background if available if let Some(ref background) = self.background { - log::debug!( - "Applying background from self.background (size: {}x{})", - background.width(), - background.height() + let size = (background.width(), background.height()); + log::info!( + "✓ Applying background from self.background: {}x{}", + size.0, + size.1 ); self.renderer.set_background(background.clone()); } else { - log::debug!("No background in self.background"); + log::warn!("✗ No background in self.background - will render solid color!"); } self.renderer diff --git a/src/main.rs b/src/main.rs index 30f8c3a..cd272b4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -865,43 +865,44 @@ fn lock_wayland_session( match state.screenshot_manager.as_ref().unwrap().buffer_to_surface(handle, &mut state.pool) { Ok(surface) => { + log::info!("✓ Converted screenshot for output {}: {}x{}", output_idx, surface.width(), surface.height()); // Apply effects if configured let mut screenshot = Screenshot::new(surface); if let Err(e) = screenshot.apply_effects(&state.config) { log::error!("Failed to apply effects: {}", e); } let surface = screenshot.into_inner(); + log::info!("✓ Screenshot ready for output {}", output_idx); // Save screenshot to file for debugging if debug mode enabled if state.config.debug { let path = format!("/tmp/wayrustlock_output{}.png", output_idx); - match std::fs::File::create(&path) { - Ok(mut file) => { - if let Err(e) = surface.write_to_png(&mut file) { - log::error!("Failed to write PNG to {}: {}", path, e); - } else { - log::info!("Saved screenshot to {}", path); - } - } - Err(e) => { - log::error!("Failed to create file {}: {}", path, e); - } + match std::fs::File::create(&path) { + Ok(mut file) => { + if let Err(e) = surface.write_to_png(&mut file) { + log::error!("Failed to write PNG to {}: {}", path, e); + } else { + log::info!("✓ Saved screenshot to {}", path); } + } + Err(e) => { + log::error!("Failed to create file {}: {}", path, e); + } + } } if output_idx < state.outputs.len() { let output = &state.outputs[output_idx]; if let Ok(mut lock_manager) = state.lock_manager.lock() { - if let Some(locked_surface) = lock_manager.find_surface_by_output(output) { - log::debug!("Setting background directly on lock surface for output {}", output_idx); - locked_surface.set_background(surface); - log::debug!("Background set on surface"); - } else { - log::debug!("Storing background in captured_backgrounds for output {}", output_idx); - state.captured_backgrounds[output_idx] = Some(surface); - } + if let Some(locked_surface) = lock_manager.find_surface_by_output(output) { + log::info!("✓ Setting background on locked surface for output {}", output_idx); + locked_surface.set_background(surface); + } else { + log::warn!("⚠ No locked surface found for output {}, storing in captured_backgrounds", output_idx); + state.captured_backgrounds[output_idx] = Some(surface); + } } else { - log::debug!("Failed to lock manager, storing background"); + log::warn!("⚠ Lock manager poisoned, storing in captured_backgrounds for output {}", output_idx); state.captured_backgrounds[output_idx] = Some(surface); } } else { @@ -909,7 +910,7 @@ fn lock_wayland_session( } } Err(e) => { - log::error!("Failed to convert buffer to surface: {}", e); + log::error!("✗ Failed to convert buffer to surface: {}", e); } } } else { diff --git a/src/render.rs b/src/render.rs index 514703e..4ba5ddc 100644 --- a/src/render.rs +++ b/src/render.rs @@ -92,7 +92,7 @@ impl Renderer { /// Render the current frame pub fn render(&mut self) { - log::debug!( + log::info!( "Renderer::render() called, background: {}", self.background.is_some() ); @@ -103,17 +103,23 @@ impl Renderer { // Draw background if available if let Some(ref background) = self.background { - log::debug!("Drawing background (fade_alpha: {})", self.fade_alpha); + let size = (background.width(), background.height()); + log::info!( + "✓ Drawing background ({}x{}, fade_alpha: {})", + size.0, + size.1, + self.fade_alpha + ); self.context .set_source_surface(background, 0.0, 0.0) .expect("Failed to set background source"); self.context .paint_with_alpha(self.fade_alpha) .expect("Failed to draw background"); - log::debug!("Background drawn"); + log::info!("✓ Background drawn successfully"); } else { // Draw solid color background (dark gray visible color) - log::debug!("No background, drawing solid color"); + log::warn!("✗ No background available - rendering solid gray!"); self.context.set_source_rgba(0.15, 0.15, 0.15, 1.0); self.context .paint()