From 714fcffaa8c2916760f448a1e03efcd6f33a0afe Mon Sep 17 00:00:00 2001 From: veltza <106755522+veltza@users.noreply.github.com> Date: Fri, 9 Aug 2024 10:12:51 +0300 Subject: [PATCH 1/2] Fix issue with columns and reflow that breaks sixels (#146) Fixes #145 --- st.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/st.c b/st.c index 02725e9..4721ee2 100644 --- a/st.c +++ b/st.c @@ -2748,7 +2748,7 @@ strhandle(void) } else { term.images = newimages; } - #if COLUMNS_PATCH && !REFLOW + #if COLUMNS_PATCH && !REFLOW_PATCH x2 = MIN(x2, term.maxcol) - 1; #else x2 = MIN(x2, term.col) - 1; From 8a024a15b0e67d7d1b4d85cdedc9e2ef2ae9ebde Mon Sep 17 00:00:00 2001 From: Bakkeby Date: Fri, 9 Aug 2024 22:06:40 +0200 Subject: [PATCH 2/2] fix BadMatch error when embedding on some windows When embedded, st fails with BadMatch error if the embedder's window has non-default colormap/depth/visual. This commit fixes that by creating st's window inside root and then reparent it into embedder. The reference window for dc.gc is also changed to match root's visuals. A similar commit had been made for dmenu[1]. See this issue[2] on github for context. [1]: https://git.suckless.org/dmenu/commit/0fe460dbd469a1d5b6a7140d0e1801935e4a923b.html [2]: https://github.com/phillbush/xfiles/issues/47 Ref. https://git.suckless.org/st/commit/a0274bc20e11d8672bb2953fdd1d3010c0e708c5.html --- README.md | 2 +- x.c | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 67cce1e..031778d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -Similar to [dwm-flexipatch](https://github.com/bakkeby/dwm-flexipatch) this st 0.9.2 (5dbcca4, 2024-05-01) project has a different take on st patching. It uses preprocessor directives to decide whether or not to include a patch during build time. Essentially this means that this build, for better or worse, contains both the patched _and_ the original code. The aim being that you can select which patches to include and the build will contain that code and nothing more. +Similar to [dwm-flexipatch](https://github.com/bakkeby/dwm-flexipatch) this st 0.9.2 (a0274bc, 2024-08-09) project has a different take on st patching. It uses preprocessor directives to decide whether or not to include a patch during build time. Essentially this means that this build, for better or worse, contains both the patched _and_ the original code. The aim being that you can select which patches to include and the build will contain that code and nothing more. For example to include the `alpha` patch then you would only need to flip this setting from 0 to 1 in [patches.h](https://github.com/bakkeby/st-flexipatch/blob/master/patches.def.h): ```c diff --git a/x.c b/x.c index 16eb15c..be1a6ba 100644 --- a/x.c +++ b/x.c @@ -1426,7 +1426,7 @@ xinit(int cols, int rows) #elif !SWAPMOUSE_PATCH Cursor cursor; #endif // HIDECURSOR_PATCH - Window parent; + Window parent, root; pid_t thispid = getpid(); #if !SWAPMOUSE_PATCH XColor xmousefg, xmousebg; @@ -1524,11 +1524,12 @@ xinit(int cols, int rows) xw.attrs.event_mask |= PointerMotionMask; #endif // OPENURLONCLICK_PATCH + root = XRootWindow(xw.dpy, xw.scr); #if !ALPHA_PATCH if (!(opt_embed && (parent = strtol(opt_embed, NULL, 0)))) - parent = XRootWindow(xw.dpy, xw.scr); + parent = root; #endif // ALPHA_PATCH - xw.win = XCreateWindow(xw.dpy, parent, xw.l, xw.t, + xw.win = XCreateWindow(xw.dpy, root, xw.l, xw.t, #if ALPHA_PATCH win.w, win.h, 0, xw.depth, InputOutput, #else @@ -1536,6 +1537,8 @@ xinit(int cols, int rows) #endif // ALPHA_PATCH xw.vis, CWBackPixel | CWBorderPixel | CWBitGravity | CWEventMask | CWColormap, &xw.attrs); + if (parent != root) + XReparentWindow(xw.dpy, xw.win, parent, xw.l, xw.t); memset(&gcvalues, 0, sizeof(gcvalues)); gcvalues.graphics_exposures = False; @@ -1548,7 +1551,7 @@ xinit(int cols, int rows) #endif // SINGLE_DRAWABLE_BUFFER_PATCH dc.gc = XCreateGC(xw.dpy, xw.buf, GCGraphicsExposures, &gcvalues); #else - dc.gc = XCreateGC(xw.dpy, parent, GCGraphicsExposures, + dc.gc = XCreateGC(xw.dpy, xw.win, GCGraphicsExposures, &gcvalues); #if SINGLE_DRAWABLE_BUFFER_PATCH xw.buf = xw.win;