Skip to content

Commit

Permalink
return status 2 if color selection was canceled
Browse files Browse the repository at this point in the history
should aid in scripting
  • Loading branch information
djpohly committed Aug 6, 2012
1 parent b5872d6 commit 245f7a2
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions stint.c
Expand Up @@ -50,16 +50,16 @@ main(int argc, char *argv[])
Cursor cross = XCreateFontCursor(dpy, XC_crosshair);

// Grab pointer clicking and motion events
if (XGrabPointer(dpy, root, False, ButtonPressMask | Button1MotionMask |
ButtonReleaseMask, GrabModeAsync, GrabModeAsync,
root, cross, CurrentTime)) {
if (XGrabPointer(dpy, root, False, ButtonPressMask | Button1MotionMask | ButtonReleaseMask,
GrabModeAsync, GrabModeAsync, root, cross, CurrentTime)) {
fprintf(stderr, "could not grab pointer\n");
rv = 1;
goto out_free;
}

// Wait for button press
XEvent ev;
int done = 0;
do {
XNextEvent(dpy, &ev);
} while (ev.type != ButtonPress);
Expand All @@ -73,11 +73,11 @@ main(int argc, char *argv[])
} while (ev.type != ButtonRelease || ev.xbutton.button != b);

// ... and cancel
goto out_ungrab;
done = 1;
rv = 2;
}

// Print colors until Button1 is released
int done = 0;
while (!done) {
XNextEvent(dpy, &ev);

Expand All @@ -91,7 +91,6 @@ main(int argc, char *argv[])
}
}

out_ungrab:
// Release the pointer grab
XUngrabPointer(dpy, CurrentTime);
out_free:
Expand Down

0 comments on commit 245f7a2

Please sign in to comment.