[wiki] [sites] [st][patch][alpha-focus-highlight] update patch, add patch version for st-0.8.3 || Julius Huelsmann

From: <git_AT_suckless.org>
Date: Mon, 01 Jun 2020 19:05:09 +0200

commit bba7f8d8ed4cd694718747b29429cdae3feead7a
Author: Julius Huelsmann <juliusHuelsmann_AT_gmail.com>
Date: Mon Jun 1 19:02:13 2020 +0200

    [st][patch][alpha-focus-highlight] update patch, add patch version for st-0.8.3

diff --git a/st.suckless.org/patches/alpha_focus_highlight/alphaFocus.gif b/st.suckless.org/patches/alpha_focus_highlight/alphaFocus.gif
deleted file mode 100644
index b152f093..00000000
Binary files a/st.suckless.org/patches/alpha_focus_highlight/alphaFocus.gif and /dev/null differ
diff --git a/st.suckless.org/patches/alpha_focus_highlight/index.md b/st.suckless.org/patches/alpha_focus_highlight/index.md
index b7075d8c..c63bc0b8 100644
--- a/st.suckless.org/patches/alpha_focus_highlight/index.md
+++ b/st.suckless.org/patches/alpha_focus_highlight/index.md
_AT_@ -1,81 +1,88 @@
-Alpha Focus Highlight Patch
-===========================
-
-Description
------------
-This patch allows the user to specify two distinct opacity values; one for the
-focused- and one for unfocused windows' background. This enables the user to
-spot the focused window at a glance.
-
-The *Alpha Highlight Focus Patch* patch is based on the
-[Alpha Patch](https://st.suckless.org/patches/alpha/),
-which is already applied in the patch file below. Most of the work has been performed by the
-original authors of the Alpha Patch.
-
-Screenshot
-----------
-![Screenshot](alphaFocus.gif)
-
-Contributions + Bug Reports
----------------------------
-* [Issues](https://github.com/juliusHuelsmann/st/issues?q=is%3Aopen+is%3Aissue+label%3AalphaFocusHighlight)
-
-
-Notes Alpha Patch
------------------
-* Note that *you need an X composite manager* (e.g. compton, xcompmgr) to make
- this patch effective.
-* The alpha value affects the default background only.
-* The color designated by 'defaultbg' should not be used elsewhere.
-* Embedding might fail after applying this patch.
-
-
-Notes
------
-* In i3WM, the focus event is triggered twice for one specific window on a workspace (root);
- hence the alpha values are applied twice which appears as blinking.
-* The patch is applied both to a non-patched version and to a patched version of st
- and can be tried out [here](https://github.com/juliusHuelsmann/st).
-
-
-Download
------------------------------------
-
-## Based on commit `2b8333f` of `st` (Okt 2019).
-*All versions (from old to new)*:
-* [Version 1.0 (attached)](st-alphafocushighlight-20191107-2b8333f.diff)
-* [Version 1.0 (Github)](https://github.com/juliusHuelsmann/st/releases/download/patchesV3/st-alphaFocusHighlight-20191107-2b8333f.diff)
-* [Version1.1 (attached)](st-alphaFocusHighlight-20191218-2b8333f.diff)
-* [Version1.1 (Github)](https://github.com/juliusHuelsmann/st/releases/download/patchesV3/st-alphaFocusHighlight-20191218-2b8333f.diff)
-* [Version1.2 (attached)](st-alphaFocusHighlight-20200212-2b8333f.diff)
-* [Version1.2 (Github)](https://github.com/juliusHuelsmann/st/releases/download/patchesV3/st-alphaFocusHighlight-20200212-2b8333f.diff)
-
-*Most Recent*:
-* [st-alphaFocusHighlight-20200212-2b8333f.diff (Github)](https://github.com/juliusHuelsmann/st/releases/download/patchesV3/st-alphaFocusHighlight-20200212-2b8333f.diff)
-
-## Based on commit `cd78575` of `st` (February 2020).
-*All versions (from old to new)*:
-* [Version 1.2 (attached)](st-alphaFocusHighlight-20200216-26cdfeb.diff)
-
-*Most Recent*:
-* [st-alphaFocusHighlight-20200216-26cdfeb.diff (Github)](https://github.com/juliusHuelsmann/st/releases/download/patchesV3/st-alphaFocusHighlight-20200216-26cdfeb.diff)
-
-Note that patch errors can occur when the code in the st repo is updated. Please report [an
-Issue](https://github.com/juliusHuelsmann/st/issues) or contribute a merged patch in that case.
-
-Authors of the Alpha Patch
---------------------------
-* Eon S. Jeon - <esjeon_AT_hyunmu.am>
-* pr - <protodev_AT_gmx.net> (0.5 port)
-* Laslo Hunhold - <dev_AT_frign.de> (0.6, git ports)
-* Ivan J. - <parazyd_AT_dyne.org> (git port)
-* Matthew Parnell - <matt_AT_parnmatt.co.uk> (0.7 port)
-* Johannes Mayrhofer - <jm.spam_AT_gmx.net> (0.8.1 port)
-* Àlex Ramírez <aramirez_AT_posteo.net> (0.8.1 pre-multiplication fix).
-
-
-Authors of the Alpha-Focus Patch
---------------------------------
-* [Julius Hülsmann](https://github.com/juliusHuelsmann) - <juliusHuelsmann [at] gmail [dot] com>
+Patch for suckless' simple terminal (`st`), which allows the user to specify two distinct opacity
+values / background colors; one for the focused- and one for unfocused windows' background.
+This enables the user to spot the focused window at a glance.
+The patch is based on the [alpha patch](https://st.suckless.org/patches/alpha/); i.e. is to be
+applied after applying the alpha patch.
+
+The patch is released [on this release page](https://github.com/juliusHuelsmann/st/releases) and
+[on the suckless page](https://st.suckless.org/patches/alpha_focus_highlight/).
+Please [leave a star](https://github.com/juliusHuelsmann/st-focus).
+
+## Contributions & Bug Reports
+* [Report / Solve Patching issues](https://github.com/juliusHuelsmann/st) with a new version of `st`
+* [Contributions and Bug reports](https://github.com/juliusHuelsmann/st-focus)
+
+## Building, customizing and installing the patch
+**1. Optional Dependencies**
+The opacity functionality of this patch requires an `X composite manager` (e.g. `picom`, `compton`,
+`xcompmgr`), which can for instance be installed via `sudo pacman -S picom` on Arch Linux and
+launched via `picom -b`. *The composite manager has to be relaunched after booting*.
+
+**2. Applying the patch**
+Apply the patch to `st`'s source code and build code via `patch < [PATCH_NAME]`
+
+**3. Customization**
+This patch performs changes in the `config.def.h` file, which need to be manually merged into a
+pre-existing custom `config.h` file. The following four variables can be adapted:
+- `alpha`/`alphaUnfocused` opacity of the terminal when focused / not focused.
+- `bg`/`bgUnfocused` background color when focused / not focused.
+
+**4. Build & install** `make; sudo make install`
+
+## Download
+If you want to try out the current version of the patch before patching your own build,
+check out [this repository](https://github.com/juliusHuelsmann/st), which contains a
+merged version of this patch with a reasonable configuration.
+
+The patch comes
+1. merged into the alpha patch (`alpha + focus`) or
+2. for patching on top of an already applied alpha patch (`focus`)
+
+I recommend downloading the alpha patch from the
+[alpha patch](https://st.suckless.org/patches/alpha/) page and using `Patch: focus`, that way you
+make sure that you apply the latest version of the alpha patch.
+
+Note that patch errors can occur when the code in the st repo is updated.
+Please report an Issue or contribute a merged patch in that case.
+
+### Patch: alpha + focus
+
+
+**st-0.8.3**
+- [Version 1 (attached)](st-focus-20200530-43a395a.diff)
+- Most recent release: [st-focus-20200530-43a395a.diff Github](https://github.com/juliusHuelsmann/st/releases/download/v2/st-focus-20200530-43a395a.diff)
+
+---
+
+### Patch: focus
+
+**st-0.8.3**
+- [Version 1 (attached)](st-focus-20200530-patch_alpha.diff)
+- Most recent release: [st-focus-20200530-patch_alpha.diff (Github)](https://github.com/juliusHuelsmann/st/releases/download/v2/st-focus-20200530-patch_alpha.diff)
+
+
+## MISC
+**Note:** The benefit of the `alpha` patch and the `Alpha Focus Highlight` patch are the ability to
+restrict the transparency only to the background color currently in use, hence keeping the font in
+the foreground solid and readable.
+
+If the goal is to apply transparency independent on the content, you do not require any patch for
+`st`, instead add
+`
+inactive-opacity = 0.2;
+active-opacity = 0.8;
+`
+to your `picom` configuration file and keep a vanilla `st` build.
+
+If you want to configure `inactive-opacity` and `active-opacity` rules in order to apply opacity to
+other applications, but keep the benefits of the st alpha patches, have a look at
+[this picom configuration
+file](https://github.com/juliusHuelsmann/Config/blob/master/.config/picom/picom.conf),
+in which opacity management configured to be performed by `st`.
+
+# Authors / Contributors
+* Julius Hülsmann - <juliusHuelsmann [at] gmail [dot] com>
 * [glpub](https://github.com/glpub): Fix: erroneous color reset
-* [Milos Stojanovic](https://github.com/M4444): Code formatting fix
+* [Milos Stojanovic](https://github.com/M4444): Code Formatting
+* [Yui](https://github.com/yuwui): Fix spelling errors
+* Authors of the shipped alpha patch: [Eon S. Jeon](esjeon_AT_hyunmu.am), [pr](protodev_AT_gmx.net), [Laslo Hunhold](dev_AT_frign.de), [Ivan J.](parazyd_AT_dyne.org), [Matthew Parnell](matt_AT_parnmatt.co.uk), [Johannes Mayrhofer](jm.spam_AT_gmx.net), [Àlex Ramírez](aramirez_AT_posteo.net)
diff --git a/st.suckless.org/patches/alpha_focus_highlight/st-alphaFocusHighlight-20191218-2b8333f.diff b/st.suckless.org/patches/alpha_focus_highlight/st-alphaFocusHighlight-20191218-2b8333f.diff
deleted file mode 100644
index 2caa1fd0..00000000
--- a/st.suckless.org/patches/alpha_focus_highlight/st-alphaFocusHighlight-20191218-2b8333f.diff
+++ /dev/null
_AT_@ -1,316 +0,0 @@
-From 49fbc3f0a3d3524fa37ba4c0129425394b84feed Mon Sep 17 00:00:00 2001
-From: Julius Huelsmann <juliusHuelsmann_AT_gmail.com>
-Date: Wed, 6 Nov 2019 21:59:28 +0100
-Subject: [PATCH 1/2] [PATCH:FOCUS]: first version
-
----
- config.def.h |  7 ++++++-
- config.mk    |  2 +-
- st.h         |  2 ++
- x.c          | 59 +++++++++++++++++++++++++++++++++++++++-------------
- 4 files changed, 54 insertions(+), 16 deletions(-)
-
-diff --git a/config.def.h b/config.def.h
-index 6ebea98..16f1ebd 100644
---- a/config.def.h
-+++ b/config.def.h
-_AT_@ -82,6 +82,10 @@ char *termname = "st-256color";
-  */
- unsigned int tabspaces = 8;
- 
-+/* bg opacity */
-+float alpha = 0.8;           //< alpha value used when the window is focused.
-+float alphaUnfocussed = 0.6; //< alpha value used when the focus is lost
-+
- /* Terminal colors (16 first used in escape sequence) */
- static const char *colorname[] = {
- 	/* 8 normal colors */
-_AT_@ -109,6 +113,7 @@ static const char *colorname[] = {
- 	/* more colors can be added after 255 to use with DefaultXX */
- 	"#cccccc",
- 	"#555555",
-+	"black",
- };
- 
- 
-_AT_@ -117,7 +122,7 @@ static const char *colorname[] = {
-  * foreground, background, cursor, reverse cursor
-  */
- unsigned int defaultfg = 7;
--unsigned int defaultbg = 0;
-+unsigned int defaultbg = 258;
- static unsigned int defaultcs = 256;
- static unsigned int defaultrcs = 257;
- 
-diff --git a/config.mk b/config.mk
-index 0cbb002..1d2f0e2 100644
---- a/config.mk
-+++ b/config.mk
-_AT_@ -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 4da3051..0bc69f8 100644
---- a/st.h
-+++ b/st.h
-_AT_@ -120,3 +120,5 @@ extern char *termname;
- extern unsigned int tabspaces;
- extern unsigned int defaultfg;
- extern unsigned int defaultbg;
-+extern float alpha;
-+extern float alphaUnfocussed;
-diff --git a/x.c b/x.c
-index 5828a3b..45bc960 100644
---- a/x.c
-+++ b/x.c
-_AT_@ -4,6 +4,7 @@
- #include <limits.h>
- #include <locale.h>
- #include <signal.h>
-+#include <stdbool.h>
- #include <sys/select.h>
- #include <time.h>
- #include <unistd.h>
-_AT_@ -98,6 +99,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;
-_AT_@ -233,6 +235,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;
-_AT_@ -241,6 +244,7 @@ static char *opt_io    = NULL;
- static char *opt_line  = NULL;
- static char *opt_name  = NULL;
- static char *opt_title = NULL;
-+static bool focused = true;
- 
- static int oldbutton = 3; /* button event on startup: 3 = release */
- 
-_AT_@ -692,7 +696,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);
- 
-_AT_@ -752,6 +756,14 @@ xloadcols(void)
- 			else
- 				die("could not allocate color %d
", i);
- 		}
-+
-+	/* set alpha value of bg color */
-+	if (opt_alpha)
-+		alpha = strtof(opt_alpha, NULL);
-+	float const usedAlpha = focused ? alpha : alphaUnfocussed;
-+	dc.col[defaultbg].color.alpha = (unsigned short)(0xffff * usedAlpha);
-+	dc.col[defaultbg].pixel &= 0x00FFFFFF;
-+	dc.col[defaultbg].pixel |= (unsigned char)(0xff * usedAlpha) << 24;
- 	loaded = 1;
- }
- 
-_AT_@ -1044,11 +1056,23 @@ xinit(int cols, int rows)
- 	Window parent;
- 	pid_t thispid = getpid();
- 	XColor xmousefg, xmousebg;
-+	XWindowAttributes attr;
-+	XVisualInfo vis;
- 
- 	if (!(xw.dpy = XOpenDisplay(NULL)))
- 		die("can't open display
");
- 	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())
-_AT_@ -1058,7 +1082,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 */
-_AT_@ -1078,19 +1102,15 @@ xinit(int cols, int rows)
- 		| ButtonMotionMask | ButtonPressMask | ButtonReleaseMask;
- 	xw.attrs.colormap = xw.cmap;
- 
--	if (!(opt_embed && (parent = strtol(opt_embed, NULL, 0))))
--		parent = XRootWindow(xw.dpy, xw.scr);
- 	xw.win = XCreateWindow(xw.dpy, parent, 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);
- 
- 	memset(&gcvalues, 0, sizeof(gcvalues));
- 	gcvalues.graphics_exposures = False;
--	dc.gc = XCreateGC(xw.dpy, parent, 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);
- 
-_AT_@ -1663,13 +1683,21 @@ focus(XEvent *ev)
- 		XSetICFocus(xw.xic);
- 		win.mode |= MODE_FOCUSED;
- 		xseturgency(0);
--		if (IS_SET(MODE_FOCUS))
--			ttywrite("", 3, 0);
-+		if (IS_SET(MODE_FOCUS)) { ttywrite("", 3, 0); }
-+		if (!focused) {
-+			focused = true;
-+			xloadcols();
-+			redraw();
-+		}
- 	} else {
- 		XUnsetICFocus(xw.xic);
- 		win.mode &= ~MODE_FOCUSED;
--		if (IS_SET(MODE_FOCUS))
--			ttywrite("", 3, 0);
-+		if (IS_SET(MODE_FOCUS)) { ttywrite("", 3, 0); }
-+		if (focused) {
-+			focused = false;
-+			xloadcols();
-+			redraw();
-+		}
- 	}
- }
- 
-_AT_@ -1925,6 +1953,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;
--- 
-2.24.1
-
-
-From b442038e2f28b427f044a6bbd80481251ab532ad Mon Sep 17 00:00:00 2001
-From: "gloom _AT_ t440p" <gloom_AT_t440p>
-Date: Tue, 17 Dec 2019 18:43:31 +0800
-Subject: [PATCH 2/2] merge: fix: do not reset terminal colors when
- focus/unfocus
-
-when using scripts which changes shell's
-default ANSI colors like base16-shell
-then focus/unfocus should not reset
-foreground colors to default ones
----
- x.c | 34 ++++++++++++++++++++++------------
- 1 file changed, 22 insertions(+), 12 deletions(-)
-
-diff --git a/x.c b/x.c
-index 45bc960..7482adb 100644
---- a/x.c
-+++ b/x.c
-_AT_@ -734,6 +734,20 @@ xloadcolor(int i, const char *name, Color *ncolor)
- 	return XftColorAllocName(xw.dpy, xw.vis, xw.cmap, name, ncolor);
- }
- 
-+void
-+xloadalpha(void)
-+{
-+    /* set alpha value of bg color */
-+    if (opt_alpha)
-+        alpha = strtof(opt_alpha, NULL);
-+
-+    float const usedAlpha = focused ? alpha : alphaUnfocussed;
-+
-+    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)
- {
-_AT_@ -749,7 +763,7 @@ xloadcols(void)
- 		dc.col = xmalloc(dc.collen * sizeof(Color));
- 	}
- 
--	for (i = 0; i < dc.collen; i++)
-+	for (i = 0; i < dc.collen; i++) 
- 		if (!xloadcolor(i, NULL, &dc.col[i])) {
- 			if (colorname[i])
- 				die("could not allocate color '%s'
", colorname[i]);
-_AT_@ -757,13 +771,7 @@ xloadcols(void)
- 				die("could not allocate color %d
", i);
- 		}
- 
--	/* set alpha value of bg color */
--	if (opt_alpha)
--		alpha = strtof(opt_alpha, NULL);
--	float const usedAlpha = focused ? alpha : alphaUnfocussed;
--	dc.col[defaultbg].color.alpha = (unsigned short)(0xffff * usedAlpha);
--	dc.col[defaultbg].pixel &= 0x00FFFFFF;
--	dc.col[defaultbg].pixel |= (unsigned char)(0xff * usedAlpha) << 24;
-+	xloadalpha();
- 	loaded = 1;
- }
- 
-_AT_@ -1683,19 +1691,21 @@ focus(XEvent *ev)
- 		XSetICFocus(xw.xic);
- 		win.mode |= MODE_FOCUSED;
- 		xseturgency(0);
--		if (IS_SET(MODE_FOCUS)) { ttywrite("", 3, 0); }
-+		if (IS_SET(MODE_FOCUS))
-+			ttywrite("", 3, 0);
- 		if (!focused) {
- 			focused = true;
--			xloadcols();
-+			xloadalpha();
- 			redraw();
- 		}
- 	} else {
- 		XUnsetICFocus(xw.xic);
- 		win.mode &= ~MODE_FOCUSED;
--		if (IS_SET(MODE_FOCUS)) { ttywrite("", 3, 0); }
-+		if (IS_SET(MODE_FOCUS))
-+			ttywrite("", 3, 0);
- 		if (focused) {
- 			focused = false;
--			xloadcols();
-+			xloadalpha();
- 			redraw();
- 		}
- 	}
--- 
-2.24.1
-
diff --git a/st.suckless.org/patches/alpha_focus_highlight/st-alphaFocusHighlight-20200212-2b8333f.diff b/st.suckless.org/patches/alpha_focus_highlight/st-alphaFocusHighlight-20200212-2b8333f.diff
deleted file mode 100644
index 80051f7b..00000000
--- a/st.suckless.org/patches/alpha_focus_highlight/st-alphaFocusHighlight-20200212-2b8333f.diff
+++ /dev/null
_AT_@ -1,342 +0,0 @@
-From 49fbc3f0a3d3524fa37ba4c0129425394b84feed Mon Sep 17 00:00:00 2001
-From: Julius Huelsmann <juliusHuelsmann_AT_gmail.com>
-Date: Wed, 6 Nov 2019 21:59:28 +0100
-Subject: [PATCH 1/3] [PATCH:FOCUS]: first version
-
----
- config.def.h |  7 ++++++-
- config.mk    |  2 +-
- st.h         |  2 ++
- x.c          | 59 +++++++++++++++++++++++++++++++++++++++-------------
- 4 files changed, 54 insertions(+), 16 deletions(-)
-
-diff --git a/config.def.h b/config.def.h
-index 6ebea98..16f1ebd 100644
---- a/config.def.h
-+++ b/config.def.h
-_AT_@ -82,6 +82,10 @@ char *termname = "st-256color";
-  */
- unsigned int tabspaces = 8;
- 
-+/* bg opacity */
-+float alpha = 0.8;           //< alpha value used when the window is focused.
-+float alphaUnfocussed = 0.6; //< alpha value used when the focus is lost
-+
- /* Terminal colors (16 first used in escape sequence) */
- static const char *colorname[] = {
- 	/* 8 normal colors */
-_AT_@ -109,6 +113,7 @@ static const char *colorname[] = {
- 	/* more colors can be added after 255 to use with DefaultXX */
- 	"#cccccc",
- 	"#555555",
-+	"black",
- };
- 
- 
-_AT_@ -117,7 +122,7 @@ static const char *colorname[] = {
-  * foreground, background, cursor, reverse cursor
-  */
- unsigned int defaultfg = 7;
--unsigned int defaultbg = 0;
-+unsigned int defaultbg = 258;
- static unsigned int defaultcs = 256;
- static unsigned int defaultrcs = 257;
- 
-diff --git a/config.mk b/config.mk
-index 0cbb002..1d2f0e2 100644
---- a/config.mk
-+++ b/config.mk
-_AT_@ -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 4da3051..0bc69f8 100644
---- a/st.h
-+++ b/st.h
-_AT_@ -120,3 +120,5 @@ extern char *termname;
- extern unsigned int tabspaces;
- extern unsigned int defaultfg;
- extern unsigned int defaultbg;
-+extern float alpha;
-+extern float alphaUnfocussed;
-diff --git a/x.c b/x.c
-index 5828a3b..45bc960 100644
---- a/x.c
-+++ b/x.c
-_AT_@ -4,6 +4,7 @@
- #include <limits.h>
- #include <locale.h>
- #include <signal.h>
-+#include <stdbool.h>
- #include <sys/select.h>
- #include <time.h>
- #include <unistd.h>
-_AT_@ -98,6 +99,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;
-_AT_@ -233,6 +235,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;
-_AT_@ -241,6 +244,7 @@ static char *opt_io    = NULL;
- static char *opt_line  = NULL;
- static char *opt_name  = NULL;
- static char *opt_title = NULL;
-+static bool focused = true;
- 
- static int oldbutton = 3; /* button event on startup: 3 = release */
- 
-_AT_@ -692,7 +696,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);
- 
-_AT_@ -752,6 +756,14 @@ xloadcols(void)
- 			else
- 				die("could not allocate color %d
", i);
- 		}
-+
-+	/* set alpha value of bg color */
-+	if (opt_alpha)
-+		alpha = strtof(opt_alpha, NULL);
-+	float const usedAlpha = focused ? alpha : alphaUnfocussed;
-+	dc.col[defaultbg].color.alpha = (unsigned short)(0xffff * usedAlpha);
-+	dc.col[defaultbg].pixel &= 0x00FFFFFF;
-+	dc.col[defaultbg].pixel |= (unsigned char)(0xff * usedAlpha) << 24;
- 	loaded = 1;
- }
- 
-_AT_@ -1044,11 +1056,23 @@ xinit(int cols, int rows)
- 	Window parent;
- 	pid_t thispid = getpid();
- 	XColor xmousefg, xmousebg;
-+	XWindowAttributes attr;
-+	XVisualInfo vis;
- 
- 	if (!(xw.dpy = XOpenDisplay(NULL)))
- 		die("can't open display
");
- 	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())
-_AT_@ -1058,7 +1082,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 */
-_AT_@ -1078,19 +1102,15 @@ xinit(int cols, int rows)
- 		| ButtonMotionMask | ButtonPressMask | ButtonReleaseMask;
- 	xw.attrs.colormap = xw.cmap;
- 
--	if (!(opt_embed && (parent = strtol(opt_embed, NULL, 0))))
--		parent = XRootWindow(xw.dpy, xw.scr);
- 	xw.win = XCreateWindow(xw.dpy, parent, 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);
- 
- 	memset(&gcvalues, 0, sizeof(gcvalues));
- 	gcvalues.graphics_exposures = False;
--	dc.gc = XCreateGC(xw.dpy, parent, 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);
- 
-_AT_@ -1663,13 +1683,21 @@ focus(XEvent *ev)
- 		XSetICFocus(xw.xic);
- 		win.mode |= MODE_FOCUSED;
- 		xseturgency(0);
--		if (IS_SET(MODE_FOCUS))
--			ttywrite("", 3, 0);
-+		if (IS_SET(MODE_FOCUS)) { ttywrite("", 3, 0); }
-+		if (!focused) {
-+			focused = true;
-+			xloadcols();
-+			redraw();
-+		}
- 	} else {
- 		XUnsetICFocus(xw.xic);
- 		win.mode &= ~MODE_FOCUSED;
--		if (IS_SET(MODE_FOCUS))
--			ttywrite("", 3, 0);
-+		if (IS_SET(MODE_FOCUS)) { ttywrite("", 3, 0); }
-+		if (focused) {
-+			focused = false;
-+			xloadcols();
-+			redraw();
-+		}
- 	}
- }
- 
-_AT_@ -1925,6 +1953,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;
--- 
-2.25.0
-
-
-From b442038e2f28b427f044a6bbd80481251ab532ad Mon Sep 17 00:00:00 2001
-From: "gloom _AT_ t440p" <gloom_AT_t440p>
-Date: Tue, 17 Dec 2019 18:43:31 +0800
-Subject: [PATCH 2/3] merge: fix: do not reset terminal colors when
- focus/unfocus
-
-when using scripts which changes shell's
-default ANSI colors like base16-shell
-then focus/unfocus should not reset
-foreground colors to default ones
----
- x.c | 34 ++++++++++++++++++++++------------
- 1 file changed, 22 insertions(+), 12 deletions(-)
-
-diff --git a/x.c b/x.c
-index 45bc960..7482adb 100644
---- a/x.c
-+++ b/x.c
-_AT_@ -734,6 +734,20 @@ xloadcolor(int i, const char *name, Color *ncolor)
- 	return XftColorAllocName(xw.dpy, xw.vis, xw.cmap, name, ncolor);
- }
- 
-+void
-+xloadalpha(void)
-+{
-+    /* set alpha value of bg color */
-+    if (opt_alpha)
-+        alpha = strtof(opt_alpha, NULL);
-+
-+    float const usedAlpha = focused ? alpha : alphaUnfocussed;
-+
-+    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)
- {
-_AT_@ -749,7 +763,7 @@ xloadcols(void)
- 		dc.col = xmalloc(dc.collen * sizeof(Color));
- 	}
- 
--	for (i = 0; i < dc.collen; i++)
-+	for (i = 0; i < dc.collen; i++) 
- 		if (!xloadcolor(i, NULL, &dc.col[i])) {
- 			if (colorname[i])
- 				die("could not allocate color '%s'
", colorname[i]);
-_AT_@ -757,13 +771,7 @@ xloadcols(void)
- 				die("could not allocate color %d
", i);
- 		}
- 
--	/* set alpha value of bg color */
--	if (opt_alpha)
--		alpha = strtof(opt_alpha, NULL);
--	float const usedAlpha = focused ? alpha : alphaUnfocussed;
--	dc.col[defaultbg].color.alpha = (unsigned short)(0xffff * usedAlpha);
--	dc.col[defaultbg].pixel &= 0x00FFFFFF;
--	dc.col[defaultbg].pixel |= (unsigned char)(0xff * usedAlpha) << 24;
-+	xloadalpha();
- 	loaded = 1;
- }
- 
-_AT_@ -1683,19 +1691,21 @@ focus(XEvent *ev)
- 		XSetICFocus(xw.xic);
- 		win.mode |= MODE_FOCUSED;
- 		xseturgency(0);
--		if (IS_SET(MODE_FOCUS)) { ttywrite("", 3, 0); }
-+		if (IS_SET(MODE_FOCUS))
-+			ttywrite("", 3, 0);
- 		if (!focused) {
- 			focused = true;
--			xloadcols();
-+			xloadalpha();
- 			redraw();
- 		}
- 	} else {
- 		XUnsetICFocus(xw.xic);
- 		win.mode &= ~MODE_FOCUSED;
--		if (IS_SET(MODE_FOCUS)) { ttywrite("", 3, 0); }
-+		if (IS_SET(MODE_FOCUS))
-+			ttywrite("", 3, 0);
- 		if (focused) {
- 			focused = false;
--			xloadcols();
-+			xloadalpha();
- 			redraw();
- 		}
- 	}
--- 
-2.25.0
-
-
-From dffad320251fbab67181a005436f320717658cf9 Mon Sep 17 00:00:00 2001
-From: M <mc.cm.mail_AT_gmail.com>
-Date: Sun, 2 Feb 2020 14:20:52 +0100
-Subject: [PATCH 3/3] Remove stray trailing whitespace
-
----
- x.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/x.c b/x.c
-index 7482adb..cfbe64d 100644
---- a/x.c
-+++ b/x.c
-_AT_@ -763,7 +763,7 @@ xloadcols(void)
- 		dc.col = xmalloc(dc.collen * sizeof(Color));
- 	}
- 
--	for (i = 0; i < dc.collen; i++) 
-+	for (i = 0; i < dc.collen; i++)
- 		if (!xloadcolor(i, NULL, &dc.col[i])) {
- 			if (colorname[i])
- 				die("could not allocate color '%s'
", colorname[i]);
--- 
-2.25.0
-
diff --git a/st.suckless.org/patches/alpha_focus_highlight/st-alphaFocusHighlight-20200216-26cdfeb.diff b/st.suckless.org/patches/alpha_focus_highlight/st-alphaFocusHighlight-20200216-26cdfeb.diff
deleted file mode 100644
index 85c744bd..00000000
--- a/st.suckless.org/patches/alpha_focus_highlight/st-alphaFocusHighlight-20200216-26cdfeb.diff
+++ /dev/null
_AT_@ -1,235 +0,0 @@
-From 7538b0b641fa8291b98f65ecc5d140e0e9cc0028 Mon Sep 17 00:00:00 2001
-From: Julius Huelsmann <juliusHuelsmann_AT_gmail.com>
-Date: Sun, 16 Feb 2020 18:36:56 +0100
-Subject: [PATCH] alpha_focus: port patch
-
----
- config.def.h |  7 +++++-
- config.mk    |  2 +-
- st.h         |  2 ++
- x.c          | 61 +++++++++++++++++++++++++++++++++++++++++++---------
- 4 files changed, 60 insertions(+), 12 deletions(-)
-
-diff --git a/config.def.h b/config.def.h
-index 546edda..6c6b928 100644
---- a/config.def.h
-+++ b/config.def.h
-_AT_@ -82,6 +82,10 @@ char *termname = "st-256color";
-  */
- unsigned int tabspaces = 8;
- 
-+/* bg opacity */
-+float alpha = 0.8;           //< alpha value used when the window is focused.
-+float alphaUnfocussed = 0.6; //< alpha value used when the focus is lost
-+
- /* Terminal colors (16 first used in escape sequence) */
- static const char *colorname[] = {
- 	/* 8 normal colors */
-_AT_@ -109,6 +113,7 @@ static const char *colorname[] = {
- 	/* more colors can be added after 255 to use with DefaultXX */
- 	"#cccccc",
- 	"#555555",
-+	"black",
- };
- 
- 
-_AT_@ -117,7 +122,7 @@ static const char *colorname[] = {
-  * foreground, background, cursor, reverse cursor
-  */
- unsigned int defaultfg = 7;
--unsigned int defaultbg = 0;
-+unsigned int defaultbg = 258;
- static unsigned int defaultcs = 256;
- static unsigned int defaultrcs = 257;
- 
-diff --git a/config.mk b/config.mk
-index 0cbb002..1d2f0e2 100644
---- a/config.mk
-+++ b/config.mk
-_AT_@ -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 a1928ca..2009c33 100644
---- a/st.h
-+++ b/st.h
-_AT_@ -121,3 +121,5 @@ extern char *termname;
- extern unsigned int tabspaces;
- extern unsigned int defaultfg;
- extern unsigned int defaultbg;
-+extern float alpha;
-+extern float alphaUnfocussed;
-diff --git a/x.c b/x.c
-index 1f62129..6d6751d 100644
---- a/x.c
-+++ b/x.c
-_AT_@ -4,6 +4,7 @@
- #include <limits.h>
- #include <locale.h>
- #include <signal.h>
-+#include <stdbool.h>
- #include <sys/select.h>
- #include <time.h>
- #include <unistd.h>
-_AT_@ -105,6 +106,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;
-_AT_@ -242,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;
-_AT_@ -250,6 +253,7 @@ static char *opt_io    = NULL;
- static char *opt_line  = NULL;
- static char *opt_name  = NULL;
- static char *opt_title = NULL;
-+static bool focused = true;
- 
- static int oldbutton = 3; /* button event on startup: 3 = release */
- 
-_AT_@ -719,7 +723,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);
- 
-_AT_@ -757,6 +761,20 @@ xloadcolor(int i, const char *name, Color *ncolor)
- 	return XftColorAllocName(xw.dpy, xw.vis, xw.cmap, name, ncolor);
- }
- 
-+void
-+xloadalpha(void)
-+{
-+    /* set alpha value of bg color */
-+    if (opt_alpha)
-+        alpha = strtof(opt_alpha, NULL);
-+
-+    float const usedAlpha = focused ? alpha : alphaUnfocussed;
-+
-+    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)
- {
-_AT_@ -779,6 +797,8 @@ xloadcols(void)
- 			else
- 				die("could not allocate color %d
", i);
- 		}
-+
-+	xloadalpha();
- 	loaded = 1;
- }
- 
-_AT_@ -1089,11 +1109,23 @@ xinit(int cols, int rows)
- 	Window parent;
- 	pid_t thispid = getpid();
- 	XColor xmousefg, xmousebg;
-+	XWindowAttributes attr;
-+	XVisualInfo vis;
- 
- 	if (!(xw.dpy = XOpenDisplay(NULL)))
- 		die("can't open display
");
- 	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())
-_AT_@ -1103,7 +1135,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 */
-_AT_@ -1123,19 +1155,15 @@ xinit(int cols, int rows)
- 		| ButtonMotionMask | ButtonPressMask | ButtonReleaseMask;
- 	xw.attrs.colormap = xw.cmap;
- 
--	if (!(opt_embed && (parent = strtol(opt_embed, NULL, 0))))
--		parent = XRootWindow(xw.dpy, xw.scr);
- 	xw.win = XCreateWindow(xw.dpy, parent, 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);
- 
- 	memset(&gcvalues, 0, sizeof(gcvalues));
- 	gcvalues.graphics_exposures = False;
--	dc.gc = XCreateGC(xw.dpy, parent, 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);
- 
-_AT_@ -1716,12 +1744,22 @@ focus(XEvent *ev)
- 		xseturgency(0);
- 		if (IS_SET(MODE_FOCUS))
- 			ttywrite("", 3, 0);
-+		if (!focused) {
-+			focused = true;
-+			xloadalpha();
-+			redraw();
-+		}
- 	} else {
- 		if (xw.ime.xic)
- 			XUnsetICFocus(xw.ime.xic);
- 		win.mode &= ~MODE_FOCUSED;
- 		if (IS_SET(MODE_FOCUS))
- 			ttywrite("", 3, 0);
-+		if (focused) {
-+			focused = false;
-+			xloadalpha();
-+			redraw();
-+		}
- 	}
- }
- 
-_AT_@ -1980,6 +2018,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;
--- 
-2.25.0
-
diff --git a/st.suckless.org/patches/alpha_focus_highlight/st-alphafocushighlight-20191107-2b8333f.diff b/st.suckless.org/patches/alpha_focus_highlight/st-focus-20200530-43a395a.diff
similarity index 62%
rename from st.suckless.org/patches/alpha_focus_highlight/st-alphafocushighlight-20191107-2b8333f.diff
rename to st.suckless.org/patches/alpha_focus_highlight/st-focus-20200530-43a395a.diff
index 1f74cf9b..5d2c23f9 100644
--- a/st.suckless.org/patches/alpha_focus_highlight/st-alphafocushighlight-20191107-2b8333f.diff
+++ b/st.suckless.org/patches/alpha_focus_highlight/st-focus-20200530-43a395a.diff
_AT_@ -1,31 +1,30 @@
-From 49fbc3f0a3d3524fa37ba4c0129425394b84feed Mon Sep 17 00:00:00 2001
+From f4e9ea055675807817ba3648ee7f2de4cc1d0eca Mon Sep 17 00:00:00 2001
 From: Julius Huelsmann <juliusHuelsmann_AT_gmail.com>
-Date: Wed, 6 Nov 2019 21:59:28 +0100
-Subject: [PATCH] [PATCH:FOCUS]: first version
+Date: Sat, 30 May 2020 12:18:59 +0200
+Subject: [PATCH] patch: focus
 
 ---
- config.def.h |  7 ++++++-
+ config.def.h |  5 +++++
  config.mk    |  2 +-
- st.h         |  2 ++
- x.c          | 59 +++++++++++++++++++++++++++++++++++++++-------------
- 4 files changed, 54 insertions(+), 16 deletions(-)
+ st.h         |  1 +
+ x.c          | 62 +++++++++++++++++++++++++++++++++++++---------------
+ 4 files changed, 51 insertions(+), 19 deletions(-)
 
 diff --git a/config.def.h b/config.def.h
-index 6ebea98..16f1ebd 100644
+index 0895a1f..577d1f1 100644
 --- a/config.def.h
 +++ b/config.def.h
-_AT_@ -82,6 +82,10 @@ char *termname = "st-256color";
+_AT_@ -84,6 +84,9 @@ char *termname = "st-256color";
   */
  unsigned int tabspaces = 8;
  
 +/* bg opacity */
-+float alpha = 0.8;           //< alpha value used when the window is focused.
-+float alphaUnfocussed = 0.6; //< alpha value used when the focus is lost
++float alpha = 0.8, alphaUnfocused = 0.6;
 +
  /* Terminal colors (16 first used in escape sequence) */
  static const char *colorname[] = {
  	/* 8 normal colors */
-_AT_@ -109,6 +113,7 @@ static const char *colorname[] = {
+_AT_@ -111,6 +114,7 @@ static const char *colorname[] = {
  	/* more colors can be added after 255 to use with DefaultXX */
  	"#cccccc",
  	"#555555",
_AT_@ -33,17 +32,16 @@ index 6ebea98..16f1ebd 100644
  };
  
  
-_AT_@ -117,7 +122,7 @@ static const char *colorname[] = {
-  * foreground, background, cursor, reverse cursor
-  */
- unsigned int defaultfg = 7;
--unsigned int defaultbg = 0;
-+unsigned int defaultbg = 258;
+_AT_@ -122,6 +126,7 @@ unsigned int defaultfg = 7;
+ unsigned int defaultbg = 0;
  static unsigned int defaultcs = 256;
  static unsigned int defaultrcs = 257;
++unsigned int bg = 17, bgUnfocused = 16;
  
+ /*
+  * Default shape of cursor
 diff --git a/config.mk b/config.mk
-index 0cbb002..1d2f0e2 100644
+index beafc35..ddc65ae 100644
 --- a/config.mk
 +++ b/config.mk
 _AT_@ -16,7 +16,7 @@ PKG_CONFIG = pkg-config
_AT_@ -56,28 +54,19 @@ index 0cbb002..1d2f0e2 100644
         `$(PKG_CONFIG) --libs freetype2`
  
 diff --git a/st.h b/st.h
-index 4da3051..0bc69f8 100644
+index d978458..b5f1cf6 100644
 --- a/st.h
 +++ b/st.h
-_AT_@ -120,3 +120,5 @@ extern char *termname;
+_AT_@ -122,3 +122,4 @@ extern char *termname;
  extern unsigned int tabspaces;
  extern unsigned int defaultfg;
  extern unsigned int defaultbg;
-+extern float alpha;
-+extern float alphaUnfocussed;
++extern float alpha, alphaUnfocused;
 diff --git a/x.c b/x.c
-index 5828a3b..45bc960 100644
+index e5f1737..2de16cb 100644
 --- a/x.c
 +++ b/x.c
-_AT_@ -4,6 +4,7 @@
- #include <limits.h>
- #include <locale.h>
- #include <signal.h>
-+#include <stdbool.h>
- #include <sys/select.h>
- #include <time.h>
- #include <unistd.h>
-_AT_@ -98,6 +99,7 @@ typedef struct {
+_AT_@ -105,6 +105,7 @@ typedef struct {
  	XSetWindowAttributes attrs;
  	int scr;
  	int isfixed; /* is fixed geometry? */
_AT_@ -85,7 +74,7 @@ index 5828a3b..45bc960 100644
  	int l, t; /* left and top offset */
  	int gm; /* geometry mask */
  } XWindow;
-_AT_@ -233,6 +235,7 @@ static char *usedfont = NULL;
+_AT_@ -243,6 +244,7 @@ static char *usedfont = NULL;
  static double usedfontsize = 0;
  static double defaultfontsize = 0;
  
_AT_@ -93,15 +82,16 @@ index 5828a3b..45bc960 100644
  static char *opt_class = NULL;
  static char **opt_cmd  = NULL;
  static char *opt_embed = NULL;
-_AT_@ -241,6 +244,7 @@ static char *opt_io    = NULL;
- static char *opt_line  = NULL;
+_AT_@ -252,6 +254,8 @@ static char *opt_line  = NULL;
  static char *opt_name  = NULL;
  static char *opt_title = NULL;
-+static bool focused = true;
  
++static int focused = 0;
++
  static int oldbutton = 3; /* button event on startup: 3 = release */
  
-_AT_@ -692,7 +696,7 @@ xresize(int col, int row)
+ void
+_AT_@ -734,7 +738,7 @@ xresize(int col, int row)
  
  	XFreePixmap(xw.dpy, xw.buf);
  	xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h,
_AT_@ -110,22 +100,54 @@ index 5828a3b..45bc960 100644
  	XftDrawChange(xw.draw, xw.buf);
  	xclear(0, 0, win.w, win.h);
  
-_AT_@ -752,6 +756,14 @@ xloadcols(void)
+_AT_@ -772,28 +776,38 @@ xloadcolor(int i, const char *name, Color *ncolor)
+ 	return XftColorAllocName(xw.dpy, xw.vis, xw.cmap, name, ncolor);
+ }
+ 
++void
++xloadalpha(void)
++{
++	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'
", colorname[i]);
  			else
  				die("could not allocate color %d
", i);
  		}
++	if (dc.collen) // cannot die, as the color is already loaded.
++		xloadcolor(focused ?bg :bgUnfocused, NULL, &dc.col[defaultbg]);
 +
-+	/* set alpha value of bg color */
-+	if (opt_alpha)
-+		alpha = strtof(opt_alpha, NULL);
-+	float const usedAlpha = focused ? alpha : alphaUnfocussed;
-+	dc.col[defaultbg].color.alpha = (unsigned short)(0xffff * usedAlpha);
-+	dc.col[defaultbg].pixel &= 0x00FFFFFF;
-+	dc.col[defaultbg].pixel |= (unsigned char)(0xff * usedAlpha) << 24;
++	xloadalpha();
  	loaded = 1;
  }
  
-_AT_@ -1044,11 +1056,23 @@ xinit(int cols, int rows)
+_AT_@ -1103,11 +1117,23 @@ xinit(int cols, int rows)
  	Window parent;
  	pid_t thispid = getpid();
  	XColor xmousefg, xmousebg;
_AT_@ -150,7 +172,7 @@ index 5828a3b..45bc960 100644
  
  	/* font */
  	if (!FcInit())
-_AT_@ -1058,7 +1082,7 @@ xinit(int cols, int rows)
+_AT_@ -1117,7 +1143,7 @@ xinit(int cols, int rows)
  	xloadfonts(usedfont, 0);
  
  	/* colors */
_AT_@ -159,7 +181,7 @@ index 5828a3b..45bc960 100644
  	xloadcols();
  
  	/* adjust fixed window geometry */
-_AT_@ -1078,19 +1102,15 @@ xinit(int cols, int rows)
+_AT_@ -1137,19 +1163,15 @@ xinit(int cols, int rows)
  		| ButtonMotionMask | ButtonPressMask | ButtonReleaseMask;
  	xw.attrs.colormap = xw.cmap;
  
_AT_@ -182,33 +204,7 @@ index 5828a3b..45bc960 100644
  	XSetForeground(xw.dpy, dc.gc, dc.col[defaultbg].pixel);
  	XFillRectangle(xw.dpy, xw.buf, dc.gc, 0, 0, win.w, win.h);
  
-_AT_@ -1663,13 +1683,21 @@ focus(XEvent *ev)
- 		XSetICFocus(xw.xic);
- 		win.mode |= MODE_FOCUSED;
- 		xseturgency(0);
--		if (IS_SET(MODE_FOCUS))
--			ttywrite("", 3, 0);
-+		if (IS_SET(MODE_FOCUS)) { ttywrite("", 3, 0); }
-+		if (!focused) {
-+			focused = true;
-+			xloadcols();
-+			redraw();
-+		}
- 	} else {
- 		XUnsetICFocus(xw.xic);
- 		win.mode &= ~MODE_FOCUSED;
--		if (IS_SET(MODE_FOCUS))
--			ttywrite("", 3, 0);
-+		if (IS_SET(MODE_FOCUS)) { ttywrite("", 3, 0); }
-+		if (focused) {
-+			focused = false;
-+			xloadcols();
-+			redraw();
-+		}
- 	}
- }
- 
-_AT_@ -1925,6 +1953,9 @@ main(int argc, char *argv[])
+_AT_@ -1994,6 +2016,9 @@ main(int argc, char *argv[])
  	case 'a':
  		allowaltscreen = 0;
  		break;
_AT_@ -218,6 +214,14 @@ index 5828a3b..45bc960 100644
  	case 'c':
  		opt_class = EARGF(usage());
  		break;
+_AT_@ -2045,6 +2070,7 @@ run:
+ 	XSetLocaleModifiers("");
+ 	cols = MAX(cols, 1);
+ 	rows = MAX(rows, 1);
++	defaultbg = MAX(LEN(colorname), 256);
+ 	tnew(cols, rows);
+ 	xinit(cols, rows);
+ 	xsetenv();
 -- 
-2.24.0
+2.26.2
 
diff --git a/st.suckless.org/patches/alpha_focus_highlight/st-focus-20200530-patch_alpha.diff b/st.suckless.org/patches/alpha_focus_highlight/st-focus-20200530-patch_alpha.diff
new file mode 100644
index 00000000..4796b52a
--- /dev/null
+++ b/st.suckless.org/patches/alpha_focus_highlight/st-focus-20200530-patch_alpha.diff
_AT_@ -0,0 +1,123 @@
+From c6c814329bdfc419f50a27b538a1b983ea52a1d3 Mon Sep 17 00:00:00 2001
+From: Julius Huelsmann <juliusHuelsmann_AT_gmail.com>
+Date: Sat, 30 May 2020 12:18:59 +0200
+Subject: [PATCH] patch: focus
+
+---
+ config.def.h |  5 +++--
+ st.h         |  2 +-
+ x.c          | 34 ++++++++++++++++++++--------------
+ 3 files changed, 24 insertions(+), 17 deletions(-)
+
+diff --git a/config.def.h b/config.def.h
+index b94b23c..577d1f1 100644
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -85,7 +85,7 @@ char *termname = "st-256color";
+ unsigned int tabspaces = 8;
+ 
+ /* bg opacity */
+-float alpha = 0.8;
++float alpha = 0.8, alphaUnfocused = 0.6;
+ 
+ /* Terminal colors (16 first used in escape sequence) */
+ static const char *colorname[] = {
+_AT_@ -123,9 +123,10 @@ static const char *colorname[] = {
+  * foreground, background, cursor, reverse cursor
+  */
+ unsigned int defaultfg = 7;
+-unsigned int defaultbg = 258;
++unsigned int defaultbg = 0;
+ static unsigned int defaultcs = 256;
+ static unsigned int defaultrcs = 257;
++unsigned int bg = 17, bgUnfocused = 16;
+ 
+ /*
+  * Default shape of cursor
+diff --git a/st.h b/st.h
+index 2c656af..b5f1cf6 100644
+--- a/st.h
++++ b/st.h
+_AT_@ -122,4 +122,4 @@ extern char *termname;
+ extern unsigned int tabspaces;
+ extern unsigned int defaultfg;
+ extern unsigned int defaultbg;
+-extern float alpha;
++extern float alpha, alphaUnfocused;
+diff --git a/x.c b/x.c
+index 50da23c..2de16cb 100644
+--- a/x.c
++++ b/x.c
+_AT_@ -254,6 +254,8 @@ static char *opt_line  = NULL;
+ static char *opt_name  = NULL;
+ static char *opt_title = NULL;
+ 
++static int focused = 0;
++
+ static int oldbutton = 3; /* button event on startup: 3 = release */
+ 
+ void
+_AT_@ -774,35 +776,38 @@ xloadcolor(int i, const char *name, Color *ncolor)
+ 	return XftColorAllocName(xw.dpy, xw.vis, xw.cmap, name, ncolor);
+ }
+ 
++void
++xloadalpha(void)
++{
++	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'
", colorname[i]);
+ 			else
+ 				die("could not allocate color %d
", i);
+ 		}
++	if (dc.collen) // cannot die, as the color is already loaded.
++		xloadcolor(focused ?bg :bgUnfocused, NULL, &dc.col[defaultbg]);
+ 
+-	/* set alpha value of bg color */
+-	if (opt_alpha)
+-		alpha = strtof(opt_alpha, NULL);
+-	dc.col[defaultbg].color.alpha = (unsigned short)(0xffff * alpha);
+-	dc.col[defaultbg].pixel &= 0x00FFFFFF;
+-	dc.col[defaultbg].pixel |= (unsigned char)(0xff * alpha) << 24;
++	xloadalpha();
+ 	loaded = 1;
+ }
+ 
+_AT_@ -2065,6 +2070,7 @@ run:
+ 	XSetLocaleModifiers("");
+ 	cols = MAX(cols, 1);
+ 	rows = MAX(rows, 1);
++	defaultbg = MAX(LEN(colorname), 256);
+ 	tnew(cols, rows);
+ 	xinit(cols, rows);
+ 	xsetenv();
+-- 
+2.26.2
+
Received on Mon Jun 01 2020 - 19:05:09 CEST

This archive was generated by hypermail 2.3.0 : Mon Jun 01 2020 - 19:12:43 CEST