sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

commit d6bda46c8c864f436e0a825a5fa6f431a1328e57
parent 72189fa13a454297b3f3abb57b4d0712aa216931
Author: . <chyleson165@disroot.org>
Date:   Tue, 24 Feb 2026 13:32:57 -0300

[st][PATCH] Update st-alpha_focus_highlight patch for 0.9.3

Diffstat:
Mst.suckless.org/patches/alpha_focus_highlight/index.md | 2++
Ast.suckless.org/patches/alpha_focus_highlight/st-focus-0.9.3.diff | 257+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 259 insertions(+), 0 deletions(-)

diff --git a/st.suckless.org/patches/alpha_focus_highlight/index.md b/st.suckless.org/patches/alpha_focus_highlight/index.md @@ -52,6 +52,8 @@ Please report an Issue or contribute a merged patch in that case. Patch: alpha + focus -------------------- +**st-0.9.3** +- [Version 3(attached)](st-focus-0.9.3.diff) **st-0.9** - [Version 2(attached)](st-focus-20230610-68d1ad9.diff) - Most recent release [st-focus-20230610-68d1ad9.diff Github](https://github.com/juliusHuelsmann/st/releases/download/alpha_09/st-focus-20230610-68d1ad9.diff) diff --git a/st.suckless.org/patches/alpha_focus_highlight/st-focus-0.9.3.diff b/st.suckless.org/patches/alpha_focus_highlight/st-focus-0.9.3.diff @@ -0,0 +1,257 @@ +diff -up a/config.def.h b/config.def.h +--- a/config.def.h 2025-08-09 10:00:58.350298234 -0300 ++++ b/config.def.h 2026-02-24 12:47:39.589730661 -0300 +@@ -93,6 +93,9 @@ char *termname = "st-256color"; + */ + unsigned int tabspaces = 8; + ++/* bg opacity */ ++float alpha = 0.93, alphaUnfocused = 0.6; ++ + /* Terminal colors (16 first used in escape sequence) */ + static const char *colorname[] = { + /* 8 normal colors */ +@@ -120,8 +123,7 @@ static const char *colorname[] = { + /* more colors can be added after 255 to use with DefaultXX */ + "#cccccc", + "#555555", +- "gray90", /* default foreground colour */ +- "black", /* default background colour */ ++ "black", + }; + + +@@ -129,10 +131,11 @@ static const char *colorname[] = { + * Default colors (colorname index) + * foreground, background, cursor, reverse cursor + */ +-unsigned int defaultfg = 258; +-unsigned int defaultbg = 259; ++unsigned int defaultfg = 7; ++unsigned int defaultbg = 0; + unsigned int defaultcs = 256; + static unsigned int defaultrcs = 257; ++unsigned int bg = 0, bgUnfocused = 16; + + /* + * Default shape of cursor +diff -up a/config.mk b/config.mk +--- a/config.mk 2025-08-09 10:00:58.350298234 -0300 ++++ b/config.mk 2026-02-24 12:47:39.580955347 -0300 +@@ -16,7 +16,7 @@ PKG_CONFIG = pkg-config + INCS = -I$(X11INC) \ + `$(PKG_CONFIG) --cflags fontconfig` \ + `$(PKG_CONFIG) --cflags freetype2` +-LIBS = -L$(X11LIB) -lm -lrt -lX11 -lutil -lXft \ ++LIBS = -L$(X11LIB) -lm -lrt -lX11 -lutil -lXft -lXrender\ + `$(PKG_CONFIG) --libs fontconfig` \ + `$(PKG_CONFIG) --libs freetype2` + +diff -up a/st.c b/st.c +--- a/st.c 2025-08-09 10:00:58.350298234 -0300 ++++ b/st.c 2026-02-24 12:47:39.588067873 -0300 +@@ -194,7 +194,6 @@ static void tsetscroll(int, int); + static void tswapscreen(void); + static void tsetmode(int, int, const int *, int); + static int twrite(const char *, int, int); +-static void tfulldirt(void); + static void tcontrolcode(uchar ); + static void tdectest(char ); + static void tdefutf8(char); +diff -up a/st.h b/st.h +--- a/st.h 2025-08-09 10:00:58.350298234 -0300 ++++ b/st.h 2026-02-24 12:47:39.588511996 -0300 +@@ -79,6 +79,7 @@ typedef union { + + void die(const char *, ...); + void redraw(void); ++void tfulldirt(void); + void draw(void); + + void printscreen(const Arg *); +@@ -124,3 +125,4 @@ extern unsigned int tabspaces; + extern unsigned int defaultfg; + extern unsigned int defaultbg; + extern unsigned int defaultcs; ++extern float alpha, alphaUnfocused; +diff -up a/x.c b/x.c +--- a/x.c 2025-08-09 10:00:58.350298234 -0300 ++++ b/x.c 2026-02-24 12:50:24.094826510 -0300 +@@ -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; +@@ -243,6 +244,7 @@ static char *usedfont = NULL; + static double usedfontsize = 0; + static double defaultfontsize = 0; + ++static char *opt_alpha = NULL; + static char *opt_class = NULL; + static char **opt_cmd = NULL; + static char *opt_embed = NULL; +@@ -253,6 +255,7 @@ static char *opt_name = NULL; + static char *opt_title = NULL; + + static uint buttons; /* bit field of pressed buttons */ ++static int focused = 0; + + void + clipcopy(const Arg *dummy) +@@ -752,7 +755,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); + +@@ -791,27 +794,36 @@ xloadcolor(int i, const char *name, Colo + } + + void ++xloadalpha(void) ++{ ++ xloadcolor(focused ?bg :bgUnfocused, NULL, &dc.col[defaultbg]); ++ float const usedAlpha = focused ? alpha : alphaUnfocused; ++ if (opt_alpha) alpha = strtof(opt_alpha, NULL); ++ dc.col[defaultbg].color.alpha = (unsigned short)(0xffff * usedAlpha); ++ dc.col[defaultbg].pixel &= 0x00FFFFFF; ++ dc.col[defaultbg].pixel |= (unsigned char)(0xff * usedAlpha) << 24; ++} ++ ++void + xloadcols(void) + { +- int i; + static int loaded; + Color *cp; + +- if (loaded) { +- for (cp = dc.col; cp < &dc.col[dc.collen]; ++cp) +- XftColorFree(xw.dpy, xw.vis, xw.cmap, cp); +- } else { +- dc.collen = MAX(LEN(colorname), 256); +- dc.col = xmalloc(dc.collen * sizeof(Color)); ++ if (!loaded) { ++ dc.collen = 1 + (defaultbg = MAX(LEN(colorname), 256)); ++ dc.col = xmalloc((dc.collen) * sizeof(Color)); + } + +- for (i = 0; i < dc.collen; i++) ++ for (int i = 0; i+1 < dc.collen; ++i) + if (!xloadcolor(i, NULL, &dc.col[i])) { + if (colorname[i]) + die("could not allocate color '%s'\n", colorname[i]); + else + die("could not allocate color %d\n", i); + } ++ ++ xloadalpha(); + loaded = 1; + } + +@@ -1134,11 +1146,23 @@ xinit(int cols, int rows) + Window parent, root; + pid_t thispid = getpid(); + XColor xmousefg, xmousebg; ++ XWindowAttributes attr; ++ 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); ++ ++ if (!(opt_embed && (parent = strtol(opt_embed, NULL, 0)))) { ++ parent = XRootWindow(xw.dpy, xw.scr); ++ xw.depth = 32; ++ } else { ++ XGetWindowAttributes(xw.dpy, parent, &attr); ++ xw.depth = attr.depth; ++ } ++ ++ XMatchVisualInfo(xw.dpy, xw.scr, xw.depth, TrueColor, &vis); ++ xw.vis = vis.visual; + + /* font */ + if (!FcInit()) +@@ -1148,7 +1172,7 @@ xinit(int cols, int rows) + xloadfonts(usedfont, 0); + + /* colors */ +- xw.cmap = XDefaultColormap(xw.dpy, xw.scr); ++ xw.cmap = XCreateColormap(xw.dpy, parent, xw.vis, None); + xloadcols(); + + /* adjust fixed window geometry */ +@@ -1169,10 +1193,8 @@ xinit(int cols, int rows) + 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) +@@ -1180,10 +1202,8 @@ xinit(int cols, int rows) + + memset(&gcvalues, 0, sizeof(gcvalues)); + 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); ++ dc.gc = XCreateGC(xw.dpy, xw.buf, GCGraphicsExposures, &gcvalues); + XSetForeground(xw.dpy, dc.gc, dc.col[defaultbg].pixel); + XFillRectangle(xw.dpy, xw.buf, dc.gc, 0, 0, win.w, win.h); + +@@ -1786,12 +1806,22 @@ focus(XEvent *ev) + xseturgency(0); + if (IS_SET(MODE_FOCUS)) + ttywrite("\033[I", 3, 0); ++ if (!focused) { ++ focused = 1; ++ xloadalpha(); ++ tfulldirt(); ++ } + } else { + if (xw.ime.xic) + XUnsetICFocus(xw.ime.xic); + win.mode &= ~MODE_FOCUSED; + if (IS_SET(MODE_FOCUS)) + ttywrite("\033[O", 3, 0); ++ if (focused) { ++ focused = 0; ++ xloadalpha(); ++ tfulldirt(); ++ } + } + } + +@@ -2047,6 +2077,9 @@ main(int argc, char *argv[]) + case 'a': + allowaltscreen = 0; + break; ++ case 'A': ++ opt_alpha = EARGF(usage()); ++ break; + case 'c': + opt_class = EARGF(usage()); + break; +@@ -2098,6 +2131,7 @@ run: + XSetLocaleModifiers(""); + cols = MAX(cols, 1); + rows = MAX(rows, 1); ++ defaultbg = MAX(LEN(colorname), 256); + tnew(cols, rows); + xinit(cols, rows); + xsetenv();