From 4e276dc7eedca133ba586a368a6e36da0be7138a Mon Sep 17 00:00:00 2001 From: Candifloss Date: Sat, 20 Dec 2025 15:41:11 +0530 Subject: [PATCH] Fix clippy warnings in `x11.rs` --- src/x11.rs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/x11.rs b/src/x11.rs index c49584f..1792e62 100644 --- a/src/x11.rs +++ b/src/x11.rs @@ -94,6 +94,15 @@ impl X11Session { self.conn .create_pixmap(self.depth, pixmap, self.root, self.width, self.height)?; + let width = u16::try_from(prepared.width) + .map_err(|_| anyhow::anyhow!("Image width exceeds X11 limits"))?; + let height = u16::try_from(prepared.height) + .map_err(|_| anyhow::anyhow!("Image height exceeds X11 limits"))?; + let offset_x = i16::try_from(prepared.offset_x) + .map_err(|_| anyhow::anyhow!("X offset exceeds X11 limits"))?; + let offset_y = i16::try_from(prepared.offset_y) + .map_err(|_| anyhow::anyhow!("Y offset exceeds X11 limits"))?; + // Create a Graphics Context (GC). // A GC is required by X11 for image uploads, even though most of its // drawing settings are unused when using put_image. @@ -107,11 +116,11 @@ impl X11Session { ImageFormat::Z_PIXMAP, pixmap, // drawable: Destination pixmap (wallpaper image) gc, // Graphics Context (required by X11) - prepared.width as u16, - prepared.height as u16, // width/height: size of the uploaded image region in pixels - prepared.offset_x as i16, - prepared.offset_y as i16, // dst_x/dst_y: Destination offset inside the pixmap (top-left corner) - 0, // left_pad: legacy bitmap padding, always 0 for modern images + width, + height, // width/height: size of the uploaded image region in pixels + offset_x, + offset_y, // dst_x/dst_y: Destination offset inside the pixmap (top-left corner) + 0, // left_pad: legacy bitmap padding, always 0 for modern images self.depth, // depth: must match the root window's depth (usually 24 or 32) &prepared.pixels, // data: raw BGRA/BGRX pixel buffer )?;