From ff70f6056ed38f54993a66999a7fc27ffa0bb7c1 Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Wed, 21 Oct 2020 02:06:15 +0000 Subject: [PATCH] core: remove a bit more of Xlib dependencies Signed-off-by: Yuxuan Shui --- src/picom.c | 11 ++++++++--- src/picom.h | 33 --------------------------------- 2 files changed, 8 insertions(+), 36 deletions(-) diff --git a/src/picom.c b/src/picom.c index 9b7c534b..cf17b947 100644 --- a/src/picom.c +++ b/src/picom.c @@ -955,9 +955,14 @@ static int register_cm(session_t *ps) { } // Set COMPTON_VERSION - if (!wid_set_text_prop(ps, ps->reg_win, get_atom(ps->atoms, "COMPTON_VERSION"), - COMPTON_VERSION)) { - log_error("Failed to set COMPTON_VERSION."); + e = xcb_request_check( + ps->c, xcb_change_property_checked( + ps->c, XCB_PROP_MODE_REPLACE, ps->reg_win, + get_atom(ps->atoms, "COMPTON_VERSION"), XCB_ATOM_STRING, 8, + (uint32_t)strlen(COMPTON_VERSION), COMPTON_VERSION)); + if (e) { + log_error_x_error(e, "Failed to set COMPTON_VERSION."); + free(e); } // Acquire X Selection _NET_WM_CM_S? diff --git a/src/picom.h b/src/picom.h index a71f5c03..25f75806 100644 --- a/src/picom.h +++ b/src/picom.h @@ -102,39 +102,6 @@ free_win_res_glx(session_t *ps attr_unused, struct managed_win *w attr_unused) { } #endif -/** - * Create a XTextProperty of a single string. - */ -static inline XTextProperty *make_text_prop(session_t *ps, char *str) { - XTextProperty *pprop = ccalloc(1, XTextProperty); - - if (XmbTextListToTextProperty(ps->dpy, &str, 1, XStringStyle, pprop)) { - XFree(pprop->value); - free(pprop); - pprop = NULL; - } - - return pprop; -} - -/** - * Set a single-string text property on a window. - */ -static inline bool -wid_set_text_prop(session_t *ps, xcb_window_t wid, xcb_atom_t prop_atom, char *str) { - XTextProperty *pprop = make_text_prop(ps, str); - if (!pprop) { - log_error("Failed to make text property: %s.", str); - return false; - } - - XSetTextProperty(ps->dpy, wid, pprop, prop_atom); - XFree(pprop->value); - XFree(pprop); - - return true; -} - /** * Dump an drawable's info. */