Introduction
Introduction Statistics Contact Development Disclaimer Help
st-alpha-0.4.1.diff - sites - public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log
Files
Refs
---
st-alpha-0.4.1.diff (5007B)
---
1 diff --git a/config.def.h b/config.def.h
2 index d1c20bd..cc9f34d 100644
3 --- a/config.def.h
4 +++ b/config.def.h
5 @@ -25,6 +25,8 @@ static char termname[] = "st-256color";
6
7 static unsigned int tabspaces = 8;
8
9 +/* background opacity */
10 +static const int alpha = 0xdd;
11
12 /* Terminal colors (16 first used in escape sequence) */
13 static const char *colorname[] = {
14 @@ -52,6 +54,7 @@ static const char *colorname[] = {
15
16 /* more colors can be added after 255 to use with DefaultXX */
17 "#cccccc",
18 + "black",
19 };
20
21
22 @@ -60,7 +63,7 @@ static const char *colorname[] = {
23 * foreground, background, cursor
24 */
25 static unsigned int defaultfg = 7;
26 -static unsigned int defaultbg = 0;
27 +static unsigned int defaultbg = 257;
28 static unsigned int defaultcs = 256;
29
30 /*
31 diff --git a/config.mk b/config.mk
32 index 9431de2..0b92bf2 100644
33 --- a/config.mk
34 +++ b/config.mk
35 @@ -14,7 +14,7 @@ X11LIB = /usr/X11R6/lib
36 INCS = -I. -I/usr/include -I${X11INC} \
37 `pkg-config --cflags fontconfig` \
38 `pkg-config --cflags freetype2`
39 -LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 -lutil -lXext -lXft \
40 +LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 -lutil -lXext -lXft -lXrender \
41 `pkg-config --libs fontconfig` \
42 `pkg-config --libs freetype2`
43
44 diff --git a/st.c b/st.c
45 index 686ed5d..de4d0f9 100644
46 --- a/st.c
47 +++ b/st.c
48 @@ -60,6 +60,7 @@ char *argv0;
49 #define XK_ANY_MOD UINT_MAX
50 #define XK_NO_MOD 0
51 #define XK_SWITCH_MOD (1<<13)
52 +#define OPAQUE 0Xff
53
54 #define REDRAW_TIMEOUT (80*1000) /* 80 ms */
55
56 @@ -74,6 +75,7 @@ char *argv0;
57 #define ATTRCMP(a, b) ((a).mode != (b).mode || (a).fg != (b).fg || (a).…
58 #define IS_SET(flag) ((term.mode & (flag)) != 0)
59 #define TIMEDIFF(t1, t2) ((t1.tv_sec-t2.tv_sec)*1000 + (t1.tv_usec-t2.t…
60 +#define USE_ARGB (alpha != OPAQUE && opt_embed == NULL)
61
62 #define VT102ID "\033[?6c"
63
64 @@ -215,6 +217,7 @@ typedef struct {
65 int w, h; /* window width and height */
66 int ch; /* char height */
67 int cw; /* char width */
68 + int depth; /* bit depth */
69 char state; /* focus, redraw, visible */
70 } XWindow;
71
72 @@ -2335,8 +2338,7 @@ xresize(int col, int row) {
73 xw.th = MAX(1, row * xw.ch);
74
75 XFreePixmap(xw.dpy, xw.buf);
76 - xw.buf = XCreatePixmap(xw.dpy, xw.win, xw.w, xw.h,
77 - DefaultDepth(xw.dpy, xw.scr));
78 + xw.buf = XCreatePixmap(xw.dpy, xw.win, xw.w, xw.h, xw.depth);
79 XftDrawChange(xw.draw, xw.buf);
80 xclear(0, 0, xw.w, xw.h);
81 }
82 @@ -2360,6 +2362,13 @@ xloadcols(void) {
83 }
84 }
85
86 + /* set alpha value of bg color */
87 + if (USE_ARGB) {
88 + dc.col[defaultbg].color.alpha = (0xffff * alpha) / OPAQ…
89 + dc.col[defaultbg].pixel &= 0x00111111;
90 + dc.col[defaultbg].pixel |= alpha << 24; // 0xcc000000;
91 + }
92 +
93 /* load colors [16-255] ; same colors as xterm */
94 for(i = 16, r = 0; r < 6; r++) {
95 for(g = 0; g < 6; g++) {
96 @@ -2603,7 +2612,38 @@ xinit(void) {
97 if(!(xw.dpy = XOpenDisplay(NULL)))
98 die("Can't open display\n");
99 xw.scr = XDefaultScreen(xw.dpy);
100 - xw.vis = XDefaultVisual(xw.dpy, xw.scr);
101 + xw.depth = (USE_ARGB)? 32: XDefaultDepth(xw.dpy, xw.scr);
102 + if (! USE_ARGB)
103 + xw.vis = XDefaultVisual(xw.dpy, xw.scr);
104 + else {
105 + XVisualInfo *vis;
106 + XRenderPictFormat *fmt;
107 + int nvi;
108 + int i;
109 +
110 + XVisualInfo tpl = {
111 + .screen = xw.scr,
112 + .depth = 32,
113 + .class = TrueColor
114 + };
115 +
116 + vis = XGetVisualInfo(xw.dpy, VisualScreenMask | VisualD…
117 + xw.vis = NULL;
118 + for(i = 0; i < nvi; i ++) {
119 + fmt = XRenderFindVisualFormat(xw.dpy, vis[i].vi…
120 + if (fmt->type == PictTypeDirect && fmt->direct.…
121 + xw.vis = vis[i].visual;
122 + break;
123 + }
124 + }
125 +
126 + XFree(vis);
127 +
128 + if (! xw.vis) {
129 + fprintf(stderr, "Couldn't find ARGB visual.\n");
130 + exit(1);
131 + }
132 + }
133
134 /* font */
135 if(!FcInit())
136 @@ -2613,7 +2653,10 @@ xinit(void) {
137 xloadfonts(usedfont, 0);
138
139 /* colors */
140 - xw.cmap = XDefaultColormap(xw.dpy, xw.scr);
141 + if (! USE_ARGB)
142 + xw.cmap = XDefaultColormap(xw.dpy, xw.scr);
143 + else
144 + xw.cmap = XCreateColormap(xw.dpy, XRootWindow(xw.dpy, x…
145 xloadcols();
146
147 /* adjust fixed window geometry */
148 @@ -2647,7 +2690,7 @@ xinit(void) {
149 parent = opt_embed ? strtol(opt_embed, NULL, 0) : \
150 XRootWindow(xw.dpy, xw.scr);
151 xw.win = XCreateWindow(xw.dpy, parent, xw.fx, xw.fy,
152 - xw.w, xw.h, 0, XDefaultDepth(xw.dpy, xw.scr), I…
153 + xw.w, xw.h, 0, xw.depth, InputOutput,
154 xw.vis,
155 CWBackPixel | CWBorderPixel | CWBitGravity | CW…
156 | CWColormap,
157 @@ -2655,10 +2698,11 @@ xinit(void) {
158
159 memset(&gcvalues, 0, sizeof(gcvalues));
160 gcvalues.graphics_exposures = False;
161 - dc.gc = XCreateGC(xw.dpy, parent, GCGraphicsExposures,
162 + xw.buf = XCreatePixmap(xw.dpy, xw.win, xw.w, xw.h, xw.depth);
163 + dc.gc = XCreateGC(xw.dpy,
164 + (USE_ARGB)? xw.buf: parent,
165 + GCGraphicsExposures,
166 &gcvalues);
167 - xw.buf = XCreatePixmap(xw.dpy, xw.win, xw.w, xw.h,
168 - DefaultDepth(xw.dpy, xw.scr));
169 XSetForeground(xw.dpy, dc.gc, dc.col[defaultbg].pixel);
170 XFillRectangle(xw.dpy, xw.buf, dc.gc, 0, 0, xw.w, xw.h);
171
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.