From 2ebeb2e237599eed280bce5c2b87420b0ba3e87e Mon Sep 17 00:00:00 2001 From: A Farzat Date: Tue, 22 Oct 2024 14:26:45 +0900 Subject: Add st patches and config.h to paru --- .../st/patches/0001-Apply-font2-0.8.5.diff | 163 +++++++++++++++++++++ .../0002-Apply-dynamic-cursor-color-0.9.diff | 49 +++++++ .../patches/0003-Apply-alpha-0.8.5-modified.diff | 143 ++++++++++++++++++ .../0004-Apply-changealpha-0.1-modified.diff | 75 ++++++++++ 4 files changed, 430 insertions(+) create mode 100644 .config/paru/pkg_config/st/patches/0001-Apply-font2-0.8.5.diff create mode 100644 .config/paru/pkg_config/st/patches/0002-Apply-dynamic-cursor-color-0.9.diff create mode 100644 .config/paru/pkg_config/st/patches/0003-Apply-alpha-0.8.5-modified.diff create mode 100644 .config/paru/pkg_config/st/patches/0004-Apply-changealpha-0.1-modified.diff (limited to '.config/paru/pkg_config/st/patches') diff --git a/.config/paru/pkg_config/st/patches/0001-Apply-font2-0.8.5.diff b/.config/paru/pkg_config/st/patches/0001-Apply-font2-0.8.5.diff new file mode 100644 index 0000000..78151ad --- /dev/null +++ b/.config/paru/pkg_config/st/patches/0001-Apply-font2-0.8.5.diff @@ -0,0 +1,163 @@ +From 34ce1d44898f3ac2fd2806627b4aead097dec213 Mon Sep 17 00:00:00 2001 +From: A Farzat +Date: Sun, 31 Dec 2023 09:48:47 +0900 +Subject: [PATCH 1/4] Apply font2-0.8.5 + +--- + config.def.h | 6 +++ + x.c | 101 +++++++++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 107 insertions(+) + +diff --git a/config.def.h b/config.def.h +index 2cd740a..1dd5a9b 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -6,6 +6,12 @@ + * font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html + */ + static char *font = "Liberation Mono:pixelsize=12:antialias=true:autohint=true"; ++/* Spare fonts */ ++static char *font2[] = { ++/* "Inconsolata for Powerline:pixelsize=12:antialias=true:autohint=true", */ ++/* "Hack Nerd Font Mono:pixelsize=11:antialias=true:autohint=true", */ ++}; ++ + static int borderpx = 2; + + /* +diff --git a/x.c b/x.c +index d73152b..2f2180c 100644 +--- a/x.c ++++ b/x.c +@@ -157,6 +157,8 @@ static void xhints(void); + static int xloadcolor(int, const char *, Color *); + static int xloadfont(Font *, FcPattern *); + static void xloadfonts(const char *, double); ++static int xloadsparefont(FcPattern *, int); ++static void xloadsparefonts(void); + static void xunloadfont(Font *); + static void xunloadfonts(void); + static void xsetenv(void); +@@ -306,6 +308,7 @@ zoomabs(const Arg *arg) + { + xunloadfonts(); + xloadfonts(usedfont, arg->f); ++ xloadsparefonts(); + cresize(0, 0); + redraw(); + xhints(); +@@ -1050,6 +1053,101 @@ xloadfonts(const char *fontstr, double fontsize) + FcPatternDestroy(pattern); + } + ++int ++xloadsparefont(FcPattern *pattern, int flags) ++{ ++ FcPattern *match; ++ FcResult result; ++ ++ match = FcFontMatch(NULL, pattern, &result); ++ if (!match) { ++ return 1; ++ } ++ ++ if (!(frc[frclen].font = XftFontOpenPattern(xw.dpy, match))) { ++ FcPatternDestroy(match); ++ return 1; ++ } ++ ++ frc[frclen].flags = flags; ++ /* Believe U+0000 glyph will present in each default font */ ++ frc[frclen].unicodep = 0; ++ frclen++; ++ ++ return 0; ++} ++ ++void ++xloadsparefonts(void) ++{ ++ FcPattern *pattern; ++ double sizeshift, fontval; ++ int fc; ++ char **fp; ++ ++ if (frclen != 0) ++ die("can't embed spare fonts. cache isn't empty"); ++ ++ /* Calculate count of spare fonts */ ++ fc = sizeof(font2) / sizeof(*font2); ++ if (fc == 0) ++ return; ++ ++ /* Allocate memory for cache entries. */ ++ if (frccap < 4 * fc) { ++ frccap += 4 * fc - frccap; ++ frc = xrealloc(frc, frccap * sizeof(Fontcache)); ++ } ++ ++ for (fp = font2; fp - font2 < fc; ++fp) { ++ ++ if (**fp == '-') ++ pattern = XftXlfdParse(*fp, False, False); ++ else ++ pattern = FcNameParse((FcChar8 *)*fp); ++ ++ if (!pattern) ++ die("can't open spare font %s\n", *fp); ++ ++ if (defaultfontsize > 0) { ++ sizeshift = usedfontsize - defaultfontsize; ++ if (sizeshift != 0 && ++ FcPatternGetDouble(pattern, FC_PIXEL_SIZE, 0, &fontval) == ++ FcResultMatch) { ++ fontval += sizeshift; ++ FcPatternDel(pattern, FC_PIXEL_SIZE); ++ FcPatternDel(pattern, FC_SIZE); ++ FcPatternAddDouble(pattern, FC_PIXEL_SIZE, fontval); ++ } ++ } ++ ++ FcPatternAddBool(pattern, FC_SCALABLE, 1); ++ ++ FcConfigSubstitute(NULL, pattern, FcMatchPattern); ++ XftDefaultSubstitute(xw.dpy, xw.scr, pattern); ++ ++ if (xloadsparefont(pattern, FRC_NORMAL)) ++ die("can't open spare font %s\n", *fp); ++ ++ FcPatternDel(pattern, FC_SLANT); ++ FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ITALIC); ++ if (xloadsparefont(pattern, FRC_ITALIC)) ++ die("can't open spare font %s\n", *fp); ++ ++ FcPatternDel(pattern, FC_WEIGHT); ++ FcPatternAddInteger(pattern, FC_WEIGHT, FC_WEIGHT_BOLD); ++ if (xloadsparefont(pattern, FRC_ITALICBOLD)) ++ die("can't open spare font %s\n", *fp); ++ ++ FcPatternDel(pattern, FC_SLANT); ++ FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ROMAN); ++ if (xloadsparefont(pattern, FRC_BOLD)) ++ die("can't open spare font %s\n", *fp); ++ ++ FcPatternDestroy(pattern); ++ } ++} ++ + void + xunloadfont(Font *f) + { +@@ -1147,6 +1245,9 @@ xinit(int cols, int rows) + usedfont = (opt_font == NULL)? font : opt_font; + xloadfonts(usedfont, 0); + ++ /* spare fonts */ ++ xloadsparefonts(); ++ + /* colors */ + xw.cmap = XDefaultColormap(xw.dpy, xw.scr); + xloadcols(); +-- +2.46.0 + diff --git a/.config/paru/pkg_config/st/patches/0002-Apply-dynamic-cursor-color-0.9.diff b/.config/paru/pkg_config/st/patches/0002-Apply-dynamic-cursor-color-0.9.diff new file mode 100644 index 0000000..e558a61 --- /dev/null +++ b/.config/paru/pkg_config/st/patches/0002-Apply-dynamic-cursor-color-0.9.diff @@ -0,0 +1,49 @@ +From da058d34a98027a1c7fb28a1552932687307fb65 Mon Sep 17 00:00:00 2001 +From: A Farzat +Date: Sun, 31 Dec 2023 09:50:11 +0900 +Subject: [PATCH 2/4] Apply dynamic-cursor-color-0.9 + +--- + x.c | 17 ++++++++++++++--- + 1 file changed, 14 insertions(+), 3 deletions(-) + +diff --git a/x.c b/x.c +index 2f2180c..fef7f65 100644 +--- a/x.c ++++ b/x.c +@@ -1624,6 +1624,7 @@ void + xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og) + { + Color drawcol; ++ XRenderColor colbg; + + /* remove the old cursor */ + if (selected(ox, oy)) +@@ -1652,11 +1653,21 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og) + if (selected(cx, cy)) { + g.fg = defaultfg; + g.bg = defaultrcs; ++ } else if (!(og.mode & ATTR_REVERSE)) { ++ unsigned long col = g.bg; ++ g.bg = g.fg; ++ g.fg = col; ++ } ++ ++ if (IS_TRUECOL(g.bg)) { ++ colbg.alpha = 0xffff; ++ colbg.red = TRUERED(g.bg); ++ colbg.green = TRUEGREEN(g.bg); ++ colbg.blue = TRUEBLUE(g.bg); ++ XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &colbg, &drawcol); + } else { +- g.fg = defaultbg; +- g.bg = defaultcs; ++ drawcol = dc.col[g.bg]; + } +- drawcol = dc.col[g.bg]; + } + + /* draw the new one */ +-- +2.46.0 + diff --git a/.config/paru/pkg_config/st/patches/0003-Apply-alpha-0.8.5-modified.diff b/.config/paru/pkg_config/st/patches/0003-Apply-alpha-0.8.5-modified.diff new file mode 100644 index 0000000..747160a --- /dev/null +++ b/.config/paru/pkg_config/st/patches/0003-Apply-alpha-0.8.5-modified.diff @@ -0,0 +1,143 @@ +From cd3fb2a876303aa6e7a5c430173cba209a052981 Mon Sep 17 00:00:00 2001 +From: A Farzat +Date: Sun, 31 Dec 2023 09:55:29 +0900 +Subject: [PATCH 3/4] Apply alpha-0.8.5 modified + +--- + config.def.h | 3 +++ + config.mk | 2 +- + st.h | 1 + + x.c | 34 ++++++++++++++++++++++++---------- + 4 files changed, 29 insertions(+), 11 deletions(-) + +diff --git a/config.def.h b/config.def.h +index 1dd5a9b..4a60638 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -99,6 +99,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/config.mk b/config.mk +index fdc29a7..069a6c2 100644 +--- a/config.mk ++++ b/config.mk +@@ -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 --git a/st.h b/st.h +index fd3b0d8..9f91e2a 100644 +--- a/st.h ++++ b/st.h +@@ -124,3 +124,4 @@ extern unsigned int tabspaces; + extern unsigned int defaultfg; + extern unsigned int defaultbg; + extern unsigned int defaultcs; ++extern float alpha; +diff --git a/x.c b/x.c +index fef7f65..9a76f95 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; +@@ -755,7 +756,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); + +@@ -815,6 +816,11 @@ xloadcols(void) + else + die("could not allocate color %d\n", i); + } ++ ++ /* set alpha value of bg color */ ++ 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; + } + +@@ -1232,11 +1238,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()) +@@ -1249,7 +1267,7 @@ xinit(int cols, int rows) + xloadsparefonts(); + + /* colors */ +- xw.cmap = XDefaultColormap(xw.dpy, xw.scr); ++ xw.cmap = XCreateColormap(xw.dpy, parent, xw.vis, None); + xloadcols(); + + /* adjust fixed window geometry */ +@@ -1270,10 +1288,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) +@@ -1281,10 +1297,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); + +-- +2.46.0 + diff --git a/.config/paru/pkg_config/st/patches/0004-Apply-changealpha-0.1-modified.diff b/.config/paru/pkg_config/st/patches/0004-Apply-changealpha-0.1-modified.diff new file mode 100644 index 0000000..3886ae9 --- /dev/null +++ b/.config/paru/pkg_config/st/patches/0004-Apply-changealpha-0.1-modified.diff @@ -0,0 +1,75 @@ +From ce788c4b745653bb3d74eb8dc3ec1312bb97ee57 Mon Sep 17 00:00:00 2001 +From: A Farzat +Date: Sun, 31 Dec 2023 09:56:43 +0900 +Subject: [PATCH 4/4] Apply changealpha-0.1 modified + +--- + config.def.h | 2 ++ + st.1 | 6 ++++++ + x.c | 13 +++++++++++++ + 3 files changed, 21 insertions(+) + +diff --git a/config.def.h b/config.def.h +index 4a60638..b76cb0e 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -202,6 +202,8 @@ static Shortcut shortcuts[] = { + { ControlMask, XK_Print, toggleprinter, {.i = 0} }, + { ShiftMask, XK_Print, printscreen, {.i = 0} }, + { XK_ANY_MOD, XK_Print, printsel, {.i = 0} }, ++ { TERMMOD, XK_F11, changealpha, {.f = -0.05} }, ++ { TERMMOD, XK_F12, changealpha, {.f = +0.05} }, + { TERMMOD, XK_Prior, zoom, {.f = +1} }, + { TERMMOD, XK_Next, zoom, {.f = -1} }, + { TERMMOD, XK_Home, zoomreset, {.f = 0} }, +diff --git a/st.1 b/st.1 +index 39120b4..ef18153 100644 +--- a/st.1 ++++ b/st.1 +@@ -151,6 +151,12 @@ Decrease font size. + .B Ctrl-Shift-Home + Reset to default font size. + .TP ++.B Ctrl-Shift-F11 ++Decrease the opacity by 0.05. ++.TP ++.B Ctrl-Shift-F12 ++Increase the opacity by 0.05. ++.TP + .B Ctrl-Shift-y + Paste from primary selection (middle mouse button). + .TP +diff --git a/x.c b/x.c +index 9a76f95..9e75b23 100644 +--- a/x.c ++++ b/x.c +@@ -55,6 +55,7 @@ static void clipcopy(const Arg *); + static void clippaste(const Arg *); + static void numlock(const Arg *); + static void selpaste(const Arg *); ++static void changealpha(const Arg *); + static void zoom(const Arg *); + static void zoomabs(const Arg *); + static void zoomreset(const Arg *); +@@ -295,6 +296,18 @@ numlock(const Arg *dummy) + win.mode ^= MODE_NUMLOCK; + } + ++void ++changealpha(const Arg *arg) ++{ ++ alpha += arg->f; ++ LIMIT(alpha, 0, 1); ++ ++ dc.col[defaultbg].color.alpha = (unsigned short)(0xffff * alpha); ++ /* Required to remove artifacting from borderpx */ ++ cresize(0, 0); ++ redraw(); ++} ++ + void + zoom(const Arg *arg) + { +-- +2.46.0 + -- cgit v1.2.3-70-g09d2