On Thu, Nov 07, 2024 at 11:18:03AM +0000, stefan11111 wrote: > On 2024-11-05 10:37, stefan11111 wrote: > > > > Looks like git st works. > > Looked into it a bit more, and it turns out that the reason it failed > like that > is not because of code from st, but because of the alpha patch for st. > > XftColorAllocName() fails(likely not implemented in tinyx), which kills > st. > > Is there a way to get st to ignore/handle that error and not have it > kill the app?
Turns out I was looking at the wrong diff somehow. The alpha patch indeed just introduced an entirely new bug, since the mainline st never needed a 32-bit color mode. I've made an updated version, if you'd like to check it out. -- Storkman
>From 13235fb1bac7d0bd24186e391d7befa4a569e4f9 Mon Sep 17 00:00:00 2001 From: Paul Storkman <stork...@storkman.nl> Date: Mon, 11 Nov 2024 20:18:52 +0100 Subject: [PATCH] Updated alpha patch. Uses the default visual if a 32-bit TrueColor one isn't supported by the server. Based on st-alpha-osc11-20220222-0.8.5.diff by Santtu Lakkala <i...@inz.fi> --- config.def.h | 3 +++ x.c | 36 +++++++++++++++++++++++++++++------- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/config.def.h b/config.def.h index 2cd740a..019a4e1 100644 --- a/config.def.h +++ b/config.def.h @@ -93,6 +93,9 @@ char *termname = "st-256color"; */ unsigned int tabspaces = 8; +/* bg opacity */ +float alpha = 0.8; + /* Terminal colors (16 first used in escape sequence) */ static const char *colorname[] = { /* 8 normal colors */ diff --git a/x.c b/x.c index d73152b..80ce1b3 100644 --- a/x.c +++ b/x.c @@ -105,6 +105,7 @@ typedef struct { XSetWindowAttributes attrs; int scr; int isfixed; /* is fixed geometry? */ + int depth; /* bit depth */ int l, t; /* left and top offset */ int gm; /* geometry mask */ } XWindow; @@ -752,7 +753,7 @@ xresize(int col, int row) XFreePixmap(xw.dpy, xw.buf); xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h, - DefaultDepth(xw.dpy, xw.scr)); + xw.depth); XftDrawChange(xw.draw, xw.buf); xclear(0, 0, win.w, win.h); @@ -812,6 +813,10 @@ xloadcols(void) else die("could not allocate color %d\n", i); } + + dc.col[defaultbg].color.alpha = (unsigned short)(0xffff * alpha); + dc.col[defaultbg].pixel &= 0x00FFFFFF; + dc.col[defaultbg].pixel |= (unsigned char)(0xff * alpha) << 24; loaded = 1; } @@ -842,6 +847,12 @@ xsetcolorname(int x, const char *name) XftColorFree(xw.dpy, xw.vis, xw.cmap, &dc.col[x]); dc.col[x] = ncolor; + if (x == defaultbg) { + dc.col[defaultbg].color.alpha = (unsigned short)(0xffff * alpha); + dc.col[defaultbg].pixel &= 0x00FFFFFF; + dc.col[defaultbg].pixel |= (unsigned char)(0xff * alpha) << 24; + } + return 0; } @@ -1134,11 +1145,20 @@ xinit(int cols, int rows) Window parent, root; pid_t thispid = getpid(); XColor xmousefg, xmousebg; + XVisualInfo vis; if (!(xw.dpy = XOpenDisplay(NULL))) die("can't open display\n"); xw.scr = XDefaultScreen(xw.dpy); - xw.vis = XDefaultVisual(xw.dpy, xw.scr); + + root = XRootWindow(xw.dpy, xw.scr); + if (XMatchVisualInfo(xw.dpy, xw.scr, 32, TrueColor, &vis)) { + xw.depth = 32; + xw.vis = vis.visual; + } else { + xw.depth = DefaultDepth(xw.dpy, xw.scr); + xw.vis = DefaultVisual(xw.dpy, xw.scr); + } /* font */ if (!FcInit()) @@ -1148,7 +1168,7 @@ xinit(int cols, int rows) xloadfonts(usedfont, 0); /* colors */ - xw.cmap = XDefaultColormap(xw.dpy, xw.scr); + xw.cmap = XCreateColormap(xw.dpy, root, xw.vis, None); xloadcols(); /* adjust fixed window geometry */ @@ -1168,11 +1188,10 @@ xinit(int cols, int rows) | ButtonMotionMask | ButtonPressMask | ButtonReleaseMask; xw.attrs.colormap = xw.cmap; - root = XRootWindow(xw.dpy, xw.scr); if (!(opt_embed && (parent = strtol(opt_embed, NULL, 0)))) parent = root; xw.win = XCreateWindow(xw.dpy, root, xw.l, xw.t, - win.w, win.h, 0, XDefaultDepth(xw.dpy, xw.scr), InputOutput, + win.w, win.h, 0, xw.depth, InputOutput, xw.vis, CWBackPixel | CWBorderPixel | CWBitGravity | CWEventMask | CWColormap, &xw.attrs); if (parent != root) @@ -1182,8 +1201,7 @@ xinit(int cols, int rows) gcvalues.graphics_exposures = False; dc.gc = XCreateGC(xw.dpy, xw.win, GCGraphicsExposures, &gcvalues); - xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h, - DefaultDepth(xw.dpy, xw.scr)); + xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h, xw.depth); XSetForeground(xw.dpy, dc.gc, dc.col[defaultbg].pixel); XFillRectangle(xw.dpy, xw.buf, dc.gc, 0, 0, win.w, win.h); @@ -2047,6 +2065,10 @@ main(int argc, char *argv[]) case 'a': allowaltscreen = 0; break; + case 'A': + alpha = strtof(EARGF(usage()), NULL); + LIMIT(alpha, 0.0, 1.0); + break; case 'c': opt_class = EARGF(usage()); break; -- 2.43.2