diff options
-rw-r--r-- | xchord.c | 25 |
1 files changed, 15 insertions, 10 deletions
@@ -37,7 +37,7 @@ Window rwin; int main(int argc, char *argv[]) { - int p1; + int p; unsigned char mask[(XI_LASTEVENT+7)/8]; XEvent ev; XGenericEventCookie *cookie; @@ -63,7 +63,7 @@ main(int argc, char *argv[]) XFlush(dpy); cookie = &ev.xcookie; - p1 = 0; + p = 0; /* watch for events */ for (;;) { @@ -79,17 +79,22 @@ main(int argc, char *argv[]) switch (cookie->evtype) { case XI_RawButtonPress: - /* button 1 pressed */ - if (rev->detail == 1) p1 = 1; + /* 1 pressed (first step) */ + if (rev->detail == 1) p = 1; + /* 1 + 3 pressed (second step) */ + if (p > 0 && rev->detail == 3) p = 2; break; case XI_RawButtonRelease: - /* button 1 released */ - if (rev->detail == 1) p1 = 0; - /* button 1 pressed + 3 released */ - if (p1 && rev->detail == 3 && vfork() == 0) { - execlp("dwim", "dwim", NULL); - err(1, "execlp"); + /* 1 pressed + 3 pressed + 3 released (third step) */ + if (p == 2 && rev->detail == 3) { + p = 3; + if (vfork() == 0) { + execlp("dwim", "dwim", NULL); + err(1, "execlp"); + } } + /* 1 released (reset) */ + if (p == 3 && rev->detail == 1) p = 0; break; } |