From b828b27adfd97162e989723afbedf245f3822682 Mon Sep 17 00:00:00 2001 From: speedie Date: Sat, 11 Feb 2023 11:34:52 +0100 Subject: [PATCH] update alpha on color reload --- st.c | 14 +++++++++++++- st.h | 2 +- toggle.h | 2 +- x.c | 8 ++++++++ 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/st.c b/st.c index bd16699..519a8c2 100644 --- a/st.c +++ b/st.c @@ -2273,9 +2273,18 @@ strhandle(void) return; #if RELOADCOLORS case 4: - if (narg < 3) + if (narg < 3) { + reloadalpha(); break; + } p = strescseq.args[2]; + reloadalpha(); + + break; + #else + case 4: + reloadalpha(); + break; #endif case 104: /* color reset */ j = (narg > 1) ? atoi(strescseq.args[1]) : -1; @@ -2292,6 +2301,9 @@ strhandle(void) xclearwin(); tfulldirt(); } + + reloadalpha(); + return; } break; diff --git a/st.h b/st.h index f7a7288..48c9292 100644 --- a/st.h +++ b/st.h @@ -44,7 +44,7 @@ enum glyph_attribute { ATTR_BOLD_FAINT = ATTR_BOLD | ATTR_FAINT, }; - + enum drawing_mode { DRAW_NONE = 0, DRAW_BG = 1 << 0, diff --git a/toggle.h b/toggle.h index f0e56e3..d81d619 100644 --- a/toggle.h +++ b/toggle.h @@ -2,4 +2,4 @@ #define USEXRESOURCES 1 /* Include Xresources support (0/1) */ /* 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) */ diff --git a/x.c b/x.c index 0006088..7db70dc 100644 --- a/x.c +++ b/x.c @@ -870,6 +870,14 @@ xloadcolor(int i, const char *name, Color *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 xloadcols(void) {