fix(wm,st,theme): fix live theme reload across apps and top-bar artifacts
- Read XA_RESOURCE_MANAGER directly via XGetWindowProperty in anode_open_xres_db() instead of XResourceManagerString(), avoiding stale startup Xlib caches. - Switch xrdb -merge to xrdb -load in anode-apply-theme and reset default palettes/resources on reload in dwm and st so omitted keys do not linger. - Update Mod4+Shift+r (reloadxres) in dwm to run xrdb -load, signal running ANODE processes, and run anode-autostart reload while freeing old XftColors, preserving fullscreen borders, and updating non-ARGB tray icon backgrounds. - Watch root PropertyNotify(XA_RESOURCE_MANAGER) in st, use sigaction(SIGUSR1), free reloaded resource strings, and refresh window background and cursor colors. - Fix drw_text() return x-coordinate in dwm and dmenu and clear the bar pixmap in drawbar() to eliminate unpainted gaps before window titles on reload. - Sync active_name on external theme reload in anode-themes and add pixel-level test_live_theme_reload_and_bar_artifacts() in tests/test_x11_xvfb.py.
This commit is contained in:
1 parent
d1eff5562d
commit
86ca30db03
8 files changed
+343
-42
No files matched your search
+49
-5
@@ -957,6 +957,9 @@ static void drawbar(Monitor *m) {
|
||||
if (showsystray && m == systraytomon(m) && !systrayonleft)
|
||||
stw = (int)getsystraywidth();
|
||||
|
||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||
drw_rect(drw, 0, 0, (unsigned int)m->ww, (unsigned int)bh, 1, 1);
|
||||
|
||||
if (m == selmon) {
|
||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||
tw = (int)TEXTW(stext) - lrpad / 2 + 2;
|
||||
@@ -1545,6 +1548,12 @@ static void loadxres(void) {
|
||||
}
|
||||
|
||||
int cur_sz = 0;
|
||||
snprintf(normbgcolor, sizeof(normbgcolor), "#0b0e14");
|
||||
snprintf(normbordercolor, sizeof(normbordercolor), "#283444");
|
||||
snprintf(normfgcolor, sizeof(normfgcolor), "#e6e1cf");
|
||||
snprintf(selbgcolor, sizeof(selbgcolor), "#2b5278");
|
||||
snprintf(selbordercolor, sizeof(selbordercolor), "#59c2ff");
|
||||
snprintf(selfgcolor, sizeof(selfgcolor), "#ffffff");
|
||||
if (db) {
|
||||
if ((v = xrm_lookup(db, "dwm.normbgcolor", "dwm.background", "theme.bgBar")))
|
||||
snprintf(normbgcolor, sizeof(normbgcolor), "%s", v);
|
||||
@@ -1617,8 +1626,13 @@ static void reloadxres(const Arg *arg) {
|
||||
if (cursor[CurNormal])
|
||||
XDefineCursor(dpy, root, cursor[CurNormal]->cursor);
|
||||
|
||||
free(scheme[SchemeNorm]);
|
||||
free(scheme[SchemeSel]);
|
||||
for (int si = 0; si < 2; si++) {
|
||||
if (scheme[si]) {
|
||||
for (int ci = 0; ci < 3; ci++)
|
||||
XftColorFree(dpy, DefaultVisual(dpy, screen), DefaultColormap(dpy, screen), &scheme[si][ci]);
|
||||
free(scheme[si]);
|
||||
}
|
||||
}
|
||||
scheme[SchemeNorm] = drw_scm_create(drw, (const char **)colors[SchemeNorm], 3);
|
||||
scheme[SchemeSel] = drw_scm_create(drw, (const char **)colors[SchemeSel], 3);
|
||||
|
||||
@@ -1627,14 +1641,20 @@ static void reloadxres(const Arg *arg) {
|
||||
updatebarpos(m);
|
||||
resizebarwin(m);
|
||||
for (c = m->clients; c; c = c->next) {
|
||||
c->bw = (int)borderpx;
|
||||
if (!c->isfullscreen)
|
||||
c->bw = (int)borderpx;
|
||||
else
|
||||
c->oldbw = (int)borderpx;
|
||||
XSetWindowBorder(dpy, c->win,
|
||||
scheme[c == selmon->sel ? SchemeSel : SchemeNorm][ColBorder].pixel);
|
||||
}
|
||||
}
|
||||
if (showsystray && systray) {
|
||||
for (c = systray->icons; c; c = c->next)
|
||||
for (c = systray->icons; c; c = c->next) {
|
||||
updatesystrayicongeom(c, c->w, c->h);
|
||||
if (!systray->use_argb)
|
||||
XSetWindowBackground(dpy, c->win, scheme[SchemeNorm][ColBg].pixel);
|
||||
}
|
||||
}
|
||||
updatesystray(1);
|
||||
updateworkarea();
|
||||
@@ -1642,7 +1662,31 @@ static void reloadxres(const Arg *arg) {
|
||||
drawbars();
|
||||
XSync(dpy, False);
|
||||
if (arg && arg->i) {
|
||||
Arg a = {.v = autostartreloadcmd};
|
||||
static const char *reloadcmd[] = {
|
||||
"/bin/sh", "-c",
|
||||
"xr=\"${ANODE_XRESOURCES:-$HOME/.Xresources}\"; "
|
||||
"if [ -r \"$xr\" ] && command -v xrdb >/dev/null 2>&1; then "
|
||||
" xrdb -load \"$xr\" >/dev/null 2>&1 || true; "
|
||||
"fi; "
|
||||
"if [ \"${ANODE_NO_SIGNAL:-0}\" != \"1\" ]; then "
|
||||
" _pids=\"$( (ps -eo pid=,comm= 2>/dev/null || ps -ax -o pid=,comm= 2>/dev/null || true) | awk '"
|
||||
" { pid = $1; cmd = $2; sub(/^.*\\//, \"\", cmd); "
|
||||
" if (cmd == \"st\" || cmd == \"anode-statusd\" || "
|
||||
" cmd == \"anode-net\" || cmd == \"anode-audio\" || "
|
||||
" cmd == \"anode-display\" || cmd == \"anode-datetime\" || "
|
||||
" cmd == \"anode-power\" || cmd == \"anode-themes\") print \"USR1 \" pid; "
|
||||
" else if (cmd == \"anode-vkbd\") print \"HUP \" pid; "
|
||||
" }' )\"; "
|
||||
" if [ -n \"${_pids:-}\" ]; then "
|
||||
" printf '%s\\n' \"$_pids\" | while read -r _sig _p; do "
|
||||
" [ -n \"${_p:-}\" ] && kill -\"$_sig\" \"$_p\" 2>/dev/null || true; "
|
||||
" done; "
|
||||
" fi; "
|
||||
"fi; "
|
||||
"exec anode-autostart reload",
|
||||
NULL
|
||||
};
|
||||
Arg a = {.v = reloadcmd};
|
||||
spawn(&a);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user