From 5c16760c03b4e84517ac1ae158c34205f3189ecb Mon Sep 17 00:00:00 2001 From: dogeystamp Date: Tue, 2 Jan 2024 11:58:43 -0500 Subject: [PATCH] [st] fix: colors are legible now --- suckless/st/config.def.h | 17 ++++------------- suckless/st/x.c | 13 ++++++++++++- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/suckless/st/config.def.h b/suckless/st/config.def.h index 5c1193f..e14775c 100644 --- a/suckless/st/config.def.h +++ b/suckless/st/config.def.h @@ -122,15 +122,6 @@ static const char *colorname[] = { "#b48ead", /* magenta */ "#8fbcbb", /* cyan */ "#eceff4", /* white */ - - - [255] = 0, - - /* more colors can be added after 255 to use with DefaultXX */ - "#cccccc", - "#555555", - "gray90", /* default foreground colour */ - "black", /* default background colour */ }; @@ -138,10 +129,10 @@ static const char *colorname[] = { * Default colors (colorname index) * foreground, background, cursor, reverse cursor */ -unsigned int defaultfg = 258; -unsigned int defaultbg = 259; -unsigned int defaultcs = 256; -static unsigned int defaultrcs = 257; +unsigned int defaultfg = 15; +unsigned int defaultbg = 0; +unsigned int defaultcs = 15; +static unsigned int defaultrcs = 0; /* * Default shape of cursor diff --git a/suckless/st/x.c b/suckless/st/x.c index 5bb6d7e..03b5189 100644 --- a/suckless/st/x.c +++ b/suckless/st/x.c @@ -1549,7 +1549,7 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i int charlen = len * ((base.mode & ATTR_WIDE) ? 2 : 1); int winx = win.hborderpx + x * win.cw, winy = win.vborderpx + y * win.ch, width = charlen * win.cw; - Color *fg, *bg, *temp, revfg, revbg, truefg, truebg; + Color *fg, *bg, *temp, revfg, revbg, clarfg, truefg, truebg; XRenderColor colfg, colbg; XRectangle r; @@ -1635,6 +1635,17 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i if (base.mode & ATTR_INVISIBLE) fg = bg; + /* Hack that fixes fg becoming same as bg when its alpha is set near 0. */ + if (fg == &dc.col[defaultbg]) { + colfg.red = fg->color.red; + colfg.green = fg->color.green; + colfg.blue = fg->color.blue; + colfg.alpha = 0xFFFF; + XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &colfg, + &clarfg); + fg = &clarfg; + } + /* Intelligent cleaning up of the borders. */ if (x == 0) { xclear(0, (y == 0)? 0 : winy, win.hborderpx,