nsxivf7fc663
Support X resource entries with Sxiv class name
+9 −13
1 file changed
- M window.c +9 −13
| @@ -29,6 +29,8 @@ | |||
| 29 | 29 | #include <X11/Xatom.h> | |
| 30 | 30 | #include <X11/Xresource.h> | |
| 31 | 31 | ||
| 32 | + | #define RES_CLASS "Sxiv" | |
| 33 | + | ||
| 32 | 34 | enum { | |
| 33 | 35 | H_TEXT_PAD = 5, | |
| 34 | 36 | V_TEXT_PAD = 1 | |
| @@ -100,12 +102,11 @@ void win_check_wm_support(Display *dpy, Window root) | |||
| 100 | 102 | } | |
| 101 | 103 | } | |
| 102 | 104 | ||
| 103 | − | void win_res(Display *dpy, const char *rsc, const char **dst) | |
| 105 | + | void win_res(Display *dpy, const char *name, const char **dst) | |
| 104 | 106 | { | |
| 105 | 107 | char *type; | |
| 106 | 108 | XrmValue ret; | |
| 107 | 109 | XrmDatabase db; | |
| 108 | − | char fullname[256]; | |
| 109 | 110 | char *res_man; | |
| 110 | 111 | ||
| 111 | 112 | XrmInitialize(); | |
| @@ -116,12 +117,7 @@ void win_res(Display *dpy, const char *rsc, const char **dst) | |||
| 116 | 117 | if ((db = XrmGetStringDatabase(res_man)) == NULL) | |
| 117 | 118 | return; | |
| 118 | 119 | ||
| 119 | − | snprintf(fullname, sizeof(fullname), ".%s", rsc); | |
| 120 | − | fullname[sizeof(fullname) - 1] = '\0'; | |
| 121 | − | ||
| 122 | − | XrmGetResource(db, fullname, "String", &type, &ret); | |
| 123 | − | ||
| 124 | − | if (ret.addr != NULL && STREQ(type, "String")) | |
| 120 | + | if (XrmGetResource(db, name, name, &type, &ret) && STREQ(type, "String")) | |
| 125 | 121 | *dst = ret.addr; | |
| 126 | 122 | } | |
| 127 | 123 | ||
| @@ -148,10 +144,10 @@ void win_init(win_t *win) | |||
| 148 | 144 | if (setlocale(LC_CTYPE, "") == NULL || XSupportsLocale() == 0) | |
| 149 | 145 | error(0, 0, "No locale support"); | |
| 150 | 146 | ||
| 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); | |
| 147 | + | win_res(e->dpy, RES_CLASS ".background", &WIN_BG_COLOR); | |
| 148 | + | win_res(e->dpy, RES_CLASS ".background", &BAR_FG_COLOR); | |
| 149 | + | win_res(e->dpy, RES_CLASS ".foreground", &BAR_BG_COLOR); | |
| 150 | + | win_res(e->dpy, RES_CLASS ".foreground", &SEL_COLOR); | |
| 155 | 151 | ||
| 156 | 152 | win_init_font(e, BAR_FONT); | |
| 157 | 153 | ||
| @@ -281,7 +277,7 @@ void win_open(win_t *win) | |||
| 281 | 277 | ||
| 282 | 278 | win_set_title(win, "sxiv"); | |
| 283 | 279 | ||
| 284 | − | classhint.res_class = "Sxiv"; | |
| 280 | + | classhint.res_class = RES_CLASS; | |
| 285 | 281 | classhint.res_name = options->res_name != NULL ? options->res_name : "sxiv"; | |
| 286 | 282 | XSetClassHint(e->dpy, win->xwin, &classhint); | |
| 287 | 283 | ||