From 856ad4b230d6a5dc9abc21925eb69336c93a2446 Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Thu, 7 Feb 2019 00:30:32 +0000 Subject: [PATCH] Wrap root window background prop check It might be reused by the backends. Depends on what the backend API ends up look like. Signed-off-by: Yuxuan Shui --- src/compton.c | 16 ++-------------- src/render.c | 16 +--------------- src/x.c | 2 +- src/x.h | 2 +- 4 files changed, 5 insertions(+), 31 deletions(-) diff --git a/src/compton.c b/src/compton.c index b000e16..41333e6 100644 --- a/src/compton.c +++ b/src/compton.c @@ -142,14 +142,6 @@ const char * const BACKEND_STRS[NUM_BKEND + 1] = { NULL }; -/// Names of root window properties that could point to a pixmap of -/// background. -const char *background_props_str[] = { - "_XROOTPMAP_ID", - "_XSETROOT_ID", - 0, -}; - // === Global variables === /// Pointer to current session, as a global variable. Only used by @@ -1647,14 +1639,10 @@ ev_property_notify(session_t *ps, xcb_property_notify_event_t *ev) { if (ps->o.track_focus && ps->o.use_ewmh_active_win && ps->atom_ewmh_active_win == ev->atom) { update_ewmh_active_win(ps); - } - else { + } else { // Destroy the root "image" if the wallpaper probably changed - for (int p = 0; background_props_str[p]; p++) { - if (ev->atom == get_atom(ps, background_props_str[p])) { + if (x_is_root_back_pixmap_atom(ps, ev->atom)) { root_damaged(ps); - break; - } } } diff --git a/src/render.c b/src/render.c index 09870a3..d8f8933 100644 --- a/src/render.c +++ b/src/render.c @@ -432,21 +432,7 @@ static bool get_root_tile(session_t *ps) { ps->root_tile_fill = false; bool fill = false; - xcb_pixmap_t pixmap = XCB_NONE; - - // Get the values of background attributes - for (int p = 0; background_props_str[p]; p++) { - winprop_t prop = - wid_get_prop(ps, ps->root, get_atom(ps, background_props_str[p]), 1L, - XCB_ATOM_PIXMAP, 32); - if (prop.nitems) { - pixmap = *prop.p32; - fill = false; - free_winprop(&prop); - break; - } - free_winprop(&prop); - } + xcb_pixmap_t pixmap = x_get_root_back_pixmap(ps); // Make sure the pixmap we got is valid if (pixmap && !x_validate_pixmap(ps->c, pixmap)) diff --git a/src/x.c b/src/x.c index bdb48d6..fee9d0d 100644 --- a/src/x.c +++ b/src/x.c @@ -473,7 +473,7 @@ xcb_pixmap_t x_get_root_back_pixmap(session_t *ps) { return pixmap; } -bool x_atom_is_background_prop(session_t *ps, xcb_atom_t atom) { +bool x_is_root_back_pixmap_atom(session_t *ps, xcb_atom_t atom) { for (int p = 0; background_props_str[p]; p++) { xcb_atom_t prop_atom = get_atom(ps, background_props_str[p]); if (prop_atom == atom) diff --git a/src/x.h b/src/x.h index 8269e3f..eac48d1 100644 --- a/src/x.h +++ b/src/x.h @@ -164,6 +164,6 @@ xcb_pixmap_t x_get_root_back_pixmap(session_t *ps); /// Return true if the atom refers to a property name that is used for the /// root window background pixmap -bool x_atom_is_background_prop(session_t *ps, xcb_atom_t atom); +bool x_is_root_back_pixmap_atom(session_t *ps, xcb_atom_t atom); bool x_fence_sync(xcb_connection_t *, xcb_sync_fence_t);