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 <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2019-02-07 00:30:32 +00:00
parent 7d00b89364
commit 856ad4b230
No known key found for this signature in database
GPG Key ID: 37C999F617EA1A47
4 changed files with 5 additions and 31 deletions

View File

@ -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;
}
}
}

View File

@ -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))

View File

@ -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)

View File

@ -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);