Add XRESOURCES_RELOAD_PATCH

This commit is contained in:
Loic Coyle 2021-04-24 00:17:23 +02:00
parent ec513b230a
commit 540a923fb9
4 changed files with 43 additions and 4 deletions

View file

@ -34,19 +34,46 @@ resource_load(XrmDatabase db, char *name, enum resource_type rtype, void *dst)
return 0;
}
#if XRESOURCES_RELOAD_PATCH
void
config_init(Display *dpy)
{
#else
void
config_init(void)
{
#endif // XRESOURCES_RELOAD_PATCH
char *resm;
XrmDatabase db;
ResourcePref *p;
XrmInitialize();
#if XRESOURCES_RELOAD_PATCH
resm = XResourceManagerString(dpy);
#else
resm = XResourceManagerString(xw.dpy);
#endif // XRESOURCES_RELOAD_PATCH
if (!resm)
return;
db = XrmGetStringDatabase(resm);
for (p = resources; p < resources + LEN(resources); p++)
resource_load(db, p->name, p->type, p->dst);
}
}
#if XRESOURCES_RELOAD_PATCH
void reload_config(int sig){
/* Recreate a Display object to have up to date Xresources entries */
Display *dpy;
if (!(dpy = XOpenDisplay(NULL)))
die("Can't open display\n");
config_init(dpy);
if (sig != -1) {
/* Called due to a SIGUSR1 */
xloadcols();
redraw();
}
signal(SIGUSR1, reload_config);
}
#endif // XRESOURCES_RELOAD_PATCH