Introduction
Introduction Statistics Contact Development Disclaimer Help
st-alpha-20160727-308bfbf.diff - sites - public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log
Files
Refs
---
st-alpha-20160727-308bfbf.diff (5375B)
---
1 diff --git a/config.def.h b/config.def.h
2 index b41747f..e22ebd2 100644
3 --- a/config.def.h
4 +++ b/config.def.h
5 @@ -82,6 +82,9 @@ static char termname[] = "st-256color";
6 */
7 static unsigned int tabspaces = 8;
8
9 +/* bg opacity */
10 +static const int alpha = 0xdd;
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 static unsigned int defaultfg = 7;
27 -static unsigned int defaultbg = 0;
28 +static 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 81e3e47..005b1c6 100644
34 --- a/config.mk
35 +++ b/config.mk
36 @@ -14,7 +14,7 @@ X11LIB = /usr/X11R6/lib
37 INCS = -I. -I/usr/include -I${X11INC} \
38 `pkg-config --cflags fontconfig` \
39 `pkg-config --cflags freetype2`
40 -LIBS = -L/usr/lib -lc -L${X11LIB} -lm -lrt -lX11 -lutil -lXft \
41 +LIBS = -L/usr/lib -lc -L${X11LIB} -lm -lrt -lX11 -lutil -lXext -lXft -l…
42 `pkg-config --libs fontconfig` \
43 `pkg-config --libs freetype2`
44
45 diff --git a/st.c b/st.c
46 index 2594c65..f9ba75b 100644
47 --- a/st.c
48 +++ b/st.c
49 @@ -61,6 +61,7 @@ char *argv0;
50 #define XK_ANY_MOD UINT_MAX
51 #define XK_NO_MOD 0
52 #define XK_SWITCH_MOD (1<<13)
53 +#define OPAQUE 0Xff
54
55 /* macros */
56 #define MIN(a, b) ((a) < (b) ? (a) : (b))
57 @@ -81,6 +82,8 @@ char *argv0;
58 (t1.tv_nsec-t2.tv_nsec)/1E6)
59 #define MODBIT(x, set, bit) ((set) ? ((x) |= (bit)) : ((x) &= ~(…
60
61 +#define USE_ARGB (alpha != OPAQUE && opt_embed == NULL)
62 +
63 #define TRUECOLOR(r,g,b) (1 << 24 | (r) << 16 | (g) << 8 | (b))
64 #define IS_TRUECOL(x) (1 << 24 & (x))
65 #define TRUERED(x) (((x) & 0xff0000) >> 8)
66 @@ -268,6 +271,7 @@ typedef struct {
67 int w, h; /* window width and height */
68 int ch; /* char height */
69 int cw; /* char width */
70 + int depth; /* bit depth */
71 char state; /* focus, redraw, visible */
72 int cursor; /* cursor style */
73 } XWindow;
74 @@ -3137,7 +3141,7 @@ xresize(int col, int row)
75
76 XFreePixmap(xw.dpy, xw.buf);
77 xw.buf = XCreatePixmap(xw.dpy, xw.win, xw.w, xw.h,
78 - DefaultDepth(xw.dpy, xw.scr));
79 + xw.depth);
80 XftDrawChange(xw.draw, xw.buf);
81 xclear(0, 0, xw.w, xw.h);
82 }
83 @@ -3191,6 +3195,14 @@ xloadcols(void)
84 else
85 die("Could not allocate color %d\n", i);
86 }
87 +
88 + /* set alpha value of bg color */
89 + if (USE_ARGB) {
90 + dc.col[defaultbg].color.alpha = (0xffff * alpha) / OPAQ…
91 + dc.col[defaultbg].pixel &= 0x00111111;
92 + dc.col[defaultbg].pixel |= alpha << 24; // 0xcc000000;
93 + }
94 +
95 loaded = 1;
96 }
97
98 @@ -3212,6 +3224,16 @@ xsetcolorname(int x, const char *name)
99 return 0;
100 }
101
102 +void
103 +xtermclear(int col1, int row1, int col2, int row2) {
104 + XftDrawRect(xw.draw,
105 + &dc.col[IS_SET(MODE_REVERSE) ? defaultfg : defa…
106 + borderpx + col1 * xw.cw,
107 + borderpx + row1 * xw.ch,
108 + (col2-col1+1) * xw.cw,
109 + (row2-row1+1) * xw.ch);
110 +}
111 +
112 /*
113 * Absolute coordinates.
114 */
115 @@ -3443,7 +3465,38 @@ xinit(void)
116 if (!(xw.dpy = XOpenDisplay(NULL)))
117 die("Can't open display\n");
118 xw.scr = XDefaultScreen(xw.dpy);
119 - xw.vis = XDefaultVisual(xw.dpy, xw.scr);
120 + xw.depth = (USE_ARGB) ? 32: XDefaultDepth(xw.dpy, xw.scr);
121 + if (! USE_ARGB)
122 + xw.vis = XDefaultVisual(xw.dpy, xw.scr);
123 + else {
124 + XVisualInfo *vis;
125 + XRenderPictFormat *fmt;
126 + int nvi;
127 + int i;
128 +
129 + XVisualInfo tpl = {
130 + .screen = xw.scr,
131 + .depth = 32,
132 + .class = TrueColor
133 + };
134 +
135 + vis = XGetVisualInfo(xw.dpy, VisualScreenMask | VisualD…
136 + xw.vis = NULL;
137 + for(i = 0; i < nvi; i ++) {
138 + fmt = XRenderFindVisualFormat(xw.dpy, vis[i].vi…
139 + if (fmt->type == PictTypeDirect && fmt->direct.…
140 + xw.vis = vis[i].visual;
141 + break;
142 + }
143 + }
144 +
145 + XFree(vis);
146 +
147 + if (! xw.vis) {
148 + fprintf(stderr, "Couldn't find ARGB visual.\n");
149 + exit(1);
150 + }
151 + }
152
153 /* font */
154 if (!FcInit())
155 @@ -3453,7 +3506,10 @@ xinit(void)
156 xloadfonts(usedfont, 0);
157
158 /* colors */
159 - xw.cmap = XDefaultColormap(xw.dpy, xw.scr);
160 + if (! USE_ARGB)
161 + xw.cmap = XDefaultColormap(xw.dpy, xw.scr);
162 + else
163 + xw.cmap = XCreateColormap(xw.dpy, XRootWindow(xw.dpy, x…
164 xloadcols();
165
166 /* adjust fixed window geometry */
167 @@ -3476,16 +3532,17 @@ xinit(void)
168 if (!(opt_embed && (parent = strtol(opt_embed, NULL, 0))))
169 parent = XRootWindow(xw.dpy, xw.scr);
170 xw.win = XCreateWindow(xw.dpy, parent, xw.l, xw.t,
171 - xw.w, xw.h, 0, XDefaultDepth(xw.dpy, xw.scr), I…
172 + xw.w, xw.h, 0, xw.depth, InputOutput,
173 xw.vis, CWBackPixel | CWBorderPixel | CWBitGrav…
174 | CWEventMask | CWColormap, &xw.attrs);
175
176 memset(&gcvalues, 0, sizeof(gcvalues));
177 gcvalues.graphics_exposures = False;
178 - dc.gc = XCreateGC(xw.dpy, parent, GCGraphicsExposures,
179 + xw.buf = XCreatePixmap(xw.dpy, xw.win, xw.w, xw.h, xw.depth);
180 + dc.gc = XCreateGC(xw.dpy,
181 + (USE_ARGB)? xw.buf: parent,
182 + GCGraphicsExposures,
183 &gcvalues);
184 - xw.buf = XCreatePixmap(xw.dpy, xw.win, xw.w, xw.h,
185 - DefaultDepth(xw.dpy, xw.scr));
186 XSetForeground(xw.dpy, dc.gc, dc.col[defaultbg].pixel);
187 XFillRectangle(xw.dpy, xw.buf, dc.gc, 0, 0, xw.w, xw.h);
188
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.