gardesk/gardm / b16d5b6

Browse files

greeter: clear garbg root pixmap atoms on startup

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
b16d5b644a6943e8d4e4906a884fb665f3457765
Parents
45a4db1
Tree
d74f544

1 changed file

StatusFile+-
M gardm-greeter/src/window.rs 36 2
gardm-greeter/src/window.rsmodified
@@ -53,8 +53,42 @@ impl GreeterWindow {
5353
         let visual = screen.root_visual;
5454
 
5555
         // Clear the root window to black to hide any leftover content from previous session
56
-        // garbg sets the root background using a pixmap, so we must clear that first
57
-        // BackPixmap::NONE (0) removes any background pixmap, then background_pixel takes effect
56
+        // garbg sets the root background using a pixmap AND stores the pixmap ID in
57
+        // _XROOTPMAP_ID and ESETROOT_PMAP_ID atoms. We must clear all of these.
58
+
59
+        // First, clear the root pixmap atoms that garbg sets
60
+        // This prevents compositors from reading stale pixmap references
61
+        let xrootpmap_atom = conn
62
+            .intern_atom(false, b"_XROOTPMAP_ID")?
63
+            .reply()
64
+            .map(|r| r.atom)
65
+            .unwrap_or(x11rb::NONE);
66
+        let esetroot_atom = conn
67
+            .intern_atom(false, b"ESETROOT_PMAP_ID")?
68
+            .reply()
69
+            .map(|r| r.atom)
70
+            .unwrap_or(x11rb::NONE);
71
+
72
+        // Try to free the old pixmap if it exists (to avoid memory leak)
73
+        if xrootpmap_atom != x11rb::NONE {
74
+            if let Ok(reply) = conn.get_property(false, root, xrootpmap_atom, AtomEnum::PIXMAP, 0, 1)?.reply() {
75
+                if reply.format == 32 && !reply.value.is_empty() {
76
+                    let pixmap_id = u32::from_ne_bytes([
77
+                        reply.value[0], reply.value[1], reply.value[2], reply.value[3]
78
+                    ]);
79
+                    if pixmap_id != 0 {
80
+                        let _ = conn.free_pixmap(pixmap_id);
81
+                    }
82
+                }
83
+            }
84
+            // Delete the property
85
+            let _ = conn.delete_property(root, xrootpmap_atom);
86
+        }
87
+        if esetroot_atom != x11rb::NONE {
88
+            let _ = conn.delete_property(root, esetroot_atom);
89
+        }
90
+
91
+        // Now clear the window's background pixmap attribute and set solid color
5892
         conn.change_window_attributes(
5993
             root,
6094
             &ChangeWindowAttributesAux::new()