croptool

Image cropping tool
git clone git://lumidify.org/croptool.git (fast, but not encrypted)
git clone https://lumidify.org/git/croptool.git (encrypted, but very slow)
Log | Files | Refs | README | LICENSE

commit 022ad164b6516bbb4c5109e45c68248c17ff7115
parent 71d1f49b960b895f769450c895a010469b2fd9a4
Author: lumidify <nobody@lumidify.org>
Date:   Fri, 18 Aug 2023 08:55:37 +0200

Exit when pressing 'q'

Diffstat:
MLICENSE | 2+-
Mcroptool.1 | 4+++-
Mcroptool.c | 11+++++++----
3 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/LICENSE b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2021-2022 lumidify <nobody@lumidify.org> +Copyright (c) 2021-2023 lumidify <nobody@lumidify.org> Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above diff --git a/croptool.1 b/croptool.1 @@ -1,4 +1,4 @@ -.Dd January 13, 2022 +.Dd August 18, 2023 .Dt CROPTOOL 1 .Os .Sh NAME @@ -120,6 +120,8 @@ Delete the cropping rectangle of the current image. Redraw the window. This is useful when automatic redrawing is disabled with .Fl m . +.It q +Exit the program. .El .Sh MOUSE ACTIONS .Bl -tag -width Ds diff --git a/croptool.c b/croptool.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 lumidify <nobody@lumidify.org> + * Copyright (c) 2021-2023 lumidify <nobody@lumidify.org> * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -160,7 +160,7 @@ static void drag_motion(XEvent event); static void resize_window(int w, int h); static void button_release(void); static void button_press(XEvent event); -static void key_press(XEvent event); +static int key_press(XEvent event); static void queue_update(int x, int y, int w, int h); static int parse_int(const char *str, int min, int max, int *value); @@ -273,7 +273,7 @@ mainloop(void) { drag_motion(event); break; case KeyPress: - key_press(event); + running = key_press(event); break; case ClientMessage: if ((Atom)event.xclient.data.l[0] == state.wm_delete_msg) @@ -1103,7 +1103,7 @@ switch_color(void) { queue_update(0, 0, state.window_w, state.window_h); } -static void +static int key_press(XEvent event) { XWindowAttributes attrs; char buf[32]; @@ -1135,7 +1135,10 @@ key_press(XEvent event) { size didn't change */ queue_update(0, 0, state.window_w, state.window_h); break; + case XK_q: + return 0; default: break; } + return 1; }