This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch master
in repository legacy-imlib2.

View the commit online.

commit dbeff07758c55648bd0928c79172ec1fe2e4e811
Author: Kim Woelders <[email protected]>
AuthorDate: Mon Nov 21 15:11:09 2022 +0100

    imlib2_view: Deal with all pending X events at once
    
    Sometimes processing of e.g. key events were deferred do to frame
    handling.
---
 src/bin/imlib2_view.c | 228 +++++++++++++++++++++++++-------------------------
 1 file changed, 116 insertions(+), 112 deletions(-)

diff --git a/src/bin/imlib2_view.c b/src/bin/imlib2_view.c
index 321d6b7..1c3ac59 100644
--- a/src/bin/imlib2_view.c
+++ b/src/bin/imlib2_view.c
@@ -682,133 +682,137 @@ main(int argc, char **argv)
         timeout = 0;
 
         XFlush(disp);
-        XNextEvent(disp, &ev);
-        switch (ev.type)
+        do
           {
-          default:
-             if (prog_x11_event(&ev))
-                goto quit;
-             break;
-          case KeyPress:
-             while (XCheckTypedWindowEvent(disp, win, KeyPress, &ev))
-                ;
-             key = XLookupKeysym(&ev.xkey, 0);
-             switch (key)
+             XNextEvent(disp, &ev);
+             switch (ev.type)
                {
                default:
+                  if (prog_x11_event(&ev))
+                     goto quit;
                   break;
-               case XK_q:
-               case XK_Escape:
-                  goto quit;
-               case XK_r:
-                  goto show_cur;
-               case XK_Right:
-                  goto show_next;
-               case XK_Left:
-                  goto show_prev;
-               case XK_p:
-                  animate = animated && !animate;
+               case KeyPress:
+                  while (XCheckTypedWindowEvent(disp, win, KeyPress, &ev))
+                     ;
+                  key = XLookupKeysym(&ev.xkey, 0);
+                  switch (key)
+                    {
+                    default:
+                       break;
+                    case XK_q:
+                    case XK_Escape:
+                       goto quit;
+                    case XK_r:
+                       goto show_cur;
+                    case XK_Right:
+                       goto show_next;
+                    case XK_Left:
+                       goto show_prev;
+                    case XK_p:
+                       animate = animated && !animate;
+                       break;
+                    case XK_Up:
+                       goto show_next_frame;
+                    case XK_Down:
+                       goto show_prev_frame;
+                    }
                   break;
-               case XK_Up:
-                  goto show_next_frame;
-               case XK_Down:
-                  goto show_prev_frame;
-               }
-             break;
-          case ButtonPress:
-             b = ev.xbutton.button;
-             x = ev.xbutton.x;
-             y = ev.xbutton.y;
-             if (b == 3)
-               {
-                  zoom_mode = 1;
-                  zx = x;
-                  zy = y;
-                  bg_pm_redraw(zx, zy, 0., 0);
-               }
-             break;
-          case ButtonRelease:
-             b = ev.xbutton.button;
-             if (b == 3)
-                zoom_mode = 0;
-             if (b == 1)
-                goto show_next;
-             if (b == 2)
-                goto show_prev;
-             break;
-          case MotionNotify:
-             while (XCheckTypedWindowEvent(disp, win, MotionNotify, &ev))
-                ;
-             x = ev.xmotion.x;
-             if (zoom_mode)
-               {
-                  zoom = ((double)x - (double)zx) / 32.0;
-                  if (zoom < 0)
-                     zoom = 1.0 + ((zoom * 32.0) / ((double)(zx + 1)));
-                  else
-                     zoom += 1.0;
-                  if (zoom <= 0.0001)
-                     zoom = 0.0001;
-
-                  bg_pm_redraw(zx, zy, zoom, 0);
-                  timeout = 200000;     /* .2 s */
-               }
-             break;
-
-           show_cur:
-             inc = 0;
-             goto show_next_prev;
-           show_next:
-             inc = 1;
-             goto show_next_prev;
-           show_prev:
-             inc = -1;
-             goto show_next_prev;
-           show_next_prev:
-             for (no2 = no;;)
-               {
-                  no2 += inc;
-                  if (no2 >= argc)
+               case ButtonPress:
+                  b = ev.xbutton.button;
+                  x = ev.xbutton.x;
+                  y = ev.xbutton.y;
+                  if (b == 3)
                     {
-                       inc = -1;
-                       continue;
+                       zoom_mode = 1;
+                       zx = x;
+                       zy = y;
+                       bg_pm_redraw(zx, zy, 0., 0);
                     }
-                  else if (no2 < 0)
+                  break;
+               case ButtonRelease:
+                  b = ev.xbutton.button;
+                  if (b == 3)
+                     zoom_mode = 0;
+                  if (b == 1)
+                     goto show_next;
+                  if (b == 2)
+                     goto show_prev;
+                  break;
+               case MotionNotify:
+                  while (XCheckTypedWindowEvent(disp, win, MotionNotify, &ev))
+                     ;
+                  x = ev.xmotion.x;
+                  if (zoom_mode)
                     {
-                       inc = 1;
-                       continue;
+                       zoom = ((double)x - (double)zx) / 32.0;
+                       if (zoom < 0)
+                          zoom = 1.0 + ((zoom * 32.0) / ((double)(zx + 1)));
+                       else
+                          zoom += 1.0;
+                       if (zoom <= 0.0001)
+                          zoom = 0.0001;
+
+                       bg_pm_redraw(zx, zy, zoom, 0);
+                       timeout = 200000;        /* .2 s */
                     }
-                  if (no2 == no && inc != 0)
-                     break;
-                  im2 = load_image(no2, argv[no2]);
-                  if (!im2)
+                  break;
+
+                show_cur:
+                  inc = 0;
+                  goto show_next_prev;
+                show_next:
+                  inc = 1;
+                  goto show_next_prev;
+                show_prev:
+                  inc = -1;
+                  goto show_next_prev;
+                show_next_prev:
+                  for (no2 = no;;)
                     {
-                       Vprintf("*** Error loading image: %s\n", argv[no2]);
-                       continue;
+                       no2 += inc;
+                       if (no2 >= argc)
+                         {
+                            inc = -1;
+                            continue;
+                         }
+                       else if (no2 < 0)
+                         {
+                            inc = 1;
+                            continue;
+                         }
+                       if (no2 == no && inc != 0)
+                          break;
+                       im2 = load_image(no2, argv[no2]);
+                       if (!im2)
+                         {
+                            Vprintf("*** Error loading image: %s\n", argv[no2]);
+                            continue;
+                         }
+                       zoom = 1.0;
+                       zoom_mode = 0;
+                       no = no2;
+                       im = im2;
+                       break;
                     }
-                  zoom = 1.0;
-                  zoom_mode = 0;
-                  no = no2;
-                  im = im2;
+                  break;
+                show_next_frame:
+                  inc = 1;
+                  goto show_next_prev_frame;
+                show_prev_frame:
+                  inc = -1;
+                  goto show_next_prev_frame;
+                show_next_prev_frame:
+                  if (!multiframe)
+                     break;
+                  if (!animated)
+                     image_width = 0;   /* Reset window size */
+                  im = load_image_frame(argv[no], finfo.frame_num, inc);
                   break;
                }
-             break;
-           show_next_frame:
-             inc = 1;
-             goto show_next_prev_frame;
-           show_prev_frame:
-             inc = -1;
-             goto show_next_prev_frame;
-           show_next_prev_frame:
-             if (!multiframe)
-                break;
-             if (!animated)
-                image_width = 0;        /* Reset window size */
-             im = load_image_frame(argv[no], finfo.frame_num, inc);
-             break;
           }
+        while (XPending(disp));
 
-        if (multiframe || XPending(disp))
+        if (multiframe)
            continue;
 
         xfd = ConnectionNumber(disp);

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to