diff --git a/.jules/bolt.md b/.jules/bolt.md new file mode 100644 index 0000000..c480f22 --- /dev/null +++ b/.jules/bolt.md @@ -0,0 +1,3 @@ +## 2026-01-13 - XSync vs XFlush in Window Managers +**Learning:** In X11 window managers, `XSync(dpy, False)` is a blocking call that waits for the X server to process all requests. This is often necessary for error handling or strict synchronization but is a major performance bottleneck for frequent operations like drawing or resizing. +**Action:** Use `XFlush(dpy)` instead of `XSync` where strict synchronization is not required (e.g., drawing `drw_map` or window configuration `resizeclient`). `XFlush` sends the requests to the server without waiting for a reply, significantly reducing latency and improving animation smoothness. 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) {