diff options
| author | uint <abhinav.prsai@gmail.com> | 2025-12-14 17:13:40 +0000 |
|---|---|---|
| committer | uint <abhinav.prsai@gmail.com> | 2025-12-14 17:13:40 +0000 |
| commit | b1ac729f34756ed63323c76386e631fda94a2adb (patch) | |
| tree | 66ec161cbe062acf6086a2f91fceac527c7e747f /xnap.c | |
| parent | 820cc7b5ec3b8ecb15ee7c0c021f0f93569148ae (diff) | |
add config.h, quit on right/middle click
Diffstat (limited to 'xnap.c')
| -rw-r--r-- | xnap.c | 15 |
1 files changed, 6 insertions, 9 deletions
@@ -6,6 +6,8 @@ #include <X11/keysym.h> #include <X11/Xutil.h> +#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); + } } } |
