diff options
author | Federico I <git@federicoigne.com> | 2020-03-21 13:15:29 +0000 |
---|---|---|
committer | Federico I <git@federicoigne.com> | 2020-03-21 13:15:29 +0000 |
commit | 9b0126bab0a35159d421e73412c930b646651346 (patch) | |
tree | e8b592cac512fd823c2d08e527c591546c0562ca | |
parent | 6524745f3a2e106037980b908c8890c650b16ba2 (diff) | |
download | st-9b0126bab0a35159d421e73412c930b646651346.tar.gz st-9b0126bab0a35159d421e73412c930b646651346.zip |
Apply Alpha patch
Patch Homepage: https://st.suckless.org/patches/alpha/
Patch Link: https://st.suckless.org/patches/alpha/st-alpha-0.8.2.diff
Additional notes: patch applied manually
-rw-r--r-- | config.def.h | 6 | ||||
-rw-r--r-- | config.h | 6 | ||||
-rw-r--r-- | config.mk | 2 | ||||
-rw-r--r-- | st.h | 1 | ||||
-rw-r--r-- | x.c | 40 |
5 files changed, 42 insertions, 13 deletions
diff --git a/config.def.h b/config.def.h index 546edda..85a1d17 100644 --- a/config.def.h +++ b/config.def.h | |||
@@ -82,6 +82,9 @@ char *termname = "st-256color"; | |||
82 | */ | 82 | */ |
83 | unsigned int tabspaces = 8; | 83 | unsigned int tabspaces = 8; |
84 | 84 | ||
85 | /* bg opacity */ | ||
86 | float alpha = 0.8; | ||
87 | |||
85 | /* Terminal colors (16 first used in escape sequence) */ | 88 | /* Terminal colors (16 first used in escape sequence) */ |
86 | static const char *colorname[] = { | 89 | static const char *colorname[] = { |
87 | /* 8 normal colors */ | 90 | /* 8 normal colors */ |
@@ -109,6 +112,7 @@ static const char *colorname[] = { | |||
109 | /* more colors can be added after 255 to use with DefaultXX */ | 112 | /* more colors can be added after 255 to use with DefaultXX */ |
110 | "#cccccc", | 113 | "#cccccc", |
111 | "#555555", | 114 | "#555555", |
115 | "black", | ||
112 | }; | 116 | }; |
113 | 117 | ||
114 | 118 | ||
@@ -117,7 +121,7 @@ static const char *colorname[] = { | |||
117 | * foreground, background, cursor, reverse cursor | 121 | * foreground, background, cursor, reverse cursor |
118 | */ | 122 | */ |
119 | unsigned int defaultfg = 7; | 123 | unsigned int defaultfg = 7; |
120 | unsigned int defaultbg = 0; | 124 | unsigned int defaultbg = 258; |
121 | static unsigned int defaultcs = 256; | 125 | static unsigned int defaultcs = 256; |
122 | static unsigned int defaultrcs = 257; | 126 | static unsigned int defaultrcs = 257; |
123 | 127 | ||
@@ -86,6 +86,9 @@ char *termname = "st-256color"; | |||
86 | * stty tabs | 86 | * stty tabs |
87 | */ | 87 | */ |
88 | unsigned int tabspaces = 8; | 88 | unsigned int tabspaces = 8; |
89 | |||
90 | /* bg opacity */ | ||
91 | float alpha = 0.8; | ||
89 | 92 | ||
90 | /* Terminal colors (16 first used in escape sequence) */ | 93 | /* Terminal colors (16 first used in escape sequence) */ |
91 | static const char *colorname[] = { | 94 | static const char *colorname[] = { |
@@ -114,6 +117,7 @@ static const char *colorname[] = { | |||
114 | /* more colors can be added after 255 to use with DefaultXX */ | 117 | /* more colors can be added after 255 to use with DefaultXX */ |
115 | "#cccccc", | 118 | "#cccccc", |
116 | "#555555", | 119 | "#555555", |
120 | "black", | ||
117 | }; | 121 | }; |
118 | 122 | ||
119 | 123 | ||
@@ -122,7 +126,7 @@ static const char *colorname[] = { | |||
122 | * foreground, background, cursor, reverse cursor | 126 | * foreground, background, cursor, reverse cursor |
123 | */ | 127 | */ |
124 | unsigned int defaultfg = 7; | 128 | unsigned int defaultfg = 7; |
125 | unsigned int defaultbg = 0; | 129 | unsigned int defaultbg = 258; |
126 | static unsigned int defaultcs = 256; | 130 | static unsigned int defaultcs = 256; |
127 | static unsigned int defaultrcs = 257; | 131 | static unsigned int defaultrcs = 257; |
128 | 132 | ||
@@ -16,7 +16,7 @@ PKG_CONFIG = pkg-config | |||
16 | INCS = -I$(X11INC) \ | 16 | INCS = -I$(X11INC) \ |
17 | `$(PKG_CONFIG) --cflags fontconfig` \ | 17 | `$(PKG_CONFIG) --cflags fontconfig` \ |
18 | `$(PKG_CONFIG) --cflags freetype2` | 18 | `$(PKG_CONFIG) --cflags freetype2` |
19 | LIBS = -L$(X11LIB) -lm -lrt -lX11 -lutil -lXft \ | 19 | LIBS = -L$(X11LIB) -lm -lrt -lX11 -lutil -lXft -lXrender\ |
20 | `$(PKG_CONFIG) --libs fontconfig` \ | 20 | `$(PKG_CONFIG) --libs fontconfig` \ |
21 | `$(PKG_CONFIG) --libs freetype2` | 21 | `$(PKG_CONFIG) --libs freetype2` |
22 | 22 | ||
@@ -121,3 +121,4 @@ extern char *termname; | |||
121 | extern unsigned int tabspaces; | 121 | extern unsigned int tabspaces; |
122 | extern unsigned int defaultfg; | 122 | extern unsigned int defaultfg; |
123 | extern unsigned int defaultbg; | 123 | extern unsigned int defaultbg; |
124 | extern float alpha; | ||
@@ -105,6 +105,7 @@ typedef struct { | |||
105 | XSetWindowAttributes attrs; | 105 | XSetWindowAttributes attrs; |
106 | int scr; | 106 | int scr; |
107 | int isfixed; /* is fixed geometry? */ | 107 | int isfixed; /* is fixed geometry? */ |
108 | int depth; /* bit depth */ | ||
108 | int l, t; /* left and top offset */ | 109 | int l, t; /* left and top offset */ |
109 | int gm; /* geometry mask */ | 110 | int gm; /* geometry mask */ |
110 | } XWindow; | 111 | } XWindow; |
@@ -244,6 +245,7 @@ static char *usedfont = NULL; | |||
244 | static double usedfontsize = 0; | 245 | static double usedfontsize = 0; |
245 | static double defaultfontsize = 0; | 246 | static double defaultfontsize = 0; |
246 | 247 | ||
248 | static char *opt_alpha = NULL; | ||
247 | static char *opt_class = NULL; | 249 | static char *opt_class = NULL; |
248 | static char **opt_cmd = NULL; | 250 | static char **opt_cmd = NULL; |
249 | static char *opt_embed = NULL; | 251 | static char *opt_embed = NULL; |
@@ -722,7 +724,7 @@ xresize(int col, int row) | |||
722 | 724 | ||
723 | XFreePixmap(xw.dpy, xw.buf); | 725 | XFreePixmap(xw.dpy, xw.buf); |
724 | xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h, | 726 | xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h, |
725 | DefaultDepth(xw.dpy, xw.scr)); | 727 | xw.depth); |
726 | XftDrawChange(xw.draw, xw.buf); | 728 | XftDrawChange(xw.draw, xw.buf); |
727 | xclear(0, 0, win.w, win.h); | 729 | xclear(0, 0, win.w, win.h); |
728 | 730 | ||
@@ -782,6 +784,13 @@ xloadcols(void) | |||
782 | else | 784 | else |
783 | die("could not allocate color %d\n", i); | 785 | die("could not allocate color %d\n", i); |
784 | } | 786 | } |
787 | |||
788 | /* set alpha value of bg color */ | ||
789 | if (opt_alpha) | ||
790 | alpha = strtof(opt_alpha, NULL); | ||
791 | dc.col[defaultbg].color.alpha = (unsigned short)(0xffff * alpha); | ||
792 | dc.col[defaultbg].pixel &= 0x00FFFFFF; | ||
793 | dc.col[defaultbg].pixel |= (unsigned char)(0xff * alpha) << 24; | ||
785 | loaded = 1; | 794 | loaded = 1; |
786 | } | 795 | } |
787 | 796 | ||
@@ -1187,11 +1196,23 @@ xinit(int cols, int rows) | |||
1187 | Window parent; | 1196 | Window parent; |
1188 | pid_t thispid = getpid(); | 1197 | pid_t thispid = getpid(); |
1189 | XColor xmousefg, xmousebg; | 1198 | XColor xmousefg, xmousebg; |
1199 | XWindowAttributes attr; | ||
1200 | XVisualInfo vis; | ||
1190 | 1201 | ||
1191 | if (!(xw.dpy = XOpenDisplay(NULL))) | 1202 | if (!(xw.dpy = XOpenDisplay(NULL))) |
1192 | die("can't open display\n"); | 1203 | die("can't open display\n"); |
1193 | xw.scr = XDefaultScreen(xw.dpy); | 1204 | xw.scr = XDefaultScreen(xw.dpy); |
1194 | xw.vis = XDefaultVisual(xw.dpy, xw.scr); | 1205 | |
1206 | if (!(opt_embed && (parent = strtol(opt_embed, NULL, 0)))) { | ||
1207 | parent = XRootWindow(xw.dpy, xw.scr); | ||
1208 | xw.depth = 32; | ||
1209 | } else { | ||
1210 | XGetWindowAttributes(xw.dpy, parent, &attr); | ||
1211 | xw.depth = attr.depth; | ||
1212 | } | ||
1213 | |||
1214 | XMatchVisualInfo(xw.dpy, xw.scr, xw.depth, TrueColor, &vis); | ||
1215 | xw.vis = vis.visual; | ||
1195 | 1216 | ||
1196 | /* font */ | 1217 | /* font */ |
1197 | if (!FcInit()) | 1218 | if (!FcInit()) |
@@ -1204,7 +1225,7 @@ xinit(int cols, int rows) | |||
1204 | xloadsparefonts(); | 1225 | xloadsparefonts(); |
1205 | 1226 | ||
1206 | /* colors */ | 1227 | /* colors */ |
1207 | xw.cmap = XDefaultColormap(xw.dpy, xw.scr); | 1228 | xw.cmap = XCreateColormap(xw.dpy, parent, xw.vis, None); |
1208 | xloadcols(); | 1229 | xloadcols(); |
1209 | 1230 | ||
1210 | /* adjust fixed window geometry */ | 1231 | /* adjust fixed window geometry */ |
@@ -1224,19 +1245,15 @@ xinit(int cols, int rows) | |||
1224 | | ButtonMotionMask | ButtonPressMask | ButtonReleaseMask; | 1245 | | ButtonMotionMask | ButtonPressMask | ButtonReleaseMask; |
1225 | xw.attrs.colormap = xw.cmap; | 1246 | xw.attrs.colormap = xw.cmap; |
1226 | 1247 | ||
1227 | if (!(opt_embed && (parent = strtol(opt_embed, NULL, 0)))) | ||
1228 | parent = XRootWindow(xw.dpy, xw.scr); | ||
1229 | xw.win = XCreateWindow(xw.dpy, parent, xw.l, xw.t, | 1248 | xw.win = XCreateWindow(xw.dpy, parent, xw.l, xw.t, |
1230 | win.w, win.h, 0, XDefaultDepth(xw.dpy, xw.scr), InputOutput, | 1249 | win.w, win.h, 0, xw.depth, InputOutput, |
1231 | xw.vis, CWBackPixel | CWBorderPixel | CWBitGravity | 1250 | xw.vis, CWBackPixel | CWBorderPixel | CWBitGravity |
1232 | | CWEventMask | CWColormap, &xw.attrs); | 1251 | | CWEventMask | CWColormap, &xw.attrs); |
1233 | 1252 | ||
1234 | memset(&gcvalues, 0, sizeof(gcvalues)); | 1253 | memset(&gcvalues, 0, sizeof(gcvalues)); |
1235 | gcvalues.graphics_exposures = False; | 1254 | gcvalues.graphics_exposures = False; |
1236 | dc.gc = XCreateGC(xw.dpy, parent, GCGraphicsExposures, | 1255 | xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h, xw.depth); |
1237 | &gcvalues); | 1256 | dc.gc = XCreateGC(xw.dpy, xw.buf, GCGraphicsExposures, &gcvalues); |
1238 | xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h, | ||
1239 | DefaultDepth(xw.dpy, xw.scr)); | ||
1240 | XSetForeground(xw.dpy, dc.gc, dc.col[defaultbg].pixel); | 1257 | XSetForeground(xw.dpy, dc.gc, dc.col[defaultbg].pixel); |
1241 | XFillRectangle(xw.dpy, xw.buf, dc.gc, 0, 0, win.w, win.h); | 1258 | XFillRectangle(xw.dpy, xw.buf, dc.gc, 0, 0, win.w, win.h); |
1242 | 1259 | ||
@@ -2081,6 +2098,9 @@ main(int argc, char *argv[]) | |||
2081 | case 'a': | 2098 | case 'a': |
2082 | allowaltscreen = 0; | 2099 | allowaltscreen = 0; |
2083 | break; | 2100 | break; |
2101 | case 'A': | ||
2102 | opt_alpha = EARGF(usage()); | ||
2103 | break; | ||
2084 | case 'c': | 2104 | case 'c': |
2085 | opt_class = EARGF(usage()); | 2105 | opt_class = EARGF(usage()); |
2086 | break; | 2106 | break; |