From 99903c67d92ab500d77361b5a35fe0651577506d Mon Sep 17 00:00:00 2001 From: bakkeby Date: Mon, 15 Feb 2021 14:37:37 +0100 Subject: [PATCH] Adding alpha gradient patch --- README.md | 6 ++++++ config.def.h | 4 ++++ config.mk | 6 +++--- x.c | 7 +++++++ 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f236b85..b99f19c 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,8 @@ Refer to [https://st.suckless.org/](https://st.suckless.org/) for details on the ### Changelog: +2021-02-15 - Added the alpha gradient patch + 2020-11-14 - Added the wide glyphs patch 2020-10-23 - Added the monochrome patch @@ -99,6 +101,10 @@ Refer to [https://st.suckless.org/](https://st.suckless.org/) for details on the - [~force-redraw-after-keypress~](https://lists.suckless.org/hackers/2004/17221.html) - ~this patch forces the terminal to check for new data on the tty on keypress with the aim of reducing input latency~ + - [gradient](https://st.suckless.org/patches/gradient/) + - adds gradient transparency to st + - depends on the alpha patch + - [hidecursor](https://st.suckless.org/patches/hidecursor/) - hides the X cursor whenever a key is pressed and show it back when the mouse is moved in the terminal window diff --git a/config.def.h b/config.def.h index 62a1217..91d0d2d 100644 --- a/config.def.h +++ b/config.def.h @@ -124,6 +124,10 @@ unsigned int tabspaces = 8; #if ALPHA_PATCH /* bg opacity */ float alpha = 0.8; +#if ALPHA_GRADIENT_PATCH +float grad_alpha = 0.54; //alpha value that'll change +float stat_alpha = 0.46; //constant alpha value that'll get added to grad_alpha +#endif // ALPHA_GRADIENT_PATCH #endif // ALPHA_PATCH /* Terminal colors (16 first used in escape sequence) */ diff --git a/config.mk b/config.mk index e46ac6a..f49fc6b 100644 --- a/config.mk +++ b/config.mk @@ -13,7 +13,7 @@ X11LIB = /usr/X11R6/lib PKG_CONFIG = pkg-config # Uncomment this for the alpha patch / ALPHA_PATCH -#XRENDER = -lXrender +XRENDER = -lXrender # Uncomment this for the themed cursor patch / THEMED_CURSOR_PATCH #XCURSOR = -lXcursor @@ -36,8 +36,8 @@ STLDFLAGS = $(LIBS) $(LDFLAGS) # OpenBSD: #CPPFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=600 -D_BSD_SOURCE #LIBS = -L$(X11LIB) -lm -lX11 -lutil -lXft \ -# `$(PKG_CONFIG) --libs fontconfig` \ -# `$(PKG_CONFIG) --libs freetype2` +# `pkg-config --libs fontconfig` \ +# `pkg-config --libs freetype2` # compiler and linker # CC = c99 diff --git a/x.c b/x.c index cb82826..e5b17a6 100644 --- a/x.c +++ b/x.c @@ -1729,6 +1729,13 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i } #endif // INVERT_PATCH + #if ALPHA_PATCH && ALPHA_GRADIENT_PATCH + // gradient + bg->color.alpha = grad_alpha * 0xffff * (win.h - y*win.ch) / win.h + stat_alpha * 0xffff; + // uncomment to invert the gradient + // bg->color.alpha = grad_alpha * 0xffff * (y*win.ch) / win.h + stat_alpha * 0xffff; + #endif // ALPHA_PATCH | ALPHA_GRADIENT_PATCH + #if WIDE_GLYPHS_PATCH if (dmode & DRAW_BG) { #endif // WIDE_GLYPHS_PATCH