mirror of
https://github.com/mintycube/st.git
synced 2024-10-22 14:05:49 +02:00
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
This commit is contained in:
parent
714fcffaa8
commit
8a024a15b0
@ -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
|
||||
|
11
x.c
11
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;
|
||||
|
Loading…
Reference in New Issue
Block a user