commit 310ec860001ad6825d96aae99984dca9121bdc6f
parent b8b111ce2aa1e1f183c8d219259864f1b729c946
Author: Andrew Laack <andrew@laack.co>
Date: Tue, 15 Sep 2026 09:06:29 -0500
Added retry patch to make xl work with dwm
Diffstat:
| M | main.c | | | 25 | ++++++++++++++++++++++--- |
1 file changed, 22 insertions(+), 3 deletions(-)
diff --git a/main.c b/main.c
@@ -63,9 +63,28 @@ main(int argc, char *argv[])
}
root = DefaultRootWindow(display);
- XGrabPointer(display, root, 1, ButtonPress, GrabModeAsync, GrabModeAsync, None, None, CurrentTime);
- XGrabKeyboard(display, root, 0, GrabModeAsync, GrabModeAsync, CurrentTime);
- XSelectInput(display, root, KeyPressMask);
+ for (i = 0; i < 1000; i++) {
+ if (XGrabPointer(display, root, 1, ButtonPress, GrabModeAsync,
+ GrabModeAsync, None, None, CurrentTime) == GrabSuccess)
+ break;
+ usleep(1000);
+ }
+ if (i == 1000) {
+ fprintf(stderr, "could not grab pointer\n");
+ exit(1);
+ }
+
+ for (i = 0; i < 1000; i++) {
+ if (XGrabKeyboard(display, root, 0, GrabModeAsync,
+ GrabModeAsync, CurrentTime) == GrabSuccess)
+ break;
+ usleep(1000);
+ }
+ if (i == 1000) {
+ XUngrabPointer(display, CurrentTime);
+ fprintf(stderr, "could not grab keyboard\n");
+ exit(1);
+ }
while (XNextEvent(display, &ev), 1) {
if (ev.type == KeyPress) {