From b1ac729f34756ed63323c76386e631fda94a2adb Mon Sep 17 00:00:00 2001 From: uint Date: Sun, 14 Dec 2025 17:13:40 +0000 Subject: add config.h, quit on right/middle click --- config.h | 0 xnap.c | 15 ++++++--------- 2 files changed, 6 insertions(+), 9 deletions(-) create mode 100644 config.h diff --git a/config.h b/config.h new file mode 100644 index 0000000..e69de29 diff --git a/xnap.c b/xnap.c index 105173f..d4c0c06 100644 --- a/xnap.c +++ b/xnap.c @@ -6,6 +6,8 @@ #include #include +#include "config.h" + #define MIN(x, y) (x < y ? x : y) #define MAX(x, y) (x > y ? x : y) @@ -72,9 +74,6 @@ void compimg(void) if (!img) die("XGetImage failed"); - unsigned long p0 = XGetPixel(img, 0, 0); - fprintf(stderr, "first pixe =#%lx depth=%d bpp=%d\n", p0, img->depth, img->bits_per_pixel); - mkppm("img.ppm", img); XDestroyImage(img); quit(True); @@ -82,7 +81,7 @@ void compimg(void) void die(const char* s) { - fprintf(stderr, "xnap: %s", s); + fprintf(stderr, "xnap: %s\n", s); exit(EXIT_FAILURE); } @@ -125,11 +124,6 @@ void run(void) for (;;) { XNextEvent(dpy, &ev); - if (ev.type == KeyPress) { - KeySym ks = XLookupKeysym(&ev.xkey, 0); - if (ks == XK_Escape || ks == XK_q) - quit(True); - } unsigned int b = ev.xbutton.button; if (ev.type == ButtonPress && b == Button1) { /* start selecting */ @@ -145,6 +139,9 @@ void run(void) p.sel = False; compimg(); } + else if (ev.type == ButtonPress && (b == Button2 || b == Button3)) { /* quit */ + quit(True); + } } } -- cgit v1.2.3