Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .jules/bolt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 2026-01-31 - XSync vs XFlush in X11 Animations
**Learning:** `XSync(dpy, False)` is a blocking round-trip to the X server, while `XFlush(dpy)` sends requests asynchronously. In tight loops like animations (`animateclient` in `animation.c`) or interactive resizing (`resizeclient` in `client.c`), `XSync` can significantly degrade frame rates by forcing the client to wait for the server on every frame.
**Action:** Replace `XSync` with `XFlush` in performance-critical rendering/update paths where strict synchronization is not required for correctness. Ensure to verify that side effects (like event generation) are not implicitly relied upon by subsequent synchronous checks.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (typo): Consider rephrasing "Ensure to verify" to a more idiomatic form.

Consider changing it to "Ensure that you verify" or "Be sure to verify" for more natural, idiomatic wording.

5 changes: 4 additions & 1 deletion client.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,10 @@ 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);
/* Optimization: Use XFlush instead of XSync to avoid blocking round-trip to X server.
* This significantly improves performance during animations and mouse resizing.
*/
XFlush(dpy);
}

void updatetitle(Client *c) {
Expand Down
5 changes: 4 additions & 1 deletion drw.c
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,10 @@ 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);
/* Optimization: Use XFlush instead of XSync to avoid blocking round-trip.
* XCopyArea is efficient, and we just need to ensure the request is sent.
*/
XFlush(drw->dpy);
}

unsigned int drw_fontset_getwidth(Drw *drw, const char *text) {
Expand Down