URI: 
       tAvoid unnecessary redraws - croptool - Image cropping tool
  HTML git clone git://lumidify.org/croptool.git (fast, but not encrypted)
  HTML git clone https://lumidify.org/git/croptool.git (encrypted, but very slow)
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
   DIR commit d3f4eabd38936fae96a96b94801bcb753d42cde1
   DIR parent 9abe5617bed41b35fe53c8830708fd6a6eb2ec0e
  HTML Author: lumidify <nobody@lumidify.org>
       Date:   Sat,  6 Mar 2021 19:02:07 +0100
       
       Avoid unnecessary redraws
       
       Diffstat:
         M croptool.c                          |      17 ++++++++++-------
       
       1 file changed, 10 insertions(+), 7 deletions(-)
       ---
   DIR diff --git a/croptool.c b/croptool.c
       t@@ -79,7 +79,7 @@ struct Selection {
                int orig_h;
                int scaled_w;
                int scaled_h;
       -        short valid;
       +        char valid;
        };
        
        static struct {
       t@@ -105,10 +105,11 @@ static struct {
                int cursor_x;
                int cursor_y;
                struct Point move_handle;
       -        short moving;
       -        short resizing;
       -        short lock_x;
       -        short lock_y;
       +        char moving;
       +        char resizing;
       +        char lock_x;
       +        char lock_y;
       +        char dirty;
                XColor col1;
                XColor col2;
                int cur_col;
       t@@ -510,6 +511,7 @@ static void
        queue_update(int x, int y, int w, int h) {
                if (state.cur_selection < 0 || !state.selections[state.cur_selection].valid)
                        return;
       +        state.dirty = 1;
                struct Selection *sel = &state.selections[state.cur_selection];
                if (x > sel->scaled_w || y > sel->scaled_h)
                        return;
       t@@ -524,6 +526,8 @@ static void
        redraw(void) {
                Imlib_Image buffer;
                Imlib_Updates current_update;
       +        if (!state.dirty)
       +                return;
                if (!state.cur_image || state.cur_selection < 0) {
                        /* clear the window completely */
                        XSetForeground(state.dpy, state.gc, BlackPixel(state.dpy, state.screen));
       t@@ -591,9 +595,8 @@ swap_buffers:
                        if (!XdbeSwapBuffers(state.dpy, &swap_info, 1))
                                fprintf(stderr, "Warning: Unable to swap buffers.\n");
                }
       -        #else
       -        ;
                #endif
       +        state.dirty = 0;
        }
        
        static void