Comments in x11 module
- Better clarity and readability
This commit is contained in:
parent
efbf5dc7f4
commit
4da3fe8358
21
src/x11.rs
21
src/x11.rs
@ -18,11 +18,16 @@ use crate::wallpaper::PreparedWallpaper;
|
|||||||
/// Owns the X11 connection and all data needed to
|
/// Owns the X11 connection and all data needed to
|
||||||
/// safely update the root window background.
|
/// safely update the root window background.
|
||||||
pub struct X11Session {
|
pub struct X11Session {
|
||||||
|
// Connection to the X11 server
|
||||||
conn: RustConnection,
|
conn: RustConnection,
|
||||||
|
// The "root window," i.e., the desktop where you set the background.
|
||||||
pub root: u32,
|
pub root: u32,
|
||||||
|
// Screen color depth
|
||||||
pub depth: u8,
|
pub depth: u8,
|
||||||
|
// Screen dimensions
|
||||||
pub width: u16,
|
pub width: u16,
|
||||||
pub height: u16,
|
pub height: u16,
|
||||||
|
// Atom to track ownership of the current wallpaper pixmap
|
||||||
atom_eset: u32,
|
atom_eset: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,10 +39,8 @@ impl X11Session {
|
|||||||
// Select the current screen.
|
// Select the current screen.
|
||||||
let screen = &conn.setup().roots[screen_num];
|
let screen = &conn.setup().roots[screen_num];
|
||||||
|
|
||||||
// Copy what you need out of `screen` (To avoid dangling reference)
|
// Copy needed fields out of `screen` to avoid dangling reference.
|
||||||
// Find the "root window," i.e., the desktop where you set the background.
|
|
||||||
let root = screen.root;
|
let root = screen.root;
|
||||||
// Get screen dimensions and color depth
|
|
||||||
let depth = screen.root_depth;
|
let depth = screen.root_depth;
|
||||||
let width = screen.width_in_pixels;
|
let width = screen.width_in_pixels;
|
||||||
let height = screen.height_in_pixels;
|
let height = screen.height_in_pixels;
|
||||||
@ -155,18 +158,18 @@ impl X11Session {
|
|||||||
.atom;
|
.atom;
|
||||||
let atom_setroot = self.conn.intern_atom(false, b"_XSETROOT_ID")?.reply()?.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 [
|
for atom in [
|
||||||
atom_root, // _XROOTPMAP_ID: For discovery.
|
atom_root, // _XROOTPMAP_ID: For discovery.
|
||||||
self.atom_eset, // ESETROOT_PMAP_ID: For discovery and ownership / lifecycle.
|
self.atom_eset, // ESETROOT_PMAP_ID: For discovery and ownership / lifecycle.
|
||||||
atom_setroot, // _XSETROOT_ID: For discovery, but legacy.
|
atom_setroot, // _XSETROOT_ID: For discovery, but legacy.
|
||||||
] {
|
] {
|
||||||
self.conn.change_property32(
|
self.conn.change_property32(
|
||||||
PropMode::REPLACE,
|
PropMode::REPLACE, // Property setting mode: Replace
|
||||||
self.root,
|
self.root, // Window: Root window
|
||||||
atom,
|
atom, // Property to set: Atom
|
||||||
AtomEnum::PIXMAP,
|
AtomEnum::PIXMAP, // Property type: Pixmap ID
|
||||||
&[pixmap],
|
&[pixmap], // Data/value: the wallpaper pixmap
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user