----
- 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("[I", 3, 0);
-+ if (IS_SET(MODE_FOCUS)) { ttywrite("[I", 3, 0); }
-+ if (!focused) {
-+ focused = true;
-+ xloadcols();
-+ redraw();
-+ }
- } else {
- XUnsetICFocus(xw.xic);
- win.mode &= ~MODE_FOCUSED;
-- if (IS_SET(MODE_FOCUS))
-- ttywrite("[O", 3, 0);
-+ if (IS_SET(MODE_FOCUS)) { ttywrite("[O", 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("[I", 3, 0); }
-+ if (IS_SET(MODE_FOCUS))
-+ ttywrite("[I", 3, 0);
- if (!focused) {
- focused = true;
-- xloadcols();
-+ xloadalpha();
- redraw();
- }
- } else {
- XUnsetICFocus(xw.xic);
- win.mode &= ~MODE_FOCUSED;
-- if (IS_SET(MODE_FOCUS)) { ttywrite("[O", 3, 0); }
-+ if (IS_SET(MODE_FOCUS))
-+ ttywrite("[O", 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("[I", 3, 0);
-+ if (IS_SET(MODE_FOCUS)) { ttywrite("[I", 3, 0); }
-+ if (!focused) {
-+ focused = true;
-+ xloadcols();
-+ redraw();
-+ }
- } else {
- XUnsetICFocus(xw.xic);
- win.mode &= ~MODE_FOCUSED;
-- if (IS_SET(MODE_FOCUS))
-- ttywrite("[O", 3, 0);
-+ if (IS_SET(MODE_FOCUS)) { ttywrite("[O", 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("[I", 3, 0); }
-+ if (IS_SET(MODE_FOCUS))
-+ ttywrite("[I", 3, 0);
- if (!focused) {
- focused = true;
-- xloadcols();
-+ xloadalpha();
- redraw();
- }
- } else {
- XUnsetICFocus(xw.xic);
- win.mode &= ~MODE_FOCUSED;
-- if (IS_SET(MODE_FOCUS)) { ttywrite("[O", 3, 0); }
-+ if (IS_SET(MODE_FOCUS))
-+ ttywrite("[O", 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("[I", 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("[O", 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("[I", 3, 0);
-+ if (IS_SET(MODE_FOCUS)) { ttywrite("[I", 3, 0); }
-+ if (!focused) {
-+ focused = true;
-+ xloadcols();
-+ redraw();
-+ }
- } else {
- XUnsetICFocus(xw.xic);
- win.mode &= ~MODE_FOCUSED;
-- if (IS_SET(MODE_FOCUS))
-- ttywrite("[O", 3, 0);
-+ if (IS_SET(MODE_FOCUS)) { ttywrite("[O", 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