st-alpha-20190116-3be4cf1.diff - sites - public wiki contents of suckless.org | |
git clone git://git.suckless.org/sites | |
Log | |
Files | |
Refs | |
--- | |
st-alpha-20190116-3be4cf1.diff (5651B) | |
--- | |
1 diff --git a/config.def.h b/config.def.h | |
2 index 0e01717..007fbd4 100644 | |
3 --- a/config.def.h | |
4 +++ b/config.def.h | |
5 @@ -82,6 +82,9 @@ char *termname = "st-256color"; | |
6 */ | |
7 unsigned int tabspaces = 8; | |
8 | |
9 +/* bg opacity */ | |
10 +unsigned int alpha = 0xcc; | |
11 + | |
12 /* Terminal colors (16 first used in escape sequence) */ | |
13 static const char *colorname[] = { | |
14 /* 8 normal colors */ | |
15 @@ -109,6 +112,7 @@ static const char *colorname[] = { | |
16 /* more colors can be added after 255 to use with DefaultXX */ | |
17 "#cccccc", | |
18 "#555555", | |
19 + "black", | |
20 }; | |
21 | |
22 | |
23 @@ -117,7 +121,7 @@ static const char *colorname[] = { | |
24 * foreground, background, cursor, reverse cursor | |
25 */ | |
26 unsigned int defaultfg = 7; | |
27 -unsigned int defaultbg = 0; | |
28 +unsigned int defaultbg = 257; | |
29 static unsigned int defaultcs = 256; | |
30 static unsigned int defaultrcs = 257; | |
31 | |
32 diff --git a/config.mk b/config.mk | |
33 index 5059632..1844c14 100644 | |
34 --- a/config.mk | |
35 +++ b/config.mk | |
36 @@ -13,10 +13,10 @@ X11LIB = /usr/X11R6/lib | |
37 PKG_CONFIG = pkg-config | |
38 | |
39 # includes and libs | |
40 -INCS = -I$(X11INC) \ | |
41 +INCS = -I. -I/usr/include -I${X11INC} \ | |
42 `$(PKG_CONFIG) --cflags fontconfig` \ | |
43 `$(PKG_CONFIG) --cflags freetype2` | |
44 -LIBS = -L$(X11LIB) -lm -lrt -lX11 -lutil -lXft \ | |
45 +LIBS = -L/usr/lib -lc -L${X11LIB} -lm -lrt -lX11 -lutil -lXft -lXrender\ | |
46 `$(PKG_CONFIG) --libs fontconfig` \ | |
47 `$(PKG_CONFIG) --libs freetype2` | |
48 | |
49 diff --git a/st.h b/st.h | |
50 index 38c61c4..935a9d3 100644 | |
51 --- a/st.h | |
52 +++ b/st.h | |
53 @@ -118,5 +118,6 @@ extern char *worddelimiters; | |
54 extern int allowaltscreen; | |
55 extern char *termname; | |
56 extern unsigned int tabspaces; | |
57 +extern unsigned int alpha; | |
58 extern unsigned int defaultfg; | |
59 extern unsigned int defaultbg; | |
60 diff --git a/x.c b/x.c | |
61 index 0422421..441bada 100644 | |
62 --- a/x.c | |
63 +++ b/x.c | |
64 @@ -48,6 +48,10 @@ typedef struct { | |
65 #define XK_NO_MOD 0 | |
66 #define XK_SWITCH_MOD (1<<13) | |
67 | |
68 +/* alpha */ | |
69 +#define OPAQUE 0Xff | |
70 +#define USE_ARGB (alpha != OPAQUE && opt_embed == NULL) | |
71 + | |
72 /* function definitions used in config.h */ | |
73 static void clipcopy(const Arg *); | |
74 static void clippaste(const Arg *); | |
75 @@ -98,6 +102,7 @@ typedef struct { | |
76 XSetWindowAttributes attrs; | |
77 int scr; | |
78 int isfixed; /* is fixed geometry? */ | |
79 + int depth; /* bit depth */ | |
80 int l, t; /* left and top offset */ | |
81 int gm; /* geometry mask */ | |
82 } XWindow; | |
83 @@ -688,7 +693,7 @@ xresize(int col, int row) | |
84 | |
85 XFreePixmap(xw.dpy, xw.buf); | |
86 xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h, | |
87 - DefaultDepth(xw.dpy, xw.scr)); | |
88 + xw.depth); | |
89 XftDrawChange(xw.draw, xw.buf); | |
90 xclear(0, 0, win.w, win.h); | |
91 | |
92 @@ -748,6 +753,14 @@ xloadcols(void) | |
93 else | |
94 die("could not allocate color %d\n", i); | |
95 } | |
96 + | |
97 + /* set alpha value of bg color */ | |
98 + if (USE_ARGB) { | |
99 + dc.col[defaultbg].color.alpha = alpha << 8; | |
100 + dc.col[defaultbg].color.red = ((dc.col[defaultbg].col… | |
101 + dc.col[defaultbg].color.green = ((dc.col[defaultbg].col… | |
102 + dc.col[defaultbg].color.blue = ((dc.col[defaultbg].col… | |
103 + } | |
104 loaded = 1; | |
105 } | |
106 | |
107 @@ -769,6 +782,17 @@ xsetcolorname(int x, const char *name) | |
108 return 0; | |
109 } | |
110 | |
111 +void | |
112 +xtermclear(int col1, int row1, int col2, int row2) | |
113 +{ | |
114 + XftDrawRect(xw.draw, | |
115 + &dc.col[IS_SET(MODE_REVERSE) ? defaultfg : defa… | |
116 + borderpx + col1 * win.cw, | |
117 + borderpx + row1 * win.ch, | |
118 + (col2-col1+1) * win.cw, | |
119 + (row2-row1+1) * win.ch); | |
120 +} | |
121 + | |
122 /* | |
123 * Absolute coordinates. | |
124 */ | |
125 @@ -1008,7 +1032,40 @@ xinit(int cols, int rows) | |
126 if (!(xw.dpy = XOpenDisplay(NULL))) | |
127 die("can't open display\n"); | |
128 xw.scr = XDefaultScreen(xw.dpy); | |
129 - xw.vis = XDefaultVisual(xw.dpy, xw.scr); | |
130 + xw.depth = (USE_ARGB) ? 32: XDefaultDepth(xw.dpy, xw.scr); | |
131 + if (!USE_ARGB) | |
132 + xw.vis = XDefaultVisual(xw.dpy, xw.scr); | |
133 + else { | |
134 + XVisualInfo *vis; | |
135 + XRenderPictFormat *fmt; | |
136 + int nvi; | |
137 + int i; | |
138 + | |
139 + XVisualInfo tpl = { | |
140 + .screen = xw.scr, | |
141 + .depth = 32, | |
142 + .class = TrueColor | |
143 + }; | |
144 + | |
145 + vis = XGetVisualInfo(xw.dpy, | |
146 + VisualScreenMask | VisualDepthMask | Vi… | |
147 + &tpl, &nvi); | |
148 + xw.vis = NULL; | |
149 + for (i = 0; i < nvi; i++) { | |
150 + fmt = XRenderFindVisualFormat(xw.dpy, vis[i].vi… | |
151 + if (fmt->type == PictTypeDirect && fmt->direct.… | |
152 + xw.vis = vis[i].visual; | |
153 + break; | |
154 + } | |
155 + } | |
156 + | |
157 + XFree(vis); | |
158 + | |
159 + if (!xw.vis) { | |
160 + fprintf(stderr, "Couldn't find ARGB visual.\n"); | |
161 + exit(1); | |
162 + } | |
163 + } | |
164 | |
165 /* font */ | |
166 if (!FcInit()) | |
167 @@ -1018,7 +1075,11 @@ xinit(int cols, int rows) | |
168 xloadfonts(usedfont, 0); | |
169 | |
170 /* colors */ | |
171 - xw.cmap = XDefaultColormap(xw.dpy, xw.scr); | |
172 + if (!USE_ARGB) | |
173 + xw.cmap = XDefaultColormap(xw.dpy, xw.scr); | |
174 + else | |
175 + xw.cmap = XCreateColormap(xw.dpy, XRootWindow(xw.dpy, x… | |
176 + xw.vis, None); | |
177 xloadcols(); | |
178 | |
179 /* adjust fixed window geometry */ | |
180 @@ -1041,16 +1102,15 @@ xinit(int cols, int rows) | |
181 if (!(opt_embed && (parent = strtol(opt_embed, NULL, 0)))) | |
182 parent = XRootWindow(xw.dpy, xw.scr); | |
183 xw.win = XCreateWindow(xw.dpy, parent, xw.l, xw.t, | |
184 - win.w, win.h, 0, XDefaultDepth(xw.dpy, xw.scr),… | |
185 + win.w, win.h, 0, xw.depth, InputOutput, | |
186 xw.vis, CWBackPixel | CWBorderPixel | CWBitGrav… | |
187 | CWEventMask | CWColormap, &xw.attrs); | |
188 | |
189 memset(&gcvalues, 0, sizeof(gcvalues)); | |
190 gcvalues.graphics_exposures = False; | |
191 - dc.gc = XCreateGC(xw.dpy, parent, GCGraphicsExposures, | |
192 - &gcvalues); | |
193 - xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h, | |
194 - DefaultDepth(xw.dpy, xw.scr)); | |
195 + xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h, xw.depth); | |
196 + dc.gc = XCreateGC(xw.dpy, (USE_ARGB) ? xw.buf: parent, | |
197 + GCGraphicsExposures, &gcvalues); | |
198 XSetForeground(xw.dpy, dc.gc, dc.col[defaultbg].pixel); | |
199 XFillRectangle(xw.dpy, xw.buf, dc.gc, 0, 0, win.w, win.h); | |
200 |