fn try_rebuild_channel(
conn: &mut RustConnection,
root: &mut u32,
rsettings: &CaptureSettings,
cap_x: &mut i16,
cap_y: &mut i16,
cap_w: &mut u16,
cap_h: &mut u16,
root_w: &mut u16,
root_h: &mut u16,
pool_n: usize,
pool: &FramePool,
surfaces: &mut Vec<ShmSurface>,
stop: &AtomicBool,
) -> Result<(), String>Expand description
Rebuild the X channel + capture surfaces after a connection-level failure (Xorg restart, VT switch), refreshing the offset/dims state against the live root. The pool is drained first so the encode thread can never be reading a surface as it is destroyed, and its generation is bumped so the encoder rebuilds against the new layout. Every fallible step completes before the swap, and the old channel/surfaces are destroyed best-effort after it (their server is likely gone; the local detaches still run, and the kernel frees each old segment once nothing maps it).