update alpha on color reload

This commit is contained in:
speedie 2023-02-11 11:34:52 +01:00
parent c91bd9f1e0
commit b828b27adf
4 changed files with 23 additions and 3 deletions

14
st.c
View file

@ -2273,9 +2273,18 @@ strhandle(void)
return; return;
#if RELOADCOLORS #if RELOADCOLORS
case 4: case 4:
if (narg < 3) if (narg < 3) {
reloadalpha();
break; break;
}
p = strescseq.args[2]; p = strescseq.args[2];
reloadalpha();
break;
#else
case 4:
reloadalpha();
break;
#endif #endif
case 104: /* color reset */ case 104: /* color reset */
j = (narg > 1) ? atoi(strescseq.args[1]) : -1; j = (narg > 1) ? atoi(strescseq.args[1]) : -1;
@ -2292,6 +2301,9 @@ strhandle(void)
xclearwin(); xclearwin();
tfulldirt(); tfulldirt();
} }
reloadalpha();
return; return;
} }
break; break;

2
st.h
View file

@ -44,7 +44,7 @@ enum glyph_attribute {
ATTR_BOLD_FAINT = ATTR_BOLD | ATTR_FAINT, ATTR_BOLD_FAINT = ATTR_BOLD | ATTR_FAINT,
}; };
enum drawing_mode { enum drawing_mode {
DRAW_NONE = 0, DRAW_NONE = 0,
DRAW_BG = 1 << 0, DRAW_BG = 1 << 0,

View file

@ -2,4 +2,4 @@
#define USEXRESOURCES 1 /* Include Xresources support (0/1) */ #define USEXRESOURCES 1 /* Include Xresources support (0/1) */
/* Toggle functionality */ /* Toggle functionality */
#define RELOADCOLORS 0 /* Allow programs like pywal to reload colors during runtime through sequences (0/1) */ #define RELOADCOLORS 1 /* Allow programs like pywal to reload colors during runtime through sequences (0/1) */

8
x.c
View file

@ -870,6 +870,14 @@ xloadcolor(int i, const char *name, Color *ncolor)
return XftColorAllocName(xw.dpy, xw.vis, xw.cmap, name, ncolor); return XftColorAllocName(xw.dpy, xw.vis, xw.cmap, name, ncolor);
} }
void
reloadalpha(void)
{
dc.col[defaultbg].color.alpha = (unsigned short)(0xffff * alpha);
dc.col[defaultbg].pixel &= 0x00FFFFFF;
dc.col[defaultbg].pixel |= (unsigned char)(0xff * alpha) << 24;
}
void void
xloadcols(void) xloadcols(void)
{ {