aboutsummaryrefslogtreecommitdiff
path: root/patches
diff options
context:
space:
mode:
Diffstat (limited to 'patches')
-rw-r--r--patches/2bwm/nerd-patch.diff47
-rw-r--r--patches/st/bright.diff28
-rw-r--r--patches/st/ligatures.diff308
-rw-r--r--patches/st/xres.diff185
4 files changed, 568 insertions, 0 deletions
diff --git a/patches/2bwm/nerd-patch.diff b/patches/2bwm/nerd-patch.diff
new file mode 100644
index 0000000..a47cc14
--- /dev/null
+++ b/patches/2bwm/nerd-patch.diff
@@ -0,0 +1,47 @@
1diff --git a/config.h b/config.h
2index 0985d2e..baa77f8 100644
3--- a/config.h
4+++ b/config.h
5@@ -40,7 +40,10 @@ static const uint8_t borders[] = {3,5,5,4};
6 #define LOOK_INTO "WM_NAME"
7 static const char *ignore_names[] = {"bar", "xclock"};
8 ///--Menus and Programs---///
9-static const char *menucmd[] = { "", NULL };
10+// static const char *menucmd[] = { "", NULL };
11+static const char *terminal[] = { "st", NULL };
12+static const char *rofi_run[] = { "rofi", "-show", "run" };
13+static const char *rofi_window[] = { "rofi", "-show", "window" };
14 ///--Custom foo---///
15 static void halfandcentered(const Arg *arg)
16 {
17@@ -193,7 +196,10 @@ static key keys[] = {
18 { MOD |SHIFT, XK_Right, cursor_move, {.i=TWOBWM_CURSOR_RIGHT}},
19 { MOD |SHIFT, XK_Left, cursor_move, {.i=TWOBWM_CURSOR_LEFT}},
20 // Start programs
21- { MOD , XK_w, start, {.com = menucmd}},
22+ //{ MOD , XK_w, start, {.com = menucmd}},
23+ { MOD , XK_Return, start, {.com = terminal}},
24+ { MOD , XK_d, start, {.com = rofi_run}},
25+ { MOD , XK_i, start, {.com = rofi_window}},
26 // Exit or restart 2bwm
27 { MOD |CONTROL, XK_q, twobwm_exit, {.i=0}},
28 { MOD |CONTROL, XK_r, twobwm_restart, {.i=0}},
29@@ -215,7 +221,7 @@ static key keys[] = {
30 static Button buttons[] = {
31 { MOD ,XCB_BUTTON_INDEX_1, mousemotion, {.i=TWOBWM_MOVE}, false},
32 { MOD ,XCB_BUTTON_INDEX_3, mousemotion, {.i=TWOBWM_RESIZE}, false},
33- { 0 ,XCB_BUTTON_INDEX_3, start, {.com = menucmd}, true},
34+ { 0 ,XCB_BUTTON_INDEX_3, start, {.com = terminal}, true},
35 { MOD|SHIFT, XCB_BUTTON_INDEX_1, changeworkspace, {.i=0}, false},
36 { MOD|SHIFT, XCB_BUTTON_INDEX_3, changeworkspace, {.i=1}, false},
37 { MOD|ALT, XCB_BUTTON_INDEX_1, changescreen, {.i=1}, false},
38diff --git a/definitions.h b/definitions.h
39index a380a3a..8aa8a45 100644
40--- a/definitions.h
41+++ b/definitions.h
42@@ -1,4 +1,4 @@
43-#define WORKSPACES 10
44+#define WORKSPACES 6
45 #define BUTTONMASK XCB_EVENT_MASK_BUTTON_PRESS|XCB_EVENT_MASK_BUTTON_RELEASE
46 #define NET_WM_FIXED 0xffffffff // Value in WM hint which means this window is fixed on all workspaces.
47 #define TWOBWM_NOWS 0xfffffffe // This means we didn't get any window hint at all.
diff --git a/patches/st/bright.diff b/patches/st/bright.diff
new file mode 100644
index 0000000..77379d3
--- /dev/null
+++ b/patches/st/bright.diff
@@ -0,0 +1,28 @@
1From e8f3c86d93613eef5af187dfd2dba9ae9919a2ee Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?Rapha=C3=ABl=20Proust?= <[email protected]>
3Date: Sun, 27 Jan 2019 13:31:28 +0800
4Subject: [PATCH] Show bold not as bright
5
6---
7 x.c | 4 ----
8 1 file changed, 4 deletions(-)
9
10diff --git a/x.c b/x.c
11index 0422421..904e1dc 100644
12--- a/x.c
13+++ b/x.c
14@@ -1296,10 +1296,6 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i
15 bg = &dc.col[base.bg];
16 }
17
18- /* Change basic system colors [0-7] to bright system colors [8-15] */
19- if ((base.mode & ATTR_BOLD_FAINT) == ATTR_BOLD && BETWEEN(base.fg, 0, 7))
20- fg = &dc.col[base.fg + 8];
21-
22 if (IS_SET(MODE_REVERSE)) {
23 if (fg == &dc.col[defaultfg]) {
24 fg = &dc.col[defaultbg];
25--
262.20.1
27
28
diff --git a/patches/st/ligatures.diff b/patches/st/ligatures.diff
new file mode 100644
index 0000000..354443c
--- /dev/null
+++ b/patches/st/ligatures.diff
@@ -0,0 +1,308 @@
1diff --git a/Makefile b/Makefile
2index 470ac86..38240da 100644
3--- a/Makefile
4+++ b/Makefile
5@@ -4,7 +4,7 @@
6
7 include config.mk
8
9-SRC = st.c x.c
10+SRC = st.c x.c hb.c
11 OBJ = $(SRC:.c=.o)
12
13 all: options st
14@@ -22,7 +22,8 @@ config.h:
15 $(CC) $(STCFLAGS) -c $<
16
17 st.o: config.h st.h win.h
18-x.o: arg.h config.h st.h win.h
19+x.o: arg.h config.h st.h win.h hb.h
20+hb.o: st.h
21
22 $(OBJ): config.h config.mk
23
24diff --git a/config.mk b/config.mk
25index beafc35..3df5c83 100644
26--- a/config.mk
27+++ b/config.mk
28@@ -15,10 +15,12 @@ PKG_CONFIG = pkg-config
29 # includes and libs
30 INCS = -I$(X11INC) \
31 `$(PKG_CONFIG) --cflags fontconfig` \
32- `$(PKG_CONFIG) --cflags freetype2`
33+ `$(PKG_CONFIG) --cflags freetype2` \
34+ `$(PKG_CONFIG) --cflags harfbuzz`
35 LIBS = -L$(X11LIB) -lm -lrt -lX11 -lutil -lXft \
36 `$(PKG_CONFIG) --libs fontconfig` \
37- `$(PKG_CONFIG) --libs freetype2`
38+ `$(PKG_CONFIG) --libs freetype2` \
39+ `$(PKG_CONFIG) --libs harfbuzz`
40
41 # flags
42 STCPPFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=600
43diff --git a/hb.c b/hb.c
44new file mode 100644
45index 0000000..7df2828
46--- /dev/null
47+++ b/hb.c
48@@ -0,0 +1,136 @@
49+#include <stdlib.h>
50+#include <stdio.h>
51+#include <math.h>
52+#include <X11/Xft/Xft.h>
53+#include <hb.h>
54+#include <hb-ft.h>
55+
56+#include "st.h"
57+
58+void hbtransformsegment(XftFont *xfont, const Glyph *string, hb_codepoint_t *codepoints, int start, int length);
59+hb_font_t *hbfindfont(XftFont *match);
60+
61+typedef struct {
62+ XftFont *match;
63+ hb_font_t *font;
64+} HbFontMatch;
65+
66+static int hbfontslen = 0;
67+static HbFontMatch *hbfontcache = NULL;
68+
69+void
70+hbunloadfonts()
71+{
72+ for (int i = 0; i < hbfontslen; i++) {
73+ hb_font_destroy(hbfontcache[i].font);
74+ XftUnlockFace(hbfontcache[i].match);
75+ }
76+
77+ if (hbfontcache != NULL) {
78+ free(hbfontcache);
79+ hbfontcache = NULL;
80+ }
81+ hbfontslen = 0;
82+}
83+
84+hb_font_t *
85+hbfindfont(XftFont *match)
86+{
87+ for (int i = 0; i < hbfontslen; i++) {
88+ if (hbfontcache[i].match == match)
89+ return hbfontcache[i].font;
90+ }
91+
92+ /* Font not found in cache, caching it now. */
93+ hbfontcache = realloc(hbfontcache, sizeof(HbFontMatch) * (hbfontslen + 1));
94+ FT_Face face = XftLockFace(match);
95+ hb_font_t *font = hb_ft_font_create(face, NULL);
96+ if (font == NULL)
97+ die("Failed to load Harfbuzz font.");
98+
99+ hbfontcache[hbfontslen].match = match;
100+ hbfontcache[hbfontslen].font = font;
101+ hbfontslen += 1;
102+
103+ return font;
104+}
105+
106+void
107+hbtransform(XftGlyphFontSpec *specs, const Glyph *glyphs, size_t len, int x, int y)
108+{
109+ int start = 0, length = 1, gstart = 0;
110+ hb_codepoint_t *codepoints = calloc(len, sizeof(hb_codepoint_t));
111+
112+ for (int idx = 1, specidx = 1; idx < len; idx++) {
113+ if (glyphs[idx].mode & ATTR_WDUMMY) {
114+ length += 1;
115+ continue;
116+ }
117+
118+ if (specs[specidx].font != specs[start].font || ATTRCMP(glyphs[gstart], glyphs[idx]) || selected(x + idx, y) != selected(x + gstart, y)) {
119+ hbtransformsegment(specs[start].font, glyphs, codepoints, gstart, length);
120+
121+ /* Reset the sequence. */
122+ length = 1;
123+ start = specidx;
124+ gstart = idx;
125+ } else {
126+ length += 1;
127+ }
128+
129+ specidx++;
130+ }
131+
132+ /* EOL. */
133+ hbtransformsegment(specs[start].font, glyphs, codepoints, gstart, length);
134+
135+ /* Apply the transformation to glyph specs. */
136+ for (int i = 0, specidx = 0; i < len; i++) {
137+ if (glyphs[i].mode & ATTR_WDUMMY)
138+ continue;
139+
140+ if (codepoints[i] != specs[specidx].glyph)
141+ ((Glyph *)glyphs)[i].mode |= ATTR_LIGA;
142+
143+ specs[specidx++].glyph = codepoints[i];
144+ }
145+
146+ free(codepoints);
147+}
148+
149+void
150+hbtransformsegment(XftFont *xfont, const Glyph *string, hb_codepoint_t *codepoints, int start, int length)
151+{
152+ hb_font_t *font = hbfindfont(xfont);
153+ if (font == NULL)
154+ return;
155+
156+ Rune rune;
157+ ushort mode = USHRT_MAX;
158+ hb_buffer_t *buffer = hb_buffer_create();
159+ hb_buffer_set_direction(buffer, HB_DIRECTION_LTR);
160+
161+ /* Fill buffer with codepoints. */
162+ for (int i = start; i < (start+length); i++) {
163+ rune = string[i].u;
164+ mode = string[i].mode;
165+ if (mode & ATTR_WDUMMY)
166+ rune = 0x0020;
167+ hb_buffer_add_codepoints(buffer, &rune, 1, 0, 1);
168+ }
169+
170+ /* Shape the segment. */
171+ hb_shape(font, buffer, NULL, 0);
172+
173+ /* Get new glyph info. */
174+ hb_glyph_info_t *info = hb_buffer_get_glyph_infos(buffer, NULL);
175+
176+ /* Write new codepoints. */
177+ for (int i = 0; i < length; i++) {
178+ hb_codepoint_t gid = info[i].codepoint;
179+ codepoints[start+i] = gid;
180+ }
181+
182+ /* Cleanup. */
183+ hb_buffer_destroy(buffer);
184+}
185diff --git a/hb.h b/hb.h
186new file mode 100644
187index 0000000..b3e02d0
188--- /dev/null
189+++ b/hb.h
190@@ -0,0 +1,7 @@
191+#include <X11/Xft/Xft.h>
192+#include <hb.h>
193+#include <hb-ft.h>
194+
195+void hbunloadfonts();
196+void hbtransform(XftGlyphFontSpec *, const Glyph *, size_t, int, int);
197+
198diff --git a/st.c b/st.c
199index 2bf133f..747f7b4 100644
200--- a/st.c
201+++ b/st.c
202@@ -2599,7 +2599,8 @@ draw(void)
203
204 drawregion(0, 0, term.col, term.row);
205 xdrawcursor(cx, term.c.y, term.line[term.c.y][cx],
206- term.ocx, term.ocy, term.line[term.ocy][term.ocx]);
207+ term.ocx, term.ocy, term.line[term.ocy][term.ocx],
208+ term.line[term.ocy], term.col);
209 term.ocx = cx;
210 term.ocy = term.c.y;
211 xfinishdraw();
212diff --git a/st.h b/st.h
213index d978458..c9b279b 100644
214--- a/st.h
215+++ b/st.h
216@@ -11,7 +11,8 @@
217 #define DIVCEIL(n, d) (((n) + ((d) - 1)) / (d))
218 #define DEFAULT(a, b) (a) = (a) ? (a) : (b)
219 #define LIMIT(x, a, b) (x) = (x) < (a) ? (a) : (x) > (b) ? (b) : (x)
220-#define ATTRCMP(a, b) ((a).mode != (b).mode || (a).fg != (b).fg || \
221+#define ATTRCMP(a, b) (((a).mode & (~ATTR_WRAP) & (~ATTR_LIGA)) != ((b).mode & (~ATTR_WRAP) & (~ATTR_LIGA)) || \
222+ (a).fg != (b).fg || \
223 (a).bg != (b).bg)
224 #define TIMEDIFF(t1, t2) ((t1.tv_sec-t2.tv_sec)*1000 + \
225 (t1.tv_nsec-t2.tv_nsec)/1E6)
226@@ -33,6 +34,7 @@ enum glyph_attribute {
227 ATTR_WRAP = 1 << 8,
228 ATTR_WIDE = 1 << 9,
229 ATTR_WDUMMY = 1 << 10,
230+ ATTR_LIGA = 1 << 11,
231 ATTR_BOLD_FAINT = ATTR_BOLD | ATTR_FAINT,
232 };
233
234diff --git a/win.h b/win.h
235index a6ef1b9..bc0d180 100644
236--- a/win.h
237+++ b/win.h
238@@ -25,7 +25,7 @@ enum win_mode {
239
240 void xbell(void);
241 void xclipcopy(void);
242-void xdrawcursor(int, int, Glyph, int, int, Glyph);
243+void xdrawcursor(int, int, Glyph, int, int, Glyph, Line, int);
244 void xdrawline(Line, int, int, int);
245 void xfinishdraw(void);
246 void xloadcols(void);
247diff --git a/x.c b/x.c
248index e5f1737..3334a83 100644
249--- a/x.c
250+++ b/x.c
251@@ -19,6 +19,7 @@ char *argv0;
252 #include "arg.h"
253 #include "st.h"
254 #include "win.h"
255+#include "hb.h"
256
257 /* types used in config.h */
258 typedef struct {
259@@ -1031,6 +1032,9 @@ xunloadfont(Font *f)
260 void
261 xunloadfonts(void)
262 {
263+ /* Clear Harfbuzz font cache. */
264+ hbunloadfonts();
265+
266 /* Free the loaded fonts in the font cache. */
267 while (frclen > 0)
268 XftFontClose(xw.dpy, frc[--frclen].font);
269@@ -1229,7 +1233,7 @@ xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x
270 mode = glyphs[i].mode;
271
272 /* Skip dummy wide-character spacing. */
273- if (mode == ATTR_WDUMMY)
274+ if (mode & ATTR_WDUMMY)
275 continue;
276
277 /* Determine font for glyph if different from previous glyph. */
278@@ -1336,6 +1340,9 @@ xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x
279 numspecs++;
280 }
281
282+ /* Harfbuzz transformation for ligatures. */
283+ hbtransform(specs, glyphs, len, x, y);
284+
285 return numspecs;
286 }
287
288@@ -1485,14 +1492,17 @@ xdrawglyph(Glyph g, int x, int y)
289 }
290
291 void
292-xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og)
293+xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og, Line line, int len)
294 {
295 Color drawcol;
296
297 /* remove the old cursor */
298 if (selected(ox, oy))
299 og.mode ^= ATTR_REVERSE;
300- xdrawglyph(og, ox, oy);
301+
302+ /* Redraw the line where cursor was previously.
303+ * It will restore the ligatures broken by the cursor. */
304+ xdrawline(line, 0, oy, len);
305
306 if (IS_SET(MODE_HIDE))
307 return;
308
diff --git a/patches/st/xres.diff b/patches/st/xres.diff
new file mode 100644
index 0000000..bac5373
--- /dev/null
+++ b/patches/st/xres.diff
@@ -0,0 +1,185 @@
1From 2752a599ee01305a435729bfacf43b1dde7cf0ef Mon Sep 17 00:00:00 2001
2From: Benji Encalada Mora <[email protected]>
3Date: Thu, 4 Jun 2020 00:41:10 -0500
4Subject: [PATCH] fix: replace xfps and actionfps variables
5
6---
7 config.def.h | 36 ++++++++++++++++++++++++
8 x.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++---
9 2 files changed, 110 insertions(+), 4 deletions(-)
10
11diff --git a/config.def.h b/config.def.h
12index 6f05dce..9b99782 100644
13--- a/config.def.h
14+++ b/config.def.h
15@@ -168,6 +168,42 @@ static unsigned int defaultattr = 11;
16 */
17 static uint forcemousemod = ShiftMask;
18
19+/*
20+ * Xresources preferences to load at startup
21+ */
22+ResourcePref resources[] = {
23+ { "font", STRING, &font },
24+ { "color0", STRING, &colorname[0] },
25+ { "color1", STRING, &colorname[1] },
26+ { "color2", STRING, &colorname[2] },
27+ { "color3", STRING, &colorname[3] },
28+ { "color4", STRING, &colorname[4] },
29+ { "color5", STRING, &colorname[5] },
30+ { "color6", STRING, &colorname[6] },
31+ { "color7", STRING, &colorname[7] },
32+ { "color8", STRING, &colorname[8] },
33+ { "color9", STRING, &colorname[9] },
34+ { "color10", STRING, &colorname[10] },
35+ { "color11", STRING, &colorname[11] },
36+ { "color12", STRING, &colorname[12] },
37+ { "color13", STRING, &colorname[13] },
38+ { "color14", STRING, &colorname[14] },
39+ { "color15", STRING, &colorname[15] },
40+ { "background", STRING, &colorname[256] },
41+ { "foreground", STRING, &colorname[257] },
42+ { "cursorColor", STRING, &colorname[258] },
43+ { "termname", STRING, &termname },
44+ { "shell", STRING, &shell },
45+ { "minlatency", INTEGER, &minlatency },
46+ { "maxlatency", INTEGER, &maxlatency },
47+ { "blinktimeout", INTEGER, &blinktimeout },
48+ { "bellvolume", INTEGER, &bellvolume },
49+ { "tabspaces", INTEGER, &tabspaces },
50+ { "borderpx", INTEGER, &borderpx },
51+ { "cwscale", FLOAT, &cwscale },
52+ { "chscale", FLOAT, &chscale },
53+};
54+
55 /*
56 * Internal mouse shortcuts.
57 * Beware that overloading Button1 will disable the selection.
58diff --git a/x.c b/x.c
59index 210f184..76f167f 100644
60--- a/x.c
61+++ b/x.c
62@@ -14,6 +14,7 @@
63 #include <X11/keysym.h>
64 #include <X11/Xft/Xft.h>
65 #include <X11/XKBlib.h>
66+#include <X11/Xresource.h>
67
68 char *argv0;
69 #include "arg.h"
70@@ -45,6 +46,19 @@ typedef struct {
71 signed char appcursor; /* application cursor */
72 } Key;
73
74+/* Xresources preferences */
75+enum resource_type {
76+ STRING = 0,
77+ INTEGER = 1,
78+ FLOAT = 2
79+};
80+
81+typedef struct {
82+ char *name;
83+ enum resource_type type;
84+ void *dst;
85+} ResourcePref;
86+
87 /* X modifiers */
88 #define XK_ANY_MOD UINT_MAX
89 #define XK_NO_MOD 0
90@@ -828,8 +842,8 @@ xclear(int x1, int y1, int x2, int y2)
91 void
92 xhints(void)
93 {
94- XClassHint class = {opt_name ? opt_name : termname,
95- opt_class ? opt_class : termname};
96+ XClassHint class = {opt_name ? opt_name : "st",
97+ opt_class ? opt_class : "St"};
98 XWMHints wm = {.flags = InputHint, .input = 1};
99 XSizeHints *sizeh;
100
101@@ -1104,8 +1118,6 @@ xinit(int cols, int rows)
102 pid_t thispid = getpid();
103 XColor xmousefg, xmousebg;
104
105- if (!(xw.dpy = XOpenDisplay(NULL)))
106- die("can't open display\n");
107 xw.scr = XDefaultScreen(xw.dpy);
108 xw.vis = XDefaultVisual(xw.dpy, xw.scr);
109
110@@ -1964,6 +1976,59 @@ run(void)
111 }
112 }
113
114+int
115+resource_load(XrmDatabase db, char *name, enum resource_type rtype, void *dst)
116+{
117+ char **sdst = dst;
118+ int *idst = dst;
119+ float *fdst = dst;
120+
121+ char fullname[256];
122+ char fullclass[256];
123+ char *type;
124+ XrmValue ret;
125+
126+ snprintf(fullname, sizeof(fullname), "%s.%s",
127+ opt_name ? opt_name : "st", name);
128+ snprintf(fullclass, sizeof(fullclass), "%s.%s",
129+ opt_class ? opt_class : "St", name);
130+ fullname[sizeof(fullname) - 1] = fullclass[sizeof(fullclass) - 1] = '\0';
131+
132+ XrmGetResource(db, fullname, fullclass, &type, &ret);
133+ if (ret.addr == NULL || strncmp("String", type, 64))
134+ return 1;
135+
136+ switch (rtype) {
137+ case STRING:
138+ *sdst = ret.addr;
139+ break;
140+ case INTEGER:
141+ *idst = strtoul(ret.addr, NULL, 10);
142+ break;
143+ case FLOAT:
144+ *fdst = strtof(ret.addr, NULL);
145+ break;
146+ }
147+ return 0;
148+}
149+
150+void
151+config_init(void)
152+{
153+ char *resm;
154+ XrmDatabase db;
155+ ResourcePref *p;
156+
157+ XrmInitialize();
158+ resm = XResourceManagerString(xw.dpy);
159+ if (!resm)
160+ return;
161+
162+ db = XrmGetStringDatabase(resm);
163+ for (p = resources; p < resources + LEN(resources); p++)
164+ resource_load(db, p->name, p->type, p->dst);
165+}
166+
167 void
168 usage(void)
169 {
170@@ -2037,6 +2102,11 @@ run:
171
172 setlocale(LC_CTYPE, "");
173 XSetLocaleModifiers("");
174+
175+ if(!(xw.dpy = XOpenDisplay(NULL)))
176+ die("Can't open display\n");
177+
178+ config_init();
179 cols = MAX(cols, 1);
180 rows = MAX(rows, 1);
181 tnew(cols, rows);
182--
1832.26.2
184
185