diff --git a/.jules/bolt.md b/.jules/bolt.md new file mode 100644 index 0000000..b8f2743 --- /dev/null +++ b/.jules/bolt.md @@ -0,0 +1,3 @@ +## 2026-01-20 - XSync vs XFlush in Event-Driven Drawing +**Learning:** `XSync` is a blocking round-trip to the X server, while `XFlush` is asynchronous. In `instantwm`, `XSync` was used in `drw_map` (called on every bar redraw) and `resizeclient` (called on every window resize), causing significant performance degradation due to unnecessary waiting for server confirmation. +**Action:** Replace `XSync` with `XFlush` in high-frequency drawing/window management paths when immediate confirmation is not strictly required for logic correctness. diff --git a/client.c b/client.c index 13f1e27..c03e6b4 100644 --- a/client.c +++ b/client.c @@ -279,7 +279,7 @@ void resizeclient(Client *c, int x, int y, int w, int h) { XConfigureWindow(dpy, c->win, CWX | CWY | CWWidth | CWHeight | CWBorderWidth, &wc); configure(c); - XSync(dpy, False); + XFlush(dpy); } void updatetitle(Client *c) { diff --git a/drw.c b/drw.c index 7e99a38..e3f9501 100644 --- a/drw.c +++ b/drw.c @@ -494,7 +494,7 @@ void drw_map(Drw *drw, Window win, int x, int y, unsigned int w, } XCopyArea(drw->dpy, drw->drawable, win, drw->gc, x, y, w, h, x, y); - XSync(drw->dpy, False); + XFlush(drw->dpy); } unsigned int drw_fontset_getwidth(Drw *drw, const char *text) {