From 6b6a8da03510ad38d7f7c89092b90f681c673de4 Mon Sep 17 00:00:00 2001 From: Maxim Solovyov Date: Sun, 18 Jun 2023 14:55:22 +0300 Subject: [PATCH 1/5] render: remove the unused background_props_str external constant --- src/render.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/render.c b/src/render.c index 80cb59a6..f4b3a979 100644 --- a/src/render.c +++ b/src/render.c @@ -583,8 +583,6 @@ void paint_one(session_t *ps, struct managed_win *w, const region_t *reg_paint) } } -extern const char *background_props_str[]; - static bool get_root_tile(session_t *ps) { /* if (ps->o.paint_on_overlay) { From fea1dc794c19131f7f4eae2f4a0345516c615781 Mon Sep 17 00:00:00 2001 From: Maxim Solovyov Date: Sun, 18 Jun 2023 14:57:50 +0300 Subject: [PATCH 2/5] atom: add atoms associated with the background pixmap --- src/atom.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/atom.h b/src/atom.h index 6f4eae69..5ea7701c 100644 --- a/src/atom.h +++ b/src/atom.h @@ -3,8 +3,8 @@ #include -#include "meta.h" #include "cache.h" +#include "meta.h" // clang-format off // Splitted into 2 lists because of the limitation of our macros @@ -23,7 +23,10 @@ WM_CLIENT_MACHINE, \ _NET_ACTIVE_WINDOW, \ _COMPTON_SHADOW, \ - _NET_WM_WINDOW_TYPE + _NET_WM_WINDOW_TYPE, \ + _XROOTPMAP_ID, \ + ESETROOT_PMAP_ID, \ + _XSETROOT_ID #define ATOM_LIST2 \ _NET_WM_WINDOW_TYPE_DESKTOP, \ From cbd2d4125c907c937d76afefce16e845917a2914 Mon Sep 17 00:00:00 2001 From: Maxim Solovyov Date: Sun, 18 Jun 2023 15:32:15 +0300 Subject: [PATCH 3/5] x: rewrite x_is_root_back_pixmap_atom using root back pixmap atoms --- src/x.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/x.c b/src/x.c index 6121e773..8c4cabe6 100644 --- a/src/x.c +++ b/src/x.c @@ -656,13 +656,8 @@ x_get_root_back_pixmap(xcb_connection_t *c, xcb_window_t root, struct atom *atom } bool x_is_root_back_pixmap_atom(struct atom *atoms, xcb_atom_t atom) { - for (int p = 0; background_props_str[p]; p++) { - xcb_atom_t prop_atom = get_atom(atoms, background_props_str[p]); - if (prop_atom == atom) { - return true; - } - } - return false; + return atom == atoms->a_XROOTPMAP_ID || atom == atoms->aESETROOT_PMAP_ID || + atom == atoms->a_XSETROOT_ID; } /** From 550518c5d122c49c8fcedb31c16eeb2d723e67ee Mon Sep 17 00:00:00 2001 From: Maxim Solovyov Date: Sun, 18 Jun 2023 15:45:06 +0300 Subject: [PATCH 4/5] 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 8c4cabe6..c902e001 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); From a377d12a66132871f31f88c713662f27634e188e Mon Sep 17 00:00:00 2001 From: Maxim Solovyov Date: Sun, 18 Jun 2023 16:09:29 +0300 Subject: [PATCH 5/5] x: add a comment on the _XSETROOT_ID root window property usage --- src/x.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/x.c b/src/x.c index c902e001..a2a7153d 100644 --- a/src/x.c +++ b/src/x.c @@ -629,6 +629,18 @@ bool x_validate_pixmap(xcb_connection_t *c, xcb_pixmap_t pixmap) { return ret; } +/// We don't use the _XSETROOT_ID root window property as a source of the background +/// pixmap because it most likely points to a dummy pixmap used to keep the colormap +/// associated with the background pixmap alive but we listen for it's changes and update +/// the background pixmap accordingly. +/// +/// For details on the _XSETROOT_ID root window property and it's usage see: +/// https://metacpan.org/pod/X11::Protocol::XSetRoot#_XSETROOT_ID +/// https://gitlab.freedesktop.org/xorg/app/xsetroot/-/blob/435d35409768de7cbc2c47a6322192dd4b480545/xsetroot.c#L318-352 +/// https://github.com/ImageMagick/ImageMagick/blob/d04a47227637dbb3af9231b0107ccf9677bf985e/MagickCore/xwindow.c#L9203-L9260 +/// https://github.com/ImageMagick/ImageMagick/blob/d04a47227637dbb3af9231b0107ccf9677bf985e/MagickCore/xwindow.c#L1853-L1922 +/// https://www.fvwm.org/Archive/Manpages/fvwm-root.html + 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;