From 550518c5d122c49c8fcedb31c16eeb2d723e67ee Mon Sep 17 00:00:00 2001 From: Maxim Solovyov Date: Sun, 18 Jun 2023 15:45:06 +0300 Subject: [PATCH] x: rewrite x_get_root_back_pixmap using root back pixmap atoms and remove the now unused background_props_str constant --- src/x.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/x.c b/src/x.c index 8c4cabe..c902e00 100644 --- a/src/x.c +++ b/src/x.c @@ -628,22 +628,15 @@ bool x_validate_pixmap(xcb_connection_t *c, xcb_pixmap_t pixmap) { free(r); return ret; } -/// Names of root window properties that could point to a pixmap of -/// background. -static const char *background_props_str[] = { - "_XROOTPMAP_ID", - "_XSETROOT_ID", - 0, -}; xcb_pixmap_t x_get_root_back_pixmap(xcb_connection_t *c, xcb_window_t root, struct atom *atoms) { xcb_pixmap_t pixmap = XCB_NONE; - // Get the values of background attributes - for (int p = 0; background_props_str[p]; p++) { - xcb_atom_t prop_atom = get_atom(atoms, background_props_str[p]); - winprop_t prop = x_get_prop(c, root, prop_atom, 1, XCB_ATOM_PIXMAP, 32); + xcb_atom_t root_back_pixmap_atoms[] = {atoms->a_XROOTPMAP_ID, atoms->aESETROOT_PMAP_ID}; + for (size_t i = 0; i < ARR_SIZE(root_back_pixmap_atoms); i++) { + winprop_t prop = + x_get_prop(c, root, root_back_pixmap_atoms[i], 1, XCB_ATOM_PIXMAP, 32); if (prop.nitems) { pixmap = (xcb_pixmap_t)*prop.p32; free_winprop(&prop);