Krolyxon
Commit e4fb084

Branches

Refs →

nsxive4fb084

Fix code style of merged code

Author
Bert Münnich
Date
2019-01-23 19:58 +0100
Committer
Bert Münnich · 2019-01-23 20:00 +0100
Parent
4853e17
Commit
e4fb084f26ea680852522e8b9e7769b5a1eee222

+10 −14

1 file changed

  1. M window.c +10 −14
M window.c View
@@ -100,23 +100,20 @@ void win_check_wm_support(Display *dpy, Window root)
100100 }
101101 }
102102
103−void get_xresource(Display *dpy, const char* rsc, const void* dst)
103+void win_res(Display *dpy, const char *rsc, const char **dst)
104104 {
105105 char *type;
106106 XrmValue ret;
107107 XrmDatabase db;
108108 char fullname[256];
109− char *resource_manager;
109+ char *res_man;
110110
111111 XrmInitialize();
112− resource_manager = XResourceManagerString(dpy);
113112
114− if (resource_manager == NULL)
113+ if ((res_man = XResourceManagerString(dpy)) == NULL)
115114 return;
116115
117− db = XrmGetStringDatabase(resource_manager);
118−
119− if (db == NULL)
116+ if ((db = XrmGetStringDatabase(res_man)) == NULL)
120117 return;
121118
122119 snprintf(fullname, sizeof(fullname), ".%s", rsc);
@@ -124,9 +121,8 @@ void get_xresource(Display *dpy, const char* rsc, const void* dst)
124121
125122 XrmGetResource(db, fullname, "String", &type, &ret);
126123
127− if (ret.addr != NULL || !strncmp("String", type, 64)) {
128− *( (char **) dst ) = ret.addr;
129− }
124+ if (ret.addr != NULL && STREQ(type, "String"))
125+ *dst = ret.addr;
130126 }
131127
132128 #define INIT_ATOM_(atom) \
@@ -152,10 +148,10 @@ void win_init(win_t *win)
152148 if (setlocale(LC_CTYPE, "") == NULL || XSupportsLocale() == 0)
153149 error(0, 0, "No locale support");
154150
155− get_xresource(e->dpy, "background", &WIN_BG_COLOR);
156− get_xresource(e->dpy, "background", &BAR_FG_COLOR);
157− get_xresource(e->dpy, "foreground", &BAR_BG_COLOR);
158− get_xresource(e->dpy, "foreground", &SEL_COLOR);
151+ win_res(e->dpy, "background", &WIN_BG_COLOR);
152+ win_res(e->dpy, "background", &BAR_FG_COLOR);
153+ win_res(e->dpy, "foreground", &BAR_BG_COLOR);
154+ win_res(e->dpy, "foreground", &SEL_COLOR);
159155
160156 win_init_font(e, BAR_FONT);
161157