From e4fb084f26ea680852522e8b9e7769b5a1eee222 Mon Sep 17 00:00:00 2001 From: Bert Münnich Date: Wed, 23 Jan 2019 19:58:47 +0100 Subject: Fix code style of merged code --- window.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'window.c') diff --git a/window.c b/window.c index 559c244..2f7cf7e 100644 --- a/window.c +++ b/window.c @@ -100,23 +100,20 @@ void win_check_wm_support(Display *dpy, Window root) } } -void get_xresource(Display *dpy, const char* rsc, const void* dst) +void win_res(Display *dpy, const char *rsc, const char **dst) { char *type; XrmValue ret; XrmDatabase db; char fullname[256]; - char *resource_manager; + char *res_man; XrmInitialize(); - resource_manager = XResourceManagerString(dpy); - if (resource_manager == NULL) + if ((res_man = XResourceManagerString(dpy)) == NULL) return; - db = XrmGetStringDatabase(resource_manager); - - if (db == NULL) + if ((db = XrmGetStringDatabase(res_man)) == NULL) return; snprintf(fullname, sizeof(fullname), ".%s", rsc); @@ -124,9 +121,8 @@ void get_xresource(Display *dpy, const char* rsc, const void* dst) XrmGetResource(db, fullname, "String", &type, &ret); - if (ret.addr != NULL || !strncmp("String", type, 64)) { - *( (char **) dst ) = ret.addr; - } + if (ret.addr != NULL && STREQ(type, "String")) + *dst = ret.addr; } #define INIT_ATOM_(atom) \ @@ -152,10 +148,10 @@ void win_init(win_t *win) if (setlocale(LC_CTYPE, "") == NULL || XSupportsLocale() == 0) error(0, 0, "No locale support"); - get_xresource(e->dpy, "background", &WIN_BG_COLOR); - get_xresource(e->dpy, "background", &BAR_FG_COLOR); - get_xresource(e->dpy, "foreground", &BAR_BG_COLOR); - get_xresource(e->dpy, "foreground", &SEL_COLOR); + win_res(e->dpy, "background", &WIN_BG_COLOR); + win_res(e->dpy, "background", &BAR_FG_COLOR); + win_res(e->dpy, "foreground", &BAR_BG_COLOR); + win_res(e->dpy, "foreground", &SEL_COLOR); win_init_font(e, BAR_FONT); -- cgit v1.2.3-54-g00ecf