diff options
| author | Lucas de Sena <lucas@seninha.org> | 2024-08-09 13:33:47 +0200 |
|---|---|---|
| committer | Hiltjo Posthuma <hiltjo@codemadness.org> | 2024-08-09 13:34:56 +0200 |
| commit | a0274bc20e11d8672bb2953fdd1d3010c0e708c5 (patch) | |
| tree | c2368d6273853e48c62103155b1a9a69d9d13d5e | |
| parent | support colons in SGR character attributes (diff) | |
| download | st-a0274bc20e11d8672bb2953fdd1d3010c0e708c5.tar.gz st-a0274bc20e11d8672bb2953fdd1d3010c0e708c5.zip | |
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
| -rw-r--r-- | x.c | 11 |
1 files changed, 7 insertions, 4 deletions
| @@ -1131,7 +1131,7 @@ xinit(int cols, int rows) | |||
| 1131 | { | 1131 | { |
| 1132 | XGCValues gcvalues; | 1132 | XGCValues gcvalues; |
| 1133 | Cursor cursor; | 1133 | Cursor cursor; |
| 1134 | Window parent; | 1134 | Window parent, root; |
| 1135 | pid_t thispid = getpid(); | 1135 | pid_t thispid = getpid(); |
| 1136 | XColor xmousefg, xmousebg; | 1136 | XColor xmousefg, xmousebg; |
| 1137 | 1137 | ||
| @@ -1168,16 +1168,19 @@ xinit(int cols, int rows) | |||
| 1168 | | ButtonMotionMask | ButtonPressMask | ButtonReleaseMask; | 1168 | | ButtonMotionMask | ButtonPressMask | ButtonReleaseMask; |
| 1169 | xw.attrs.colormap = xw.cmap; | 1169 | xw.attrs.colormap = xw.cmap; |
| 1170 | 1170 | ||
| 1171 | root = XRootWindow(xw.dpy, xw.scr); | ||
| 1171 | if (!(opt_embed && (parent = strtol(opt_embed, NULL, 0)))) | 1172 | if (!(opt_embed && (parent = strtol(opt_embed, NULL, 0)))) |
| 1172 | parent = XRootWindow(xw.dpy, xw.scr); | 1173 | parent = root; |
| 1173 | xw.win = XCreateWindow(xw.dpy, parent, xw.l, xw.t, | 1174 | xw.win = XCreateWindow(xw.dpy, root, xw.l, xw.t, |
| 1174 | win.w, win.h, 0, XDefaultDepth(xw.dpy, xw.scr), InputOutput, | 1175 | win.w, win.h, 0, XDefaultDepth(xw.dpy, xw.scr), InputOutput, |
| 1175 | xw.vis, CWBackPixel | CWBorderPixel | CWBitGravity | 1176 | xw.vis, CWBackPixel | CWBorderPixel | CWBitGravity |
| 1176 | | CWEventMask | CWColormap, &xw.attrs); | 1177 | | CWEventMask | CWColormap, &xw.attrs); |
| 1178 | if (parent != root) | ||
| 1179 | XReparentWindow(xw.dpy, xw.win, parent, xw.l, xw.t); | ||
| 1177 | 1180 | ||
| 1178 | memset(&gcvalues, 0, sizeof(gcvalues)); | 1181 | memset(&gcvalues, 0, sizeof(gcvalues)); |
| 1179 | gcvalues.graphics_exposures = False; | 1182 | gcvalues.graphics_exposures = False; |
| 1180 | dc.gc = XCreateGC(xw.dpy, parent, GCGraphicsExposures, | 1183 | dc.gc = XCreateGC(xw.dpy, xw.win, GCGraphicsExposures, |
| 1181 | &gcvalues); | 1184 | &gcvalues); |
| 1182 | xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h, | 1185 | xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h, |
| 1183 | DefaultDepth(xw.dpy, xw.scr)); | 1186 | DefaultDepth(xw.dpy, xw.scr)); |
