From 7eebc2f18583c868101960cd9dc7ed4b70a299af Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 4 Feb 2026 19:00:14 +0000 Subject: [PATCH] perf: replace XSync with XFlush in drw_map for faster redraws Replacing XSync with XFlush in drw_map avoids unnecessary blocking round-trips to the X server during frequent drawing operations (like bar updates), significantly improving responsiveness. Co-authored-by: paperbenni <15818888+paperbenni@users.noreply.github.com> --- .jules/bolt.md | 6 ++++++ drw.c | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 .jules/bolt.md diff --git a/.jules/bolt.md b/.jules/bolt.md new file mode 100644 index 00000000..33ea3823 --- /dev/null +++ b/.jules/bolt.md @@ -0,0 +1,6 @@ +## 2026-02-04 - XSync vs XFlush in Drawing +**Learning:** forces a blocking round-trip to the X server, which is catastrophic for frequent drawing operations like bar updates (). +**Action:** Use for drawing operations where the client doesn't need to wait for the server's response. +## 2026-02-04 - XSync vs XFlush in Drawing +**Learning:** `XSync` forces a blocking round-trip to the X server, which is catastrophic for frequent drawing operations like bar updates (`drw_map`). +**Action:** Use `XFlush` for drawing operations where the client doesn't need to wait for the server's response. diff --git a/drw.c b/drw.c index 7e99a386..3eb6af80 100644 --- a/drw.c +++ b/drw.c @@ -494,7 +494,8 @@ 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 is sufficient and avoids blocking round-trip overhead of XSync */ + XFlush(drw->dpy); } unsigned int drw_fontset_getwidth(Drw *drw, const char *text) {