aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xchord.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/xchord.c b/xchord.c
index 943b293..f8fc70b 100644
--- a/xchord.c
+++ b/xchord.c
@@ -34,12 +34,11 @@ main(int argc, char *argv[])
unsigned char mask[(XI_LASTEVENT+7)/8];
XEvent ev;
XGenericEventCookie *cookie;
- XIEvent *xiev;
XIEventMask evmasks[1];
XIRawEvent *rev;
dpy = XOpenDisplay(NULL);
- if (!dpy) {
+ if(!dpy){
fprintf(stderr, "could not open display");
return 1;
}
@@ -62,35 +61,34 @@ main(int argc, char *argv[])
p = 0;
/* watch for events */
- for (;;) {
+ for(;;){
XNextEvent(dpy, &ev);
XPutBackEvent(dpy, &ev);
- if (!XCheckTypedEvent(dpy, GenericEvent, &ev))
+ if(!XCheckTypedEvent(dpy, GenericEvent, &ev))
continue;
- if (cookie->type != GenericEvent || !XGetEventData(dpy, cookie))
+ if(cookie->type != GenericEvent || !XGetEventData(dpy, cookie))
continue;
- xiev = (XIEvent*)cookie->data;
- rev = (XIRawEvent*)xiev;
+ rev = (XIRawEvent*)cookie->data;
- switch (cookie->evtype) {
+ switch(cookie->evtype){
case XI_RawButtonPress:
/* 1 pressed (first step) */
- if (rev->detail == 1) p = 1;
+ if(rev->detail == 1) p = 1;
/* 1 + 3 pressed (second step) */
- if (p > 0 && rev->detail == 3) p = 2;
+ if(p > 0 && rev->detail == 3) p = 2;
break;
case XI_RawButtonRelease:
/* 1 pressed + 3 pressed + 3 released (third step) */
- if (p == 2 && rev->detail == 3) {
+ if(p == 2 && rev->detail == 3){
p = 3;
- if (vfork() == 0) {
+ if(vfork() == 0){
execlp("dwim", "dwim", NULL);
err(1, "execlp");
}
}
/* 1 released (reset) */
- if ((p == 1 || p == 3) && rev->detail == 1) p = 0;
+ if((p == 1 || p == 3) && rev->detail == 1) p = 0;
break;
}