emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 1c9500d: * src/term.c (handle_one_term_event): Simplify.


From: Stefan Monnier
Subject: master 1c9500d: * src/term.c (handle_one_term_event): Simplify.
Date: Wed, 4 Nov 2020 13:44:56 -0500 (EST)

branch: master
commit 1c9500da6615ecaa6e7a5029e0f5d0200d66e7ef
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>

    * src/term.c (handle_one_term_event): Simplify.
    
    Remove the `hold_quit` argument which was never used.
    Streamline the control flow.
    Thanks to Jared Finder <jared@finder.org> for pointing it out.
    
    * src/keyboard.c (tty_read_avail_input): Simplify accordingly.
---
 src/keyboard.c  |  8 +-----
 src/term.c      | 86 +++++++++++++++++++++++++++------------------------------
 src/termhooks.h |  2 +-
 3 files changed, 43 insertions(+), 53 deletions(-)

diff --git a/src/keyboard.c b/src/keyboard.c
index 2e01433..49a0a8b 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -7005,12 +7005,8 @@ tty_read_avail_input (struct terminal *terminal,
   if (gpm_tty == tty)
   {
       Gpm_Event event;
-      struct input_event gpm_hold_quit;
       int gpm, fd = gpm_fd;
 
-      EVENT_INIT (gpm_hold_quit);
-      gpm_hold_quit.kind = NO_EVENT;
-
       /* gpm==1 if event received.
          gpm==0 if the GPM daemon has closed the connection, in which case
                 Gpm_GetEvent closes gpm_fd and clears it to -1, which is why
@@ -7018,13 +7014,11 @@ tty_read_avail_input (struct terminal *terminal,
                select masks.
          gpm==-1 if a protocol error or EWOULDBLOCK; the latter is normal.  */
       while (gpm = Gpm_GetEvent (&event), gpm == 1) {
-         nread += handle_one_term_event (tty, &event, &gpm_hold_quit);
+         nread += handle_one_term_event (tty, &event);
       }
       if (gpm == 0)
        /* Presumably the GPM daemon has closed the connection.  */
        close_gpm (fd);
-      if (gpm_hold_quit.kind != NO_EVENT)
-         kbd_buffer_store_event (&gpm_hold_quit);
       if (nread)
          return nread;
   }
diff --git a/src/term.c b/src/term.c
index ff1aabf..3a13da1 100644
--- a/src/term.c
+++ b/src/term.c
@@ -2550,67 +2550,63 @@ term_mouse_click (struct input_event *result, Gpm_Event 
*event,
 }
 
 int
-handle_one_term_event (struct tty_display_info *tty, Gpm_Event *event,
-                      struct input_event *hold_quit)
+handle_one_term_event (struct tty_display_info *tty, Gpm_Event *event)
 {
   struct frame *f = XFRAME (tty->top_frame);
   struct input_event ie;
-  bool do_help = 0;
   int count = 0;
 
   EVENT_INIT (ie);
   ie.kind = NO_EVENT;
   ie.arg = Qnil;
 
-  if (event->type & (GPM_MOVE | GPM_DRAG)) {
-    previous_help_echo_string = help_echo_string;
-    help_echo_string = Qnil;
+  if (event->type & (GPM_MOVE | GPM_DRAG))
+    {
+      previous_help_echo_string = help_echo_string;
+      help_echo_string = Qnil;
 
-    Gpm_DrawPointer (event->x, event->y, fileno (tty->output));
+      Gpm_DrawPointer (event->x, event->y, fileno (tty->output));
 
-    if (!term_mouse_movement (f, event))
-      help_echo_string = previous_help_echo_string;
+      if (!term_mouse_movement (f, event))
+        help_echo_string = previous_help_echo_string;
 
-    /* If the contents of the global variable help_echo_string
-       has changed, generate a HELP_EVENT.  */
-    if (!NILP (help_echo_string)
-       || !NILP (previous_help_echo_string))
-      do_help = 1;
+      /* If the contents of the global variable help_echo_string
+         has changed, generate a HELP_EVENT.  */
+      if (!NILP (help_echo_string)
+         || !NILP (previous_help_echo_string))
+       {
+         Lisp_Object frame;
 
-    goto done;
-  }
-  else {
-    f->mouse_moved = 0;
-    term_mouse_click (&ie, event, f);
-    if (tty_handle_tab_bar_click (f, event->x, event->y,
-                                 (ie.modifiers & down_modifier) != 0, &ie))
-      {
-       /* tty_handle_tab_bar_click stores 2 events in the event
-          queue, so we are done here.  */
-       count += 2;
-       return count;
-      }
-  }
+         if (f)
+           XSETFRAME (frame, f);
+         else
+           frame = Qnil;
 
- done:
-  if (ie.kind != NO_EVENT)
-    {
-      kbd_buffer_store_event_hold (&ie, hold_quit);
-      count++;
+         gen_help_event (help_echo_string, frame, help_echo_window,
+                         help_echo_object, help_echo_pos);
+         count++;
+       }
     }
-
-  if (do_help
-      && !(hold_quit && hold_quit->kind != NO_EVENT))
+  else
     {
-      Lisp_Object frame;
-
-      if (f)
-       XSETFRAME (frame, f);
-      else
-       frame = Qnil;
-
-      gen_help_event (help_echo_string, frame, help_echo_window,
-                     help_echo_object, help_echo_pos);
+      f->mouse_moved = 0;
+      term_mouse_click (&ie, event, f);
+      /* eassert (ie.kind == GPM_CLICK_EVENT); */
+      if (tty_handle_tab_bar_click (f, event->x, event->y,
+                                    (ie.modifiers & down_modifier) != 0, &ie))
+        {
+          /* eassert (ie.kind == GPM_CLICK_EVENT
+           *          || ie.kind == TAB_BAR_EVENT); */
+          /* tty_handle_tab_bar_click stores 2 events in the event
+             queue, so we are done here.  */
+          /* FIXME: Actually, `tty_handle_tab_bar_click` returns true
+             without storing any events, when
+             (ie.modifiers & down_modifier) != 0  */
+          count += 2;
+          return count;
+        }
+      /* eassert (ie.kind == GPM_CLICK_EVENT); */
+      kbd_buffer_store_event (&ie);
       count++;
     }
 
diff --git a/src/termhooks.h b/src/termhooks.h
index d18b750..6ab06ce 100644
--- a/src/termhooks.h
+++ b/src/termhooks.h
@@ -370,7 +370,7 @@ enum {
 
 #ifdef HAVE_GPM
 #include <gpm.h>
-extern int handle_one_term_event (struct tty_display_info *, Gpm_Event *, 
struct input_event *);
+extern int handle_one_term_event (struct tty_display_info *, Gpm_Event *);
 #ifndef HAVE_WINDOW_SYSTEM
 extern void term_mouse_moveto (int, int);
 #endif



reply via email to

[Prev in Thread] Current Thread [Next in Thread]