Comments in x11 module

- Better clarity and readability
This commit is contained in:
Candifloss 2025-12-19 10:51:24 +05:30
parent efbf5dc7f4
commit 4da3fe8358

View File

@ -18,11 +18,16 @@ use crate::wallpaper::PreparedWallpaper;
/// Owns the X11 connection and all data needed to
/// safely update the root window background.
pub struct X11Session {
// Connection to the X11 server
conn: RustConnection,
// The "root window," i.e., the desktop where you set the background.
pub root: u32,
// Screen color depth
pub depth: u8,
// Screen dimensions
pub width: u16,
pub height: u16,
// Atom to track ownership of the current wallpaper pixmap
atom_eset: u32,
}
@ -34,10 +39,8 @@ impl X11Session {
// Select the current screen.
let screen = &conn.setup().roots[screen_num];
// Copy what you need out of `screen` (To avoid dangling reference)
// Find the "root window," i.e., the desktop where you set the background.
// Copy needed fields out of `screen` to avoid dangling reference.
let root = screen.root;
// Get screen dimensions and color depth
let depth = screen.root_depth;
let width = screen.width_in_pixels;
let height = screen.height_in_pixels;
@ -155,18 +158,18 @@ impl X11Session {
.atom;
let atom_setroot = self.conn.intern_atom(false, b"_XSETROOT_ID")?.reply()?.atom;
// Set root window properties that publish the wallpaper pixmap location to other clients.
// Set root window properties that publish the wallpaper pixmap location to help other clients discover, reuse, or track the current background.
for atom in [
atom_root, // _XROOTPMAP_ID: For discovery.
self.atom_eset, // ESETROOT_PMAP_ID: For discovery and ownership / lifecycle.
atom_setroot, // _XSETROOT_ID: For discovery, but legacy.
] {
self.conn.change_property32(
PropMode::REPLACE,
self.root,
atom,
AtomEnum::PIXMAP,
&[pixmap],
PropMode::REPLACE, // Property setting mode: Replace
self.root, // Window: Root window
atom, // Property to set: Atom
AtomEnum::PIXMAP, // Property type: Pixmap ID
&[pixmap], // Data/value: the wallpaper pixmap
)?;
}