]> git.eshelyaron.com Git - emacs.git/commitdiff
Revert “Avoid some union buffered_input_event uses”
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 4 Mar 2025 06:20:08 +0000 (22:20 -0800)
committerEshel Yaron <me@eshelyaron.com>
Tue, 4 Mar 2025 21:05:41 +0000 (22:05 +0100)
Revert my commit 29a9fd4f4ba17822eca0f00c2037da3868bd874e
and the following commit 1ec0889e7b786d79351cee3ed4964d82295f059f.
This fixes a bug where ‘emacs -nw’ would sometimes freeze when Emacs is
configured with ‘--with-pgtk --enable-link-time-optimization
--disable-gc-mark-trace’ on GNU/Linux x86-64 (Bug#76729).
As it is not yet clear whether this freeze is due to an Emacs bug that
I introduced, or due to GCC bug 117423
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117423>,
play it safe for now and revert to the previous state.

(cherry picked from commit 9415941a9c65b72a3bc20ae0ec1765f3c0ed657d)

src/androidterm.c
src/gtkutil.c
src/keyboard.c
src/keyboard.h
src/pgtkterm.c
src/xterm.c

index 7fd61ee6d1c738d4b3293a47779faa443f98f4ac..884d8f8d71817ad7ea843dea532125b79406d976 100644 (file)
@@ -841,7 +841,7 @@ handle_one_android_event (struct android_display_info *dpyinfo,
   union android_event configureEvent;
   struct frame *f, *any, *mouse_frame;
   Mouse_HLInfo *hlinfo;
-  struct input_event inev;
+  union buffered_input_event inev;
   int modifiers, count, do_help;
   struct android_touch_point *touchpoint, **last;
   Lisp_Object window;
@@ -865,7 +865,7 @@ handle_one_android_event (struct android_display_info *dpyinfo,
   if (any && any->wait_event_type == event->type)
     any->wait_event_type = 0; /* Indicates we got it.  */
 
-  EVENT_INIT (inev);
+  EVENT_INIT (inev.ie);
 
   switch (event->type)
     {
@@ -936,8 +936,8 @@ handle_one_android_event (struct android_display_info *dpyinfo,
        if (!FRAME_TOOLTIP_P (f)
            && (old_left != f->left_pos || old_top != f->top_pos))
          {
-           inev.kind = MOVE_FRAME_EVENT;
-           XSETFRAME (inev.frame_or_window, f);
+           inev.ie.kind = MOVE_FRAME_EVENT;
+           XSETFRAME (inev.ie.frame_or_window, f);
          }
 
        if (f && FRAME_OUTPUT_DATA (f)->need_cursor_updates)
@@ -996,10 +996,10 @@ handle_one_android_event (struct android_display_info *dpyinfo,
        memset (&compose_status, 0, sizeof (compose_status));
 
       /* Common for all keysym input events.  */
-      XSETFRAME (inev.frame_or_window, any);
-      inev.modifiers
+      XSETFRAME (inev.ie.frame_or_window, any);
+      inev.ie.modifiers
        = android_android_to_emacs_modifiers (dpyinfo, modifiers);
-      inev.timestamp = event->xkey.time;
+      inev.ie.timestamp = event->xkey.time;
 
       keysym = event->xkey.keycode;
 
@@ -1033,8 +1033,8 @@ handle_one_android_event (struct android_display_info *dpyinfo,
 
        if (event->xkey.keycode == (uint32_t) -1)
          {
-           inev.kind = PREEDIT_TEXT_EVENT;
-           inev.arg = Qnil;
+           inev.ie.kind = PREEDIT_TEXT_EVENT;
+           inev.ie.arg = Qnil;
 
            /* If text was looked up, decode it and make it the
               preedit text.  */
@@ -1042,7 +1042,7 @@ handle_one_android_event (struct android_display_info *dpyinfo,
            if (status_return == ANDROID_LOOKUP_CHARS && nchars)
              {
                copy_bufptr[nchars] = 0;
-               inev.arg = from_unicode_buffer (copy_bufptr);
+               inev.ie.arg = from_unicode_buffer (copy_bufptr);
              }
 
            goto done_keysym;
@@ -1061,11 +1061,11 @@ handle_one_android_event (struct android_display_info *dpyinfo,
          /* Deal with characters.  */
 
          if (copy_bufptr[0] < 128)
-           inev.kind = ASCII_KEYSTROKE_EVENT;
+           inev.ie.kind = ASCII_KEYSTROKE_EVENT;
          else
-           inev.kind = MULTIBYTE_CHAR_KEYSTROKE_EVENT;
+           inev.ie.kind = MULTIBYTE_CHAR_KEYSTROKE_EVENT;
 
-         inev.code = copy_bufptr[0];
+         inev.ie.code = copy_bufptr[0];
        }
       else if (nchars < 2 && keysym)
        {
@@ -1075,8 +1075,8 @@ handle_one_android_event (struct android_display_info *dpyinfo,
 
          /* Next, deal with special ``characters'' by giving the
             keycode to keyboard.c.  */
-         inev.kind = NON_ASCII_KEYSTROKE_EVENT;
-         inev.code = keysym;
+         inev.ie.kind = NON_ASCII_KEYSTROKE_EVENT;
+         inev.ie.code = keysym;
        }
       else
        {
@@ -1084,25 +1084,25 @@ handle_one_android_event (struct android_display_info *dpyinfo,
 
          for (i = 0; i < nchars; ++i)
            {
-             inev.kind = (SINGLE_BYTE_CHAR_P (copy_bufptr[i])
-                          ? ASCII_KEYSTROKE_EVENT
-                          : MULTIBYTE_CHAR_KEYSTROKE_EVENT);
-             inev.code = copy_bufptr[i];
+             inev.ie.kind = (SINGLE_BYTE_CHAR_P (copy_bufptr[i])
+                             ? ASCII_KEYSTROKE_EVENT
+                             : MULTIBYTE_CHAR_KEYSTROKE_EVENT);
+             inev.ie.code = copy_bufptr[i];
 
              /* If the character is actually '\n', then change this
                 to RET.  */
 
              if (copy_bufptr[i] == '\n')
                {
-                 inev.kind = NON_ASCII_KEYSTROKE_EVENT;
-                 inev.code = 66;
+                 inev.ie.kind = NON_ASCII_KEYSTROKE_EVENT;
+                 inev.ie.code = 66;
                }
 
-             kbd_buffer_store_event_hold (&inev, hold_quit);
+             kbd_buffer_store_buffered_event (&inev, hold_quit);
            }
 
          count += nchars;
-         inev.kind = NO_EVENT;  /* Already stored above.  */
+         inev.ie.kind = NO_EVENT;  /* Already stored above.  */
        }
 
       goto done_keysym;
@@ -1122,7 +1122,7 @@ handle_one_android_event (struct android_display_info *dpyinfo,
 
     case ANDROID_FOCUS_IN:
     case ANDROID_FOCUS_OUT:
-      android_detect_focus_change (dpyinfo, any, event, &inev);
+      android_detect_focus_change (dpyinfo, any, event, &inev.ie);
       goto OTHER;
 
     case ANDROID_WINDOW_ACTION:
@@ -1150,8 +1150,8 @@ handle_one_android_event (struct android_display_info *dpyinfo,
              if (!f)
                goto OTHER;
 
-             inev.kind = DELETE_WINDOW_EVENT;
-             XSETFRAME (inev.frame_or_window, f);
+             inev.ie.kind = DELETE_WINDOW_EVENT;
+             XSETFRAME (inev.ie.frame_or_window, f);
            }
        }
 
@@ -1210,8 +1210,8 @@ handle_one_android_event (struct android_display_info *dpyinfo,
                  && !EQ (window, last_mouse_window)
                  && !EQ (window, selected_window))
                {
-                 inev.kind = SELECT_WINDOW_EVENT;
-                 inev.frame_or_window = window;
+                 inev.ie.kind = SELECT_WINDOW_EVENT;
+                 inev.ie.frame_or_window = window;
                }
 
              /* Remember the last window where we saw the mouse.  */
@@ -1392,10 +1392,10 @@ handle_one_android_event (struct android_display_info *dpyinfo,
          if (!(tab_bar_p && NILP (tab_bar_arg)) && !tool_bar_p)
            if (! popup_activated ())
              {
-               android_construct_mouse_click (&inev, &event->xbutton, f);
+               android_construct_mouse_click (&inev.ie, &event->xbutton, f);
 
                if (!NILP (tab_bar_arg))
-                 inev.arg = tab_bar_arg;
+                 inev.ie.arg = tab_bar_arg;
              }
        }
 
@@ -1438,8 +1438,8 @@ handle_one_android_event (struct android_display_info *dpyinfo,
          /* Simply update the tool position and send an update.  */
          touchpoint->x = event->touch.x;
          touchpoint->y = event->touch.y;
-         android_update_tools (any, &inev);
-         inev.timestamp = event->touch.time;
+         android_update_tools (any, &inev.ie);
+         inev.ie.timestamp = event->touch.time;
 
          goto OTHER;
        }
@@ -1512,12 +1512,12 @@ handle_one_android_event (struct android_display_info *dpyinfo,
        }
 
       /* Now generate the Emacs event.  */
-      inev.kind = TOUCHSCREEN_BEGIN_EVENT;
-      inev.timestamp = event->touch.time;
-      XSETFRAME (inev.frame_or_window, any);
-      XSETINT (inev.x, event->touch.x);
-      XSETINT (inev.y, event->touch.y);
-      XSETINT (inev.arg, event->touch.pointer_id);
+      inev.ie.kind = TOUCHSCREEN_BEGIN_EVENT;
+      inev.ie.timestamp = event->touch.time;
+      XSETFRAME (inev.ie.frame_or_window, any);
+      XSETINT (inev.ie.x, event->touch.x);
+      XSETINT (inev.ie.y, event->touch.y);
+      XSETINT (inev.ie.arg, event->touch.pointer_id);
 
       goto OTHER;
 
@@ -1540,8 +1540,8 @@ handle_one_android_event (struct android_display_info *dpyinfo,
 
       touchpoint->x = event->touch.x;
       touchpoint->y = event->touch.y;
-      android_update_tools (any, &inev);
-      inev.timestamp = event->touch.time;
+      android_update_tools (any, &inev.ie);
+      inev.ie.timestamp = event->touch.time;
 
       goto OTHER;
 
@@ -1583,18 +1583,18 @@ handle_one_android_event (struct android_display_info *dpyinfo,
                 grabbed by the tool bar).  */
              xfree (touchpoint);
 
-             inev.kind = TOUCHSCREEN_END_EVENT;
-             inev.timestamp = event->touch.time;
+             inev.ie.kind = TOUCHSCREEN_END_EVENT;
+             inev.ie.timestamp = event->touch.time;
 
              /* Report whether the sequence has been canceled.  */
 
              if (event->touch.flags & ANDROID_TOUCH_SEQUENCE_CANCELED)
-               inev.modifiers = 1;
+               inev.ie.modifiers = 1;
 
-             XSETFRAME (inev.frame_or_window, any);
-             XSETINT (inev.x, event->touch.x);
-             XSETINT (inev.y, event->touch.y);
-             XSETINT (inev.arg, event->touch.pointer_id);
+             XSETFRAME (inev.ie.frame_or_window, any);
+             XSETINT (inev.ie.x, event->touch.x);
+             XSETINT (inev.ie.y, event->touch.y);
+             XSETINT (inev.ie.arg, event->touch.pointer_id);
 
              /* Break out of the loop.  */
              goto OTHER;
@@ -1643,24 +1643,24 @@ handle_one_android_event (struct android_display_info *dpyinfo,
            }
 
          /* Determine what kind of event to send.  */
-         inev.kind = ((fabs (wheel_event_y)
+         inev.ie.kind = ((fabs (wheel_event_y)
                           >= fabs (wheel_event_x))
                          ? WHEEL_EVENT : HORIZ_WHEEL_EVENT);
-         inev.timestamp = event->wheel.time;
+         inev.ie.timestamp = event->wheel.time;
 
          /* Set the event coordinates.  */
-         XSETINT (inev.x, event->wheel.x);
-         XSETINT (inev.y, event->wheel.y);
+         XSETINT (inev.ie.x, event->wheel.x);
+         XSETINT (inev.ie.y, event->wheel.y);
 
          /* Set the frame.  */
-         XSETFRAME (inev.frame_or_window, any);
+         XSETFRAME (inev.ie.frame_or_window, any);
 
          /* Figure out the scroll direction.  */
-         inev.modifiers = (signbit ((fabs (wheel_event_x)
-                                     >= fabs (wheel_event_y))
-                                    ? wheel_event_x
-                                    : wheel_event_y)
-                           ? down_modifier : up_modifier);
+         inev.ie.modifiers = (signbit ((fabs (wheel_event_x)
+                                        >= fabs (wheel_event_y))
+                                       ? wheel_event_x
+                                       : wheel_event_y)
+                              ? down_modifier : up_modifier);
 
          /* Figure out how much to scale the deltas by.  */
          window = window_from_coordinates (any, event->wheel.x,
@@ -1678,14 +1678,16 @@ handle_one_android_event (struct android_display_info *dpyinfo,
          scroll_unit = pow (scroll_height, 2.0 / 3.0);
 
          /* Add the keyboard modifiers.  */
-         inev.modifiers
+         inev.ie.modifiers
            |= android_android_to_emacs_modifiers (dpyinfo,
                                                   event->wheel.state);
 
          /* Finally include the scroll deltas.  */
-         inev.arg = list3 (Qnil,
-                           make_float (wheel_event_x * scroll_unit),
-                           make_float (wheel_event_y * scroll_unit));
+         inev.ie.arg = list3 (Qnil,
+                              make_float (wheel_event_x
+                                          * scroll_unit),
+                              make_float (wheel_event_y
+                                          * scroll_unit));
 
          wheel_event_x = 0.0;
          wheel_event_y = 0.0;
@@ -1705,8 +1707,8 @@ handle_one_android_event (struct android_display_info *dpyinfo,
       SET_FRAME_VISIBLE (any, false);
       SET_FRAME_ICONIFIED (any, true);
 
-      inev.kind = ICONIFY_EVENT;
-      XSETFRAME (inev.frame_or_window, any);
+      inev.ie.kind = ICONIFY_EVENT;
+      XSETFRAME (inev.ie.frame_or_window, any);
       goto OTHER;
 
     case ANDROID_DEICONIFIED:
@@ -1720,8 +1722,8 @@ handle_one_android_event (struct android_display_info *dpyinfo,
       SET_FRAME_VISIBLE (any, true);
       SET_FRAME_ICONIFIED (any, false);
 
-      inev.kind = DEICONIFY_EVENT;
-      XSETFRAME (inev.frame_or_window, any);
+      inev.ie.kind = DEICONIFY_EVENT;
+      XSETFRAME (inev.ie.frame_or_window, any);
       goto OTHER;
 
       /* Context menu handling.  */
@@ -1769,12 +1771,12 @@ handle_one_android_event (struct android_display_info *dpyinfo,
        goto OTHER;
 
       /* Generate a drag and drop event to convey its position.  */
-      inev.kind = DRAG_N_DROP_EVENT;
-      XSETFRAME (inev.frame_or_window, any);
-      inev.timestamp = ANDROID_CURRENT_TIME;
-      XSETINT (inev.x, event->dnd.x);
-      XSETINT (inev.y, event->dnd.y);
-      inev.arg = Fcons (inev.x, inev.y);
+      inev.ie.kind = DRAG_N_DROP_EVENT;
+      XSETFRAME (inev.ie.frame_or_window, any);
+      inev.ie.timestamp = ANDROID_CURRENT_TIME;
+      XSETINT (inev.ie.x, event->dnd.x);
+      XSETINT (inev.ie.y, event->dnd.y);
+      inev.ie.arg = Fcons (inev.ie.x, inev.ie.y);
       goto OTHER;
 
     case ANDROID_DND_URI_EVENT:
@@ -1790,15 +1792,15 @@ handle_one_android_event (struct android_display_info *dpyinfo,
         content or file URI or a string to be inserted.  Generate an
         event with this information.  */
 
-      inev.kind = DRAG_N_DROP_EVENT;
-      XSETFRAME (inev.frame_or_window, any);
-      inev.timestamp = ANDROID_CURRENT_TIME;
-      XSETINT (inev.x, event->dnd.x);
-      XSETINT (inev.y, event->dnd.y);
-      inev.arg = Fcons ((event->type == ANDROID_DND_TEXT_EVENT
-                        ? Qtext : Quri),
-                       android_decode_utf16 (event->dnd.uri_or_string,
-                                             event->dnd.length));
+      inev.ie.kind = DRAG_N_DROP_EVENT;
+      XSETFRAME (inev.ie.frame_or_window, any);
+      inev.ie.timestamp = ANDROID_CURRENT_TIME;
+      XSETINT (inev.ie.x, event->dnd.x);
+      XSETINT (inev.ie.y, event->dnd.y);
+      inev.ie.arg = Fcons ((event->type == ANDROID_DND_TEXT_EVENT
+                           ? Qtext : Quri),
+                          android_decode_utf16 (event->dnd.uri_or_string,
+                                                event->dnd.length));
       free (event->dnd.uri_or_string);
       goto OTHER;
 
@@ -1806,14 +1808,15 @@ handle_one_android_event (struct android_display_info *dpyinfo,
     case ANDROID_NOTIFICATION_ACTION:
 
       if (event->notification.type == ANDROID_NOTIFICATION_DELETED)
-       android_notification_deleted (&event->notification, &inev);
+       android_notification_deleted (&event->notification, &inev.ie);
       else
        {
          Lisp_Object action;
 
          action = android_decode_utf16 (event->notification.action,
                                         event->notification.length);
-         android_notification_action (&event->notification, &inev, action);
+         android_notification_action (&event->notification, &inev.ie,
+                                      action);
        }
 
       /* Free dynamically allocated data.  */
@@ -1826,9 +1829,9 @@ handle_one_android_event (struct android_display_info *dpyinfo,
     }
 
  OTHER:
-  if (inev.kind != NO_EVENT)
+  if (inev.ie.kind != NO_EVENT)
     {
-      kbd_buffer_store_event_hold (&inev, hold_quit);
+      kbd_buffer_store_buffered_event (&inev, hold_quit);
       count++;
     }
 
index 164531aaeb3c65ba1319d97855889b65fcfeecd4..0770874eb401c79eb52957b5da58fc4f110c0423 100644 (file)
@@ -6382,7 +6382,7 @@ xg_widget_key_press_event_cb (GtkWidget *widget, GdkEvent *event,
 {
   Lisp_Object tail, tem;
   struct frame *f = NULL;
-  struct input_event inev;
+  union buffered_input_event inev;
   guint keysym = event->key.keyval;
   unsigned int xstate;
   gunichar uc;
@@ -6419,15 +6419,15 @@ xg_widget_key_press_event_cb (GtkWidget *widget, GdkEvent *event,
       && !FRAME_DISPLAY_INFO (f)->prefer_native_input)
     return true;
 
-  EVENT_INIT (inev);
-  XSETFRAME (inev.frame_or_window, f);
+  EVENT_INIT (inev.ie);
+  XSETFRAME (inev.ie.frame_or_window, f);
 
   xstate = xg_virtual_mods_to_x (FRAME_DISPLAY_INFO (f),
                                 event->key.state);
 
-  inev.modifiers
+  inev.ie.modifiers
     |= x_x_to_emacs_modifiers (FRAME_DISPLAY_INFO (f), xstate);
-  inev.timestamp = event->key.time;
+  inev.ie.timestamp = event->key.time;
 
 #ifdef HAVE_XINPUT2
   if (event->key.time == pending_keystroke_time)
@@ -6436,7 +6436,7 @@ xg_widget_key_press_event_cb (GtkWidget *widget, GdkEvent *event,
                                  FRAME_DISPLAY_INFO (f)->pending_keystroke_source);
 
       if (source)
-       inev.device = source->name;
+       inev.ie.device = source->name;
     }
 #endif
 
@@ -6455,8 +6455,8 @@ xg_widget_key_press_event_cb (GtkWidget *widget, GdkEvent *event,
   if (keysym >= 32 && keysym < 128)
     /* Avoid explicitly decoding each ASCII character.  */
     {
-      inev.kind = ASCII_KEYSTROKE_EVENT;
-      inev.code = keysym;
+      inev.ie.kind = ASCII_KEYSTROKE_EVENT;
+      inev.ie.code = keysym;
       goto done;
     }
 
@@ -6464,10 +6464,10 @@ xg_widget_key_press_event_cb (GtkWidget *widget, GdkEvent *event,
   if (keysym >= 0x01000000 && keysym <= 0x0110FFFF)
     {
       if (keysym < 0x01000080)
-       inev.kind = ASCII_KEYSTROKE_EVENT;
+       inev.ie.kind = ASCII_KEYSTROKE_EVENT;
       else
-       inev.kind = MULTIBYTE_CHAR_KEYSTROKE_EVENT;
-      inev.code = keysym & 0xFFFFFF;
+       inev.ie.kind = MULTIBYTE_CHAR_KEYSTROKE_EVENT;
+      inev.ie.code = keysym & 0xFFFFFF;
       goto done;
     }
 
@@ -6523,8 +6523,8 @@ xg_widget_key_press_event_cb (GtkWidget *widget, GdkEvent *event,
        /* Any "vendor-specific" key is ok.  */
        || (keysym & (1 << 28))))
     {
-      inev.kind = NON_ASCII_KEYSTROKE_EVENT;
-      inev.code = keysym;
+      inev.ie.kind = NON_ASCII_KEYSTROKE_EVENT;
+      inev.ie.code = keysym;
       goto done;
     }
 
@@ -6532,22 +6532,22 @@ xg_widget_key_press_event_cb (GtkWidget *widget, GdkEvent *event,
 
   if (uc)
     {
-      inev.kind = (SINGLE_BYTE_CHAR_P (uc)
-                  ? ASCII_KEYSTROKE_EVENT
-                  : MULTIBYTE_CHAR_KEYSTROKE_EVENT);
-      inev.code = uc;
+      inev.ie.kind = (SINGLE_BYTE_CHAR_P (uc)
+                     ? ASCII_KEYSTROKE_EVENT
+                     : MULTIBYTE_CHAR_KEYSTROKE_EVENT);
+      inev.ie.code = uc;
     }
   else
     {
-      inev.kind = NON_ASCII_KEYSTROKE_EVENT;
-      inev.code = keysym;
+      inev.ie.kind = NON_ASCII_KEYSTROKE_EVENT;
+      inev.ie.code = keysym;
     }
 
  done:
-  if (inev.kind != NO_EVENT)
+  if (inev.ie.kind != NO_EVENT)
     {
       xg_pending_quit_event.kind = NO_EVENT;
-      kbd_buffer_store_event_hold (&inev, &xg_pending_quit_event);
+      kbd_buffer_store_buffered_event (&inev, &xg_pending_quit_event);
     }
 
   XNoOp (FRAME_X_DISPLAY (f));
index a8ded65d4c198f0023c1088a4ab2b78a22fc85bf..bef499869e64a0e9d99b7a2889f248bec399ee00 100644 (file)
@@ -408,7 +408,7 @@ static void timer_resume_idle (void);
 static void deliver_user_signal (int);
 static char *find_user_signal_name (int);
 static void store_user_signal_events (void);
-static bool is_ignored_event_kind (enum event_kind);
+static bool is_ignored_event (union buffered_input_event *);
 
 /* Advance or retreat a buffered input event pointer.  */
 
@@ -3629,7 +3629,7 @@ readable_events (int flags)
                      && (event->kind == FOCUS_IN_EVENT
                          || event->kind == FOCUS_OUT_EVENT))
                     || (input_pending_p_filter_events
-                        && is_ignored_event_kind (event->kind))))
+                        && is_ignored_event (event))))
 #ifdef USE_TOOLKIT_SCROLL_BARS
                  && !((flags & READABLE_EVENTS_IGNORE_SQUEEZABLES)
                       && (event->kind == SCROLL_BAR_CLICK_EVENT
@@ -3714,31 +3714,6 @@ kbd_buffer_store_event (register struct input_event *event)
   kbd_buffer_store_event_hold (event, 0);
 }
 
-static void
-beware_long_paste (void)
-{
-#ifdef subprocesses
-  if (! (kbd_buffer_nr_stored () <= KBD_BUFFER_SIZE / 2
-        && kbd_on_hold_p ()))
-    {
-      /* Don't read keyboard input until we have processed kbd_buffer.
-        This happens when pasting text longer than KBD_BUFFER_SIZE/2.  */
-      hold_keyboard_input ();
-      unrequest_sigio ();
-      stop_polling ();
-    }
-#endif
-}
-
-/* If we're inside while-no-input, and this event qualifies
-   as input, set quit-flag to cause an interrupt.  */
-static void
-maybe_quit_while_no_input (enum event_kind kind)
-{
-  if (!NILP (Vthrow_on_input) && !is_ignored_event_kind (kind))
-    Vquit_flag = Vthrow_on_input;
-}
-
 /* Store EVENT obtained at interrupt level into kbd_buffer, fifo.
 
    If HOLD_QUIT is 0, just stuff EVENT into the fifo.
@@ -3750,8 +3725,8 @@ maybe_quit_while_no_input (enum event_kind kind)
    subsequent input events have been parsed (and discarded).  */
 
 void
-kbd_buffer_store_event_hold (struct input_event *event,
-                            struct input_event *hold_quit)
+kbd_buffer_store_buffered_event (union buffered_input_event *event,
+                                struct input_event *hold_quit)
 {
   if (event->kind == NO_EVENT)
     emacs_abort ();
@@ -3761,23 +3736,23 @@ kbd_buffer_store_event_hold (struct input_event *event,
 
   if (event->kind == ASCII_KEYSTROKE_EVENT)
     {
-      int c = event->code & 0377;
+      int c = event->ie.code & 0377;
 
-      if (event->modifiers & ctrl_modifier)
+      if (event->ie.modifiers & ctrl_modifier)
        c = make_ctrl_char (c);
 
-      c |= (event->modifiers
+      c |= (event->ie.modifiers
            & (meta_modifier | alt_modifier
               | hyper_modifier | super_modifier));
 
       if (c == quit_char)
        {
-         KBOARD *kb = FRAME_KBOARD (XFRAME (event->frame_or_window));
+         KBOARD *kb = FRAME_KBOARD (XFRAME (event->ie.frame_or_window));
 
          if (single_kboard && kb != current_kboard)
            {
              kset_kbd_queue
-               (kb, list2 (make_lispy_switch_frame (event->frame_or_window),
+               (kb, list2 (make_lispy_switch_frame (event->ie.frame_or_window),
                            make_fixnum (c)));
              kb->kbd_queue_has_data = true;
 
@@ -3796,7 +3771,7 @@ kbd_buffer_store_event_hold (struct input_event *event,
 
          if (hold_quit)
            {
-             *hold_quit = *event;
+             *hold_quit = event->ie;
              return;
            }
 
@@ -3807,9 +3782,9 @@ kbd_buffer_store_event_hold (struct input_event *event,
          {
            Lisp_Object focus;
 
-           focus = FRAME_FOCUS_FRAME (XFRAME (event->frame_or_window));
+           focus = FRAME_FOCUS_FRAME (XFRAME (event->ie.frame_or_window));
            if (NILP (focus))
-             focus = event->frame_or_window;
+             focus = event->ie.frame_or_window;
            internal_last_event_frame = focus;
            Vlast_event_frame = focus;
          }
@@ -3832,46 +3807,27 @@ kbd_buffer_store_event_hold (struct input_event *event,
   union buffered_input_event *next_slot = next_kbd_event (kbd_store_ptr);
   if (kbd_fetch_ptr != next_slot)
     {
-      kbd_store_ptr->ie = *event;
-      kbd_store_ptr = next_slot;
-      beware_long_paste ();
-    }
-
-  maybe_quit_while_no_input (event->kind);
-}
-
-#if defined HAVE_X11 || defined HAVE_PGTK
-/* Store EVENT obtained at interrupt level into kbd_buffer, fifo.
-   This is like kbd_buffer_store_event_hold, but for struct
-   selection_input_event instead of struct input_event.
-
-   If HOLD_QUIT && HOLD_QUIT->kind != NO_EVENT, discard EVENT.
-
-   This is used to postpone the processing of the quit event until all
-   subsequent input events have been parsed (and discarded).  */
-
-void
-kbd_buffer_store_selection_event_hold (struct selection_input_event *event,
-                                      struct input_event *hold_quit)
-{
-  if (hold_quit && hold_quit->kind != NO_EVENT)
-    return;
-
-  /* Don't let the very last slot in the buffer become full,
-     since that would make the two pointers equal,
-     and that is indistinguishable from an empty buffer.
-     Discard the event if it would fill the last slot.  */
-  union buffered_input_event *next_slot = next_kbd_event (kbd_store_ptr);
-  if (kbd_fetch_ptr != next_slot)
-    {
-      kbd_store_ptr->sie = *event;
+      *kbd_store_ptr = *event;
       kbd_store_ptr = next_slot;
-      beware_long_paste ();
+#ifdef subprocesses
+      if (kbd_buffer_nr_stored () > KBD_BUFFER_SIZE / 2
+         && ! kbd_on_hold_p ())
+        {
+          /* Don't read keyboard input until we have processed kbd_buffer.
+             This happens when pasting text longer than KBD_BUFFER_SIZE/2.  */
+          hold_keyboard_input ();
+          unrequest_sigio ();
+          stop_polling ();
+        }
+#endif /* subprocesses */
     }
 
-  maybe_quit_while_no_input (event->kind);
+  /* If we're inside while-no-input, and this event qualifies
+     as input, set quit-flag to cause an interrupt.  */
+  if (!NILP (Vthrow_on_input)
+      && !is_ignored_event (event))
+    Vquit_flag = Vthrow_on_input;
 }
-#endif /* HAVE_X11 || HAVE_PGTK */
 
 /* Limit help event positions to this range, to avoid overflow problems.  */
 #define INPUT_EVENT_POS_MAX \
@@ -12921,11 +12877,11 @@ init_while_no_input_ignore_events (void)
 }
 
 static bool
-is_ignored_event_kind (enum event_kind kind)
+is_ignored_event (union buffered_input_event *event)
 {
   Lisp_Object ignore_event;
 
-  switch (kind)
+  switch (event->kind)
     {
     case FOCUS_IN_EVENT: ignore_event = Qfocus_in; break;
     case FOCUS_OUT_EVENT: ignore_event = Qfocus_out; break;
index 1dd56d92a8fe67b2edc5e64d353d90a225f7e65c..5e04b54eb74695924fa0ea6a2610cd6e8fb0a630 100644 (file)
@@ -499,12 +499,17 @@ extern void clear_waiting_for_input (void);
 extern void swallow_events (bool);
 extern bool lucid_event_type_list_p (Lisp_Object);
 extern void kbd_buffer_store_event (struct input_event *);
-extern void kbd_buffer_store_event_hold (struct input_event *,
-                                        struct input_event *);
-#if defined HAVE_X11 || defined HAVE_PGTK
-extern void kbd_buffer_store_selection_event_hold (struct selection_input_event *,
-                                                  struct input_event *);
-#endif
+extern void kbd_buffer_store_buffered_event (union buffered_input_event *,
+                                            struct input_event *);
+INLINE void
+kbd_buffer_store_event_hold (struct input_event *event,
+                            struct input_event *hold_quit)
+{
+  static_assert (alignof (struct input_event) == alignof (union buffered_input_event)
+                && sizeof (struct input_event) == sizeof (union buffered_input_event));
+  kbd_buffer_store_buffered_event ((union buffered_input_event *) event,
+                                  hold_quit);
+}
 extern void poll_for_input_1 (void);
 extern void show_help_echo (Lisp_Object, Lisp_Object, Lisp_Object,
                             Lisp_Object);
index e887362a7b95b3a6ad8ae7d819c255a73a73a3d1..94b29b5ac9b8194b815860003ba5b88b3434510c 100644 (file)
@@ -283,8 +283,12 @@ flip_cr_context (struct frame *f)
 
 
 static void
-evq_grow_if_needed (struct event_queue_t *evq)
+evq_enqueue (union buffered_input_event *ev)
 {
+  struct event_queue_t *evq = &event_q;
+  struct frame *frame;
+  struct pgtk_display_info *dpyinfo;
+
   if (evq->cap == 0)
     {
       evq->cap = 4;
@@ -296,44 +300,28 @@ evq_grow_if_needed (struct event_queue_t *evq)
       evq->cap += evq->cap / 2;
       evq->q = xrealloc (evq->q, sizeof *evq->q * evq->cap);
     }
-}
-
-static void
-evq_enqueue (struct input_event const *ev)
-{
-  struct event_queue_t *evq = &event_q;
-  struct frame *frame;
-  struct pgtk_display_info *dpyinfo;
-
-  evq_grow_if_needed (evq);
-  evq->q[evq->nr++].ie = *ev;
 
-  frame = NULL;
+  evq->q[evq->nr++] = *ev;
 
-  if (WINDOWP (ev->frame_or_window))
-    frame = WINDOW_XFRAME (XWINDOW (ev->frame_or_window));
-
-  if (FRAMEP (ev->frame_or_window))
-    frame = XFRAME (ev->frame_or_window);
-
-  if (frame)
+  if (ev->ie.kind != SELECTION_REQUEST_EVENT
+      && ev->ie.kind != SELECTION_CLEAR_EVENT)
     {
-      dpyinfo = FRAME_DISPLAY_INFO (frame);
+      frame = NULL;
 
-      if (dpyinfo->last_user_time < ev->timestamp)
-       dpyinfo->last_user_time = ev->timestamp;
-    }
+      if (WINDOWP (ev->ie.frame_or_window))
+       frame = WINDOW_XFRAME (XWINDOW (ev->ie.frame_or_window));
 
-  raise (SIGIO);
-}
+      if (FRAMEP (ev->ie.frame_or_window))
+       frame = XFRAME (ev->ie.frame_or_window);
 
-static void
-evq_selection_enqueue (struct selection_input_event const *ev)
-{
-  struct event_queue_t *evq = &event_q;
+      if (frame)
+       {
+         dpyinfo = FRAME_DISPLAY_INFO (frame);
 
-  evq_grow_if_needed (evq);
-  evq->q[evq->nr++].sie = *ev;
+         if (dpyinfo->last_user_time < ev->ie.timestamp)
+           dpyinfo->last_user_time = ev->ie.timestamp;
+       }
+    }
 
   raise (SIGIO);
 }
@@ -346,27 +334,17 @@ evq_flush (struct input_event *hold_quit)
 
   while (evq->nr > 0)
     {
-      /* Because kbd_buffer_store_event_hold and
-        kbd_buffer_store_selection_event_hold may do longjmp,
-        we need to shift event queue before passing a pointer
-        to a copy of the event, so that events in
+      /* kbd_buffer_store_buffered_event may do longjmp, so
+        we need to shift event queue first and pass the event
+        to kbd_buffer_store_buffered_event so that events in
         queue are not processed twice.  Bug#52941 */
+      union buffered_input_event ev = evq->q[0];
+      int i;
+      for (i = 1; i < evq->nr; i++)
+       evq->q[i - 1] = evq->q[i];
       evq->nr--;
 
-      if (evq->q[0].kind == SELECTION_REQUEST_EVENT
-         || evq->q[0].kind == SELECTION_CLEAR_EVENT)
-       {
-         struct selection_input_event sinev = evq->q[0].sie;
-         memmove (&evq->q[0], &evq->q[1], evq->nr * sizeof evq->q[0]);
-         kbd_buffer_store_selection_event_hold (&sinev, hold_quit);
-       }
-      else
-       {
-         struct input_event inev = evq->q[0].ie;
-         memmove (&evq->q[0], &evq->q[1], evq->nr * sizeof evq->q[0]);
-         kbd_buffer_store_event_hold (&inev, hold_quit);
-       }
-
+      kbd_buffer_store_buffered_event (&ev, hold_quit);
       n++;
     }
 
@@ -3947,21 +3925,21 @@ static void
 pgtk_send_scroll_bar_event (Lisp_Object window, enum scroll_bar_part part,
                            int portion, int whole, bool horizontal)
 {
-  struct input_event inev;
+  union buffered_input_event inev;
 
-  EVENT_INIT (inev);
+  EVENT_INIT (inev.ie);
 
-  inev.kind = (horizontal
-              ? HORIZONTAL_SCROLL_BAR_CLICK_EVENT
-              : SCROLL_BAR_CLICK_EVENT);
-  inev.frame_or_window = window;
-  inev.arg = Qnil;
-  inev.timestamp = 0;
-  inev.code = 0;
-  inev.part = part;
-  inev.x = make_fixnum (portion);
-  inev.y = make_fixnum (whole);
-  inev.modifiers = 0;
+  inev.ie.kind = (horizontal
+                 ? HORIZONTAL_SCROLL_BAR_CLICK_EVENT
+                 : SCROLL_BAR_CLICK_EVENT);
+  inev.ie.frame_or_window = window;
+  inev.ie.arg = Qnil;
+  inev.ie.timestamp = 0;
+  inev.ie.code = 0;
+  inev.ie.part = part;
+  inev.ie.x = make_fixnum (portion);
+  inev.ie.y = make_fixnum (whole);
+  inev.ie.modifiers = 0;
 
   evq_enqueue (&inev);
 }
@@ -4961,6 +4939,7 @@ static gboolean
 pgtk_handle_event (GtkWidget *widget, GdkEvent *event, gpointer *data)
 {
   struct frame *f;
+  union buffered_input_event inev;
   GtkWidget *frame_widget;
   gint x, y;
 
@@ -4977,18 +4956,18 @@ pgtk_handle_event (GtkWidget *widget, GdkEvent *event, gpointer *data)
                                        &x, &y);
       if (f)
        {
-         struct input_event inev;
-         inev.kind = PINCH_EVENT;
-         XSETFRAME (inev.frame_or_window, f);
-         XSETINT (inev.x, x);
-         XSETINT (inev.y, y);
-         inev.arg = list4 (make_float (event->touchpad_pinch.dx),
-                           make_float (event->touchpad_pinch.dy),
-                           make_float (event->touchpad_pinch.scale),
-                           make_float (event->touchpad_pinch.angle_delta));
-         inev.modifiers = pgtk_gtk_to_emacs_modifiers (FRAME_DISPLAY_INFO (f),
+
+         inev.ie.kind = PINCH_EVENT;
+         XSETFRAME (inev.ie.frame_or_window, f);
+         XSETINT (inev.ie.x, x);
+         XSETINT (inev.ie.y, y);
+         inev.ie.arg = list4 (make_float (event->touchpad_pinch.dx),
+                              make_float (event->touchpad_pinch.dy),
+                              make_float (event->touchpad_pinch.scale),
+                              make_float (event->touchpad_pinch.angle_delta));
+         inev.ie.modifiers = pgtk_gtk_to_emacs_modifiers (FRAME_DISPLAY_INFO (f),
                                                           event->touchpad_pinch.state);
-         inev.device
+         inev.ie.device
            = pgtk_get_device_for_event (FRAME_DISPLAY_INFO (f), event);
          evq_enqueue (&inev);
        }
@@ -5206,17 +5185,17 @@ pgtk_enqueue_string (struct frame *f, gchar *str)
     return;
   for (; *ustr != 0; ustr++)
     {
-      struct input_event inev;
+      union buffered_input_event inev;
       Lisp_Object c = make_fixnum (*ustr);
-      EVENT_INIT (inev);
-      inev.kind = (SINGLE_BYTE_CHAR_P (XFIXNAT (c))
-                  ? ASCII_KEYSTROKE_EVENT
-                  : MULTIBYTE_CHAR_KEYSTROKE_EVENT);
-      inev.arg = Qnil;
-      inev.code = XFIXNAT (c);
-      XSETFRAME (inev.frame_or_window, f);
-      inev.modifiers = 0;
-      inev.timestamp = 0;
+      EVENT_INIT (inev.ie);
+      inev.ie.kind = (SINGLE_BYTE_CHAR_P (XFIXNAT (c))
+                     ? ASCII_KEYSTROKE_EVENT
+                     : MULTIBYTE_CHAR_KEYSTROKE_EVENT);
+      inev.ie.arg = Qnil;
+      inev.ie.code = XFIXNAT (c);
+      XSETFRAME (inev.ie.frame_or_window, f);
+      inev.ie.modifiers = 0;
+      inev.ie.timestamp = 0;
       evq_enqueue (&inev);
     }
 
@@ -5226,28 +5205,28 @@ pgtk_enqueue_string (struct frame *f, gchar *str)
 void
 pgtk_enqueue_preedit (struct frame *f, Lisp_Object preedit)
 {
-  struct input_event inev;
-  EVENT_INIT (inev);
-  inev.kind = PREEDIT_TEXT_EVENT;
-  inev.arg = preedit;
-  inev.code = 0;
-  XSETFRAME (inev.frame_or_window, f);
-  inev.modifiers = 0;
-  inev.timestamp = 0;
+  union buffered_input_event inev;
+  EVENT_INIT (inev.ie);
+  inev.ie.kind = PREEDIT_TEXT_EVENT;
+  inev.ie.arg = preedit;
+  inev.ie.code = 0;
+  XSETFRAME (inev.ie.frame_or_window, f);
+  inev.ie.modifiers = 0;
+  inev.ie.timestamp = 0;
   evq_enqueue (&inev);
 }
 
 static gboolean
 key_press_event (GtkWidget *widget, GdkEvent *event, gpointer *user_data)
 {
-  struct input_event inev;
+  union buffered_input_event inev;
   ptrdiff_t nbytes;
   Mouse_HLInfo *hlinfo;
   struct frame *f;
   struct pgtk_display_info *dpyinfo;
 
   f = pgtk_any_window_to_frame (gtk_widget_get_window (widget));
-  EVENT_INIT (inev);
+  EVENT_INIT (inev.ie);
   hlinfo = MOUSE_HL_INFO (f);
   nbytes = 0;
 
@@ -5318,20 +5297,20 @@ key_press_event (GtkWidget *widget, GdkEvent *event, gpointer *user_data)
       orig_keysym = keysym;
 
       /* Common for all keysym input events.  */
-      XSETFRAME (inev.frame_or_window, f);
-      inev.modifiers
+      XSETFRAME (inev.ie.frame_or_window, f);
+      inev.ie.modifiers
        = pgtk_gtk_to_emacs_modifiers (FRAME_DISPLAY_INFO (f), modifiers);
-      inev.timestamp = event->key.time;
+      inev.ie.timestamp = event->key.time;
 
       /* First deal with keysyms which have defined
          translations to characters.  */
       if (keysym >= 32 && keysym < 128)
        /* Avoid explicitly decoding each ASCII character.  */
        {
-         inev.kind = ASCII_KEYSTROKE_EVENT;
-         inev.code = keysym;
+         inev.ie.kind = ASCII_KEYSTROKE_EVENT;
+         inev.ie.code = keysym;
 
-         inev.device
+         inev.ie.device
            = pgtk_get_device_for_event (FRAME_DISPLAY_INFO (f), event);
          goto done;
        }
@@ -5340,12 +5319,12 @@ key_press_event (GtkWidget *widget, GdkEvent *event, gpointer *user_data)
       if (keysym >= 0x01000000 && keysym <= 0x0110FFFF)
        {
          if (keysym < 0x01000080)
-           inev.kind = ASCII_KEYSTROKE_EVENT;
+           inev.ie.kind = ASCII_KEYSTROKE_EVENT;
          else
-           inev.kind = MULTIBYTE_CHAR_KEYSTROKE_EVENT;
-         inev.code = keysym & 0xFFFFFF;
+           inev.ie.kind = MULTIBYTE_CHAR_KEYSTROKE_EVENT;
+         inev.ie.code = keysym & 0xFFFFFF;
 
-         inev.device
+         inev.ie.device
            = pgtk_get_device_for_event (FRAME_DISPLAY_INFO (f), event);
          goto done;
        }
@@ -5355,12 +5334,12 @@ key_press_event (GtkWidget *widget, GdkEvent *event, gpointer *user_data)
          && (c = Fgethash (make_fixnum (keysym),
                            Vpgtk_keysym_table, Qnil), FIXNATP (c)))
        {
-         inev.kind = (SINGLE_BYTE_CHAR_P (XFIXNAT (c))
-                      ? ASCII_KEYSTROKE_EVENT
-                      : MULTIBYTE_CHAR_KEYSTROKE_EVENT);
-         inev.code = XFIXNAT (c);
+         inev.ie.kind = (SINGLE_BYTE_CHAR_P (XFIXNAT (c))
+                         ? ASCII_KEYSTROKE_EVENT
+                         : MULTIBYTE_CHAR_KEYSTROKE_EVENT);
+         inev.ie.code = XFIXNAT (c);
 
-         inev.device
+         inev.ie.device
            = pgtk_get_device_for_event (FRAME_DISPLAY_INFO (f), event);
          goto done;
        }
@@ -5439,18 +5418,18 @@ key_press_event (GtkWidget *widget, GdkEvent *event, gpointer *user_data)
        {
          /* make_lispy_event will convert this to a symbolic
             key.  */
-         inev.kind = NON_ASCII_KEYSTROKE_EVENT;
-         inev.code = keysym;
+         inev.ie.kind = NON_ASCII_KEYSTROKE_EVENT;
+         inev.ie.code = keysym;
 
-         inev.device
+         inev.ie.device
            = pgtk_get_device_for_event (FRAME_DISPLAY_INFO (f), event);
          goto done;
        }
 
       {
-       inev.kind = MULTIBYTE_CHAR_KEYSTROKE_EVENT;
-       inev.arg = make_unibyte_string ((char *) copy_bufptr, nbytes);
-       inev.device
+       inev.ie.kind = MULTIBYTE_CHAR_KEYSTROKE_EVENT;
+       inev.ie.arg = make_unibyte_string ((char *) copy_bufptr, nbytes);
+       inev.ie.device
          = pgtk_get_device_for_event (FRAME_DISPLAY_INFO (f), event);
 
        if (keysym == GDK_KEY_VoidSymbol)
@@ -5459,9 +5438,9 @@ key_press_event (GtkWidget *widget, GdkEvent *event, gpointer *user_data)
     }
 
 done:
-  if (inev.kind != NO_EVENT)
+  if (inev.ie.kind != NO_EVENT)
     {
-      XSETFRAME (inev.frame_or_window, f);
+      XSETFRAME (inev.ie.frame_or_window, f);
       evq_enqueue (&inev);
     }
 
@@ -5540,11 +5519,11 @@ map_event (GtkWidget *widget,
           gpointer *user_data)
 {
   struct frame *f = pgtk_any_window_to_frame (event->any.window);
-  struct input_event inev;
+  union buffered_input_event inev;
 
-  EVENT_INIT (inev);
-  inev.kind = NO_EVENT;
-  inev.arg = Qnil;
+  EVENT_INIT (inev.ie);
+  inev.ie.kind = NO_EVENT;
+  inev.ie.arg = Qnil;
 
   if (f)
     {
@@ -5571,12 +5550,12 @@ map_event (GtkWidget *widget,
 
       if (iconified)
        {
-         inev.kind = DEICONIFY_EVENT;
-         XSETFRAME (inev.frame_or_window, f);
+         inev.ie.kind = DEICONIFY_EVENT;
+         XSETFRAME (inev.ie.frame_or_window, f);
        }
     }
 
-  if (inev.kind != NO_EVENT)
+  if (inev.ie.kind != NO_EVENT)
     evq_enqueue (&inev);
   return FALSE;
 }
@@ -5588,13 +5567,13 @@ window_state_event (GtkWidget *widget,
 {
   struct frame *f = pgtk_any_window_to_frame (event->window_state.window);
   GdkWindowState new_state;
-  struct input_event inev;
+  union buffered_input_event inev;
 
   new_state = event->window_state.new_window_state;
 
-  EVENT_INIT (inev);
-  inev.kind = NO_EVENT;
-  inev.arg = Qnil;
+  EVENT_INIT (inev.ie);
+  inev.ie.kind = NO_EVENT;
+  inev.ie.arg = Qnil;
 
   if (new_state & GDK_WINDOW_STATE_FULLSCREEN)
     store_frame_param (f, Qfullscreen, Qfullboth);
@@ -5640,8 +5619,8 @@ window_state_event (GtkWidget *widget,
   else
     {
       FRAME_X_OUTPUT (f)->has_been_visible = true;
-      inev.kind = DEICONIFY_EVENT;
-      XSETFRAME (inev.frame_or_window, f);
+      inev.ie.kind = DEICONIFY_EVENT;
+      XSETFRAME (inev.ie.frame_or_window, f);
       SET_FRAME_ICONIFIED (f, false);
       SET_FRAME_VISIBLE (f, true);
     }
@@ -5651,7 +5630,7 @@ window_state_event (GtkWidget *widget,
   else
     store_frame_param (f, Qsticky, Qnil);
 
-  if (inev.kind != NO_EVENT)
+  if (inev.ie.kind != NO_EVENT)
     evq_enqueue (&inev);
   return FALSE;
 }
@@ -5661,19 +5640,19 @@ delete_event (GtkWidget *widget,
              GdkEvent *event, gpointer *user_data)
 {
   struct frame *f = pgtk_any_window_to_frame (event->any.window);
-  struct input_event inev;
+  union buffered_input_event inev;
 
-  EVENT_INIT (inev);
-  inev.kind = NO_EVENT;
-  inev.arg = Qnil;
+  EVENT_INIT (inev.ie);
+  inev.ie.kind = NO_EVENT;
+  inev.ie.arg = Qnil;
 
   if (f)
     {
-      inev.kind = DELETE_WINDOW_EVENT;
-      XSETFRAME (inev.frame_or_window, f);
+      inev.ie.kind = DELETE_WINDOW_EVENT;
+      XSETFRAME (inev.ie.frame_or_window, f);
     }
 
-  if (inev.kind != NO_EVENT)
+  if (inev.ie.kind != NO_EVENT)
     evq_enqueue (&inev);
   return TRUE;
 }
@@ -5690,7 +5669,7 @@ delete_event (GtkWidget *widget,
 static void
 pgtk_focus_changed (gboolean is_enter, int state,
                    struct pgtk_display_info *dpyinfo, struct frame *frame,
-                   struct input_event *bufp)
+                   union buffered_input_event *bufp)
 {
   if (is_enter)
     {
@@ -5702,13 +5681,13 @@ pgtk_focus_changed (gboolean is_enter, int state,
          /* Don't stop displaying the initial startup message
             for a switch-frame event we don't need.  */
          /* When run as a daemon, Vterminal_frame is always NIL.  */
-         bufp->arg = (((NILP (Vterminal_frame)
-                        || !FRAME_PGTK_P (XFRAME (Vterminal_frame))
-                        || EQ (Fdaemonp (), Qt))
-                       && CONSP (Vframe_list)
-                       && !NILP (XCDR (Vframe_list))) ? Qt : Qnil);
-         bufp->kind = FOCUS_IN_EVENT;
-         XSETFRAME (bufp->frame_or_window, frame);
+         bufp->ie.arg = (((NILP (Vterminal_frame)
+                           || !FRAME_PGTK_P (XFRAME (Vterminal_frame))
+                           || EQ (Fdaemonp (), Qt))
+                          && CONSP (Vframe_list)
+                          && !NILP (XCDR (Vframe_list))) ? Qt : Qnil);
+         bufp->ie.kind = FOCUS_IN_EVENT;
+         XSETFRAME (bufp->ie.frame_or_window, frame);
        }
 
       frame->output_data.pgtk->focus_state |= state;
@@ -5723,8 +5702,8 @@ pgtk_focus_changed (gboolean is_enter, int state,
           dpyinfo->x_focus_event_frame = 0;
           pgtk_new_focus_frame (dpyinfo, NULL);
 
-         bufp->kind = FOCUS_OUT_EVENT;
-         XSETFRAME (bufp->frame_or_window, frame);
+          bufp->ie.kind = FOCUS_OUT_EVENT;
+          XSETFRAME (bufp->ie.frame_or_window, frame);
         }
 
       if (frame->pointer_invisible)
@@ -5736,7 +5715,7 @@ static gboolean
 enter_notify_event (GtkWidget *widget, GdkEvent *event,
                    gpointer *user_data)
 {
-  struct input_event inev;
+  union buffered_input_event inev;
   struct frame *frame
     = pgtk_any_window_to_frame (gtk_widget_get_window (widget));
 
@@ -5748,14 +5727,14 @@ enter_notify_event (GtkWidget *widget, GdkEvent *event,
   int focus_state
     = focus_frame ? focus_frame->output_data.pgtk->focus_state : 0;
 
-  EVENT_INIT (inev);
-  inev.kind = NO_EVENT;
-  inev.arg = Qnil;
+  EVENT_INIT (inev.ie);
+  inev.ie.kind = NO_EVENT;
+  inev.ie.arg = Qnil;
 
   if (event->crossing.detail != GDK_NOTIFY_INFERIOR
       && event->crossing.focus && !(focus_state & FOCUS_EXPLICIT))
     pgtk_focus_changed (TRUE, FOCUS_IMPLICIT, dpyinfo, frame, &inev);
-  if (inev.kind != NO_EVENT)
+  if (inev.ie.kind != NO_EVENT)
     evq_enqueue (&inev);
   return TRUE;
 }
@@ -5764,7 +5743,7 @@ static gboolean
 leave_notify_event (GtkWidget *widget, GdkEvent *event,
                    gpointer *user_data)
 {
-  struct input_event inev;
+  union buffered_input_event inev;
   struct frame *frame
     = pgtk_any_window_to_frame (gtk_widget_get_window (widget));
 
@@ -5785,9 +5764,9 @@ leave_notify_event (GtkWidget *widget, GdkEvent *event,
       hlinfo->mouse_face_mouse_frame = 0;
     }
 
-  EVENT_INIT (inev);
-  inev.kind = NO_EVENT;
-  inev.arg = Qnil;
+  EVENT_INIT (inev.ie);
+  inev.ie.kind = NO_EVENT;
+  inev.ie.arg = Qnil;
 
   if (event->crossing.detail != GDK_NOTIFY_INFERIOR
       && event->crossing.focus && !(focus_state & FOCUS_EXPLICIT))
@@ -5804,7 +5783,7 @@ leave_notify_event (GtkWidget *widget, GdkEvent *event,
        }
     }
 
-  if (inev.kind != NO_EVENT)
+  if (inev.ie.kind != NO_EVENT)
     evq_enqueue (&inev);
   return TRUE;
 }
@@ -5812,20 +5791,20 @@ leave_notify_event (GtkWidget *widget, GdkEvent *event,
 static gboolean
 focus_in_event (GtkWidget *widget, GdkEvent *event, gpointer *user_data)
 {
-  struct input_event inev;
+  union buffered_input_event inev;
   struct frame *frame
     = pgtk_any_window_to_frame (gtk_widget_get_window (widget));
 
   if (frame == NULL)
     return TRUE;
 
-  EVENT_INIT (inev);
-  inev.kind = NO_EVENT;
-  inev.arg = Qnil;
+  EVENT_INIT (inev.ie);
+  inev.ie.kind = NO_EVENT;
+  inev.ie.arg = Qnil;
 
   pgtk_focus_changed (TRUE, FOCUS_EXPLICIT,
                      FRAME_DISPLAY_INFO (frame), frame, &inev);
-  if (inev.kind != NO_EVENT)
+  if (inev.ie.kind != NO_EVENT)
     evq_enqueue (&inev);
 
   pgtk_im_focus_in (frame);
@@ -5836,20 +5815,20 @@ focus_in_event (GtkWidget *widget, GdkEvent *event, gpointer *user_data)
 static gboolean
 focus_out_event (GtkWidget *widget, GdkEvent *event, gpointer *user_data)
 {
-  struct input_event inev;
+  union buffered_input_event inev;
   struct frame *frame
     = pgtk_any_window_to_frame (gtk_widget_get_window (widget));
 
   if (frame == NULL)
     return TRUE;
 
-  EVENT_INIT (inev);
-  inev.kind = NO_EVENT;
-  inev.arg = Qnil;
+  EVENT_INIT (inev.ie);
+  inev.ie.kind = NO_EVENT;
+  inev.ie.arg = Qnil;
 
   pgtk_focus_changed (FALSE, FOCUS_EXPLICIT,
                      FRAME_DISPLAY_INFO (frame), frame, &inev);
-  if (inev.kind != NO_EVENT)
+  if (inev.ie.kind != NO_EVENT)
     evq_enqueue (&inev);
 
   pgtk_im_focus_out (frame);
@@ -5919,7 +5898,7 @@ static gboolean
 motion_notify_event (GtkWidget *widget, GdkEvent *event,
                     gpointer *user_data)
 {
-  struct input_event inev;
+  union buffered_input_event inev;
   struct frame *f, *frame;
   struct pgtk_display_info *dpyinfo;
   Mouse_HLInfo *hlinfo;
@@ -5935,9 +5914,9 @@ motion_notify_event (GtkWidget *widget, GdkEvent *event,
          && (gdk_device_get_source (device) == GDK_SOURCE_TOUCHSCREEN)))
     return FALSE;
 
-  EVENT_INIT (inev);
-  inev.kind = NO_EVENT;
-  inev.arg = Qnil;
+  EVENT_INIT (inev.ie);
+  inev.ie.kind = NO_EVENT;
+  inev.ie.arg = Qnil;
 
   previous_help_echo_string = help_echo_string;
   help_echo_string = Qnil;
@@ -5988,8 +5967,8 @@ motion_notify_event (GtkWidget *widget, GdkEvent *event,
              && !EQ (window, last_mouse_window)
              && !EQ (window, selected_window))
            {
-             inev.kind = SELECT_WINDOW_EVENT;
-             inev.frame_or_window = window;
+             inev.ie.kind = SELECT_WINDOW_EVENT;
+             inev.ie.frame_or_window = window;
            }
 
          /* Remember the last window where we saw the mouse.  */
@@ -6010,7 +5989,7 @@ motion_notify_event (GtkWidget *widget, GdkEvent *event,
   if (!NILP (help_echo_string) || !NILP (previous_help_echo_string))
     do_help = 1;
 
-  if (inev.kind != NO_EVENT)
+  if (inev.ie.kind != NO_EVENT)
     evq_enqueue (&inev);
 
   if (do_help > 0)
@@ -6063,7 +6042,7 @@ static gboolean
 button_event (GtkWidget *widget, GdkEvent *event,
              gpointer *user_data)
 {
-  struct input_event inev;
+  union buffered_input_event inev;
   struct frame *f, *frame;
   struct pgtk_display_info *dpyinfo;
 
@@ -6084,9 +6063,9 @@ button_event (GtkWidget *widget, GdkEvent *event,
          && (gdk_device_get_source (device) == GDK_SOURCE_TOUCHSCREEN)))
     return FALSE;
 
-  EVENT_INIT (inev);
-  inev.kind = NO_EVENT;
-  inev.arg = Qnil;
+  EVENT_INIT (inev.ie);
+  inev.ie.kind = NO_EVENT;
+  inev.ie.arg = Qnil;
 
   /* ignore double click and triple click. */
   if (event->type != GDK_BUTTON_PRESS && event->type != GDK_BUTTON_RELEASE)
@@ -6155,16 +6134,16 @@ button_event (GtkWidget *widget, GdkEvent *event,
                  && event->button.time > ignore_next_mouse_click_timeout)
                {
                  ignore_next_mouse_click_timeout = 0;
-                 construct_mouse_click (&inev, &event->button, f);
+                 construct_mouse_click (&inev.ie, &event->button, f);
                }
              if (event->type == GDK_BUTTON_RELEASE)
                ignore_next_mouse_click_timeout = 0;
            }
          else
-           construct_mouse_click (&inev, &event->button, f);
+           construct_mouse_click (&inev.ie, &event->button, f);
 
          if (!NILP (tab_bar_arg))
-           inev.arg = tab_bar_arg;
+           inev.ie.arg = tab_bar_arg;
        }
     }
 
@@ -6186,7 +6165,7 @@ button_event (GtkWidget *widget, GdkEvent *event,
   if (f != 0)
     f->mouse_moved = false;
 
-  if (inev.kind != NO_EVENT)
+  if (inev.ie.kind != NO_EVENT)
     evq_enqueue (&inev);
   return TRUE;
 }
@@ -6194,15 +6173,15 @@ button_event (GtkWidget *widget, GdkEvent *event,
 static gboolean
 scroll_event (GtkWidget *widget, GdkEvent *event, gpointer *user_data)
 {
-  struct input_event inev;
+  union buffered_input_event inev;
   struct frame *f, *frame;
   struct pgtk_display_info *dpyinfo;
   GdkScrollDirection dir;
   double delta_x, delta_y;
 
-  EVENT_INIT (inev);
-  inev.kind = NO_EVENT;
-  inev.arg = Qnil;
+  EVENT_INIT (inev.ie);
+  inev.ie.kind = NO_EVENT;
+  inev.ie.arg = Qnil;
 
   frame = pgtk_any_window_to_frame (gtk_widget_get_window (widget));
   dpyinfo = FRAME_DISPLAY_INFO (frame);
@@ -6212,19 +6191,19 @@ scroll_event (GtkWidget *widget, GdkEvent *event, gpointer *user_data)
   else
     f = pgtk_any_window_to_frame (gtk_widget_get_window (widget));
 
-  inev.kind = NO_EVENT;
-  inev.timestamp = event->scroll.time;
-  inev.modifiers
+  inev.ie.kind = NO_EVENT;
+  inev.ie.timestamp = event->scroll.time;
+  inev.ie.modifiers
     = pgtk_gtk_to_emacs_modifiers (FRAME_DISPLAY_INFO (f), event->scroll.state);
-  XSETINT (inev.x, event->scroll.x);
-  XSETINT (inev.y, event->scroll.y);
-  XSETFRAME (inev.frame_or_window, f);
-  inev.arg = Qnil;
+  XSETINT (inev.ie.x, event->scroll.x);
+  XSETINT (inev.ie.y, event->scroll.y);
+  XSETFRAME (inev.ie.frame_or_window, f);
+  inev.ie.arg = Qnil;
 
   if (gdk_event_is_scroll_stop_event (event))
     {
-      inev.kind = TOUCH_END_EVENT;
-      inev.device
+      inev.ie.kind = TOUCH_END_EVENT;
+      inev.ie.device
        = pgtk_get_device_for_event (FRAME_DISPLAY_INFO (f), event);
       evq_enqueue (&inev);
       return TRUE;
@@ -6235,20 +6214,20 @@ scroll_event (GtkWidget *widget, GdkEvent *event, gpointer *user_data)
       switch (dir)
        {
        case GDK_SCROLL_UP:
-         inev.kind = WHEEL_EVENT;
-         inev.modifiers |= up_modifier;
+         inev.ie.kind = WHEEL_EVENT;
+         inev.ie.modifiers |= up_modifier;
          break;
        case GDK_SCROLL_DOWN:
-         inev.kind = WHEEL_EVENT;
-         inev.modifiers |= down_modifier;
+         inev.ie.kind = WHEEL_EVENT;
+         inev.ie.modifiers |= down_modifier;
          break;
        case GDK_SCROLL_LEFT:
-         inev.kind = HORIZ_WHEEL_EVENT;
-         inev.modifiers |= up_modifier;
+         inev.ie.kind = HORIZ_WHEEL_EVENT;
+         inev.ie.modifiers |= up_modifier;
          break;
        case GDK_SCROLL_RIGHT:
-         inev.kind = HORIZ_WHEEL_EVENT;
-         inev.modifiers |= down_modifier;
+         inev.ie.kind = HORIZ_WHEEL_EVENT;
+         inev.ie.modifiers |= down_modifier;
          break;
        case GDK_SCROLL_SMOOTH:         /* shut up warning */
          break;
@@ -6258,14 +6237,14 @@ scroll_event (GtkWidget *widget, GdkEvent *event, gpointer *user_data)
     {
       if (!mwheel_coalesce_scroll_events)
        {
-         inev.kind = ((fabs (delta_x) > fabs (delta_y))
-                      ? HORIZ_WHEEL_EVENT
-                      : WHEEL_EVENT);
-         inev.modifiers |= (inev.kind == HORIZ_WHEEL_EVENT
-                            ? (delta_x >= 0 ? up_modifier : down_modifier)
-                            : (delta_y >= 0 ? down_modifier : up_modifier));
-         inev.arg = list3 (Qnil, make_float (-delta_x * 100),
-                           make_float (-delta_y * 100));
+         inev.ie.kind = ((fabs (delta_x) > fabs (delta_y))
+                         ? HORIZ_WHEEL_EVENT
+                         : WHEEL_EVENT);
+         inev.ie.modifiers |= (inev.ie.kind == HORIZ_WHEEL_EVENT
+                               ? (delta_x >= 0 ? up_modifier : down_modifier)
+                               : (delta_y >= 0 ? down_modifier : up_modifier));
+         inev.ie.arg = list3 (Qnil, make_float (-delta_x * 100),
+                              make_float (-delta_y * 100));
        }
       else
        {
@@ -6274,21 +6253,21 @@ scroll_event (GtkWidget *widget, GdkEvent *event, gpointer *user_data)
          if (dpyinfo->scroll.acc_y >= dpyinfo->scroll.y_per_line)
            {
              int nlines = dpyinfo->scroll.acc_y / dpyinfo->scroll.y_per_line;
-             inev.kind = WHEEL_EVENT;
-             inev.modifiers |= down_modifier;
-             inev.arg = list3 (make_fixnum (nlines),
-                               make_float (-dpyinfo->scroll.acc_x * 100),
-                               make_float (-dpyinfo->scroll.acc_y * 100));
+             inev.ie.kind = WHEEL_EVENT;
+             inev.ie.modifiers |= down_modifier;
+             inev.ie.arg = list3 (make_fixnum (nlines),
+                                  make_float (-dpyinfo->scroll.acc_x * 100),
+                                  make_float (-dpyinfo->scroll.acc_y * 100));
              dpyinfo->scroll.acc_y -= dpyinfo->scroll.y_per_line * nlines;
            }
          else if (dpyinfo->scroll.acc_y <= -dpyinfo->scroll.y_per_line)
            {
              int nlines = -dpyinfo->scroll.acc_y / dpyinfo->scroll.y_per_line;
-             inev.kind = WHEEL_EVENT;
-             inev.modifiers |= up_modifier;
-             inev.arg = list3 (make_fixnum (nlines),
-                               make_float (-dpyinfo->scroll.acc_x * 100),
-                               make_float (-dpyinfo->scroll.acc_y * 100));
+             inev.ie.kind = WHEEL_EVENT;
+             inev.ie.modifiers |= up_modifier;
+             inev.ie.arg = list3 (make_fixnum (nlines),
+                                  make_float (-dpyinfo->scroll.acc_x * 100),
+                                  make_float (-dpyinfo->scroll.acc_y * 100));
 
              dpyinfo->scroll.acc_y -= -dpyinfo->scroll.y_per_line * nlines;
            }
@@ -6296,31 +6275,31 @@ scroll_event (GtkWidget *widget, GdkEvent *event, gpointer *user_data)
                   || !mwheel_coalesce_scroll_events)
            {
              int nchars = dpyinfo->scroll.acc_x / dpyinfo->scroll.x_per_char;
-             inev.kind = HORIZ_WHEEL_EVENT;
-             inev.modifiers |= up_modifier;
-             inev.arg = list3 (make_fixnum (nchars),
-                               make_float (-dpyinfo->scroll.acc_x * 100),
-                               make_float (-dpyinfo->scroll.acc_y * 100));
+             inev.ie.kind = HORIZ_WHEEL_EVENT;
+             inev.ie.modifiers |= up_modifier;
+             inev.ie.arg = list3 (make_fixnum (nchars),
+                                  make_float (-dpyinfo->scroll.acc_x * 100),
+                                  make_float (-dpyinfo->scroll.acc_y * 100));
 
              dpyinfo->scroll.acc_x -= dpyinfo->scroll.x_per_char * nchars;
            }
          else if (dpyinfo->scroll.acc_x <= -dpyinfo->scroll.x_per_char)
            {
              int nchars = -dpyinfo->scroll.acc_x / dpyinfo->scroll.x_per_char;
-             inev.kind = HORIZ_WHEEL_EVENT;
-             inev.modifiers |= down_modifier;
-             inev.arg = list3 (make_fixnum (nchars),
-                               make_float (-dpyinfo->scroll.acc_x * 100),
-                               make_float (-dpyinfo->scroll.acc_y * 100));
+             inev.ie.kind = HORIZ_WHEEL_EVENT;
+             inev.ie.modifiers |= down_modifier;
+             inev.ie.arg = list3 (make_fixnum (nchars),
+                                  make_float (-dpyinfo->scroll.acc_x * 100),
+                                  make_float (-dpyinfo->scroll.acc_y * 100));
 
              dpyinfo->scroll.acc_x -= -dpyinfo->scroll.x_per_char * nchars;
            }
        }
     }
 
-  if (inev.kind != NO_EVENT)
+  if (inev.ie.kind != NO_EVENT)
     {
-      inev.device
+      inev.ie.device
        = pgtk_get_device_for_event (FRAME_DISPLAY_INFO (f), event);
       evq_enqueue (&inev);
     }
@@ -6415,7 +6394,7 @@ drag_leave (GtkWidget *widget, GdkDragContext *context,
            guint time, gpointer user_data)
 {
   struct frame *f;
-  struct input_event inev;
+  union buffered_input_event inev;
 
   f = pgtk_any_window_to_frame (gtk_widget_get_window (widget));
 
@@ -6429,16 +6408,16 @@ drag_leave (GtkWidget *widget, GdkDragContext *context,
                       g_object_unref);
     }
 
-  EVENT_INIT (inev);
+  EVENT_INIT (inev.ie);
 
-  inev.kind = DRAG_N_DROP_EVENT;
-  inev.modifiers = 0;
-  inev.arg = Qnil;
-  inev.timestamp = time;
+  inev.ie.kind = DRAG_N_DROP_EVENT;
+  inev.ie.modifiers = 0;
+  inev.ie.arg = Qnil;
+  inev.ie.timestamp = time;
 
-  XSETINT (inev.x, 0);
-  XSETINT (inev.y, 0);
-  XSETFRAME (inev.frame_or_window, f);
+  XSETINT (inev.ie.x, 0);
+  XSETINT (inev.ie.y, 0);
+  XSETFRAME (inev.ie.frame_or_window, f);
 
   evq_enqueue (&inev);
 }
@@ -6449,7 +6428,7 @@ drag_motion (GtkWidget *widget, GdkDragContext *context,
 
 {
   struct frame *f;
-  struct input_event inev;
+  union buffered_input_event inev;
   GdkAtom name;
   GdkDragAction suggestion;
 
@@ -6475,18 +6454,18 @@ drag_motion (GtkWidget *widget, GdkDragContext *context,
   name = gdk_drag_get_selection (context);
   suggestion = gdk_drag_context_get_suggested_action (context);
 
-  EVENT_INIT (inev);
+  EVENT_INIT (inev.ie);
 
-  inev.kind = DRAG_N_DROP_EVENT;
-  inev.modifiers = 0;
-  inev.arg = list4 (Qlambda, intern (gdk_atom_name (name)),
-                   make_uint (time),
-                   drag_action_to_symbol (suggestion));
-  inev.timestamp = time;
+  inev.ie.kind = DRAG_N_DROP_EVENT;
+  inev.ie.modifiers = 0;
+  inev.ie.arg = list4 (Qlambda, intern (gdk_atom_name (name)),
+                      make_uint (time),
+                      drag_action_to_symbol (suggestion));
+  inev.ie.timestamp = time;
 
-  XSETINT (inev.x, x);
-  XSETINT (inev.y, y);
-  XSETFRAME (inev.frame_or_window, f);
+  XSETINT (inev.ie.x, x);
+  XSETINT (inev.ie.y, y);
+  XSETFRAME (inev.ie.frame_or_window, f);
 
   evq_enqueue (&inev);
 
@@ -6498,7 +6477,7 @@ drag_drop (GtkWidget *widget, GdkDragContext *context,
           int x, int y, guint time, gpointer user_data)
 {
   struct frame *f;
-  struct input_event inev;
+  union buffered_input_event inev;
   GdkAtom name;
   GdkDragAction selected_action;
 
@@ -6524,18 +6503,18 @@ drag_drop (GtkWidget *widget, GdkDragContext *context,
   name = gdk_drag_get_selection (context);
   selected_action = gdk_drag_context_get_selected_action (context);
 
-  EVENT_INIT (inev);
+  EVENT_INIT (inev.ie);
 
-  inev.kind = DRAG_N_DROP_EVENT;
-  inev.modifiers = 0;
-  inev.arg = list4 (Qquote, intern (gdk_atom_name (name)),
-                   make_uint (time),
-                   drag_action_to_symbol (selected_action));
-  inev.timestamp = time;
+  inev.ie.kind = DRAG_N_DROP_EVENT;
+  inev.ie.modifiers = 0;
+  inev.ie.arg = list4 (Qquote, intern (gdk_atom_name (name)),
+                      make_uint (time),
+                      drag_action_to_symbol (selected_action));
+  inev.ie.timestamp = time;
 
-  XSETINT (inev.x, x);
-  XSETINT (inev.y, y);
-  XSETFRAME (inev.frame_or_window, f);
+  XSETINT (inev.ie.x, x);
+  XSETINT (inev.ie.y, y);
+  XSETFRAME (inev.ie.frame_or_window, f);
 
   evq_enqueue (&inev);
 
@@ -6663,12 +6642,12 @@ touch_event_cb (GtkWidget *self, GdkEvent *event, gpointer user_data)
   struct pgtk_display_info *dpyinfo;
   struct frame *f;
   EMACS_INT local_detail;
-  struct input_event inev;
+  union buffered_input_event inev;
   struct pgtk_touch_point *touchpoint;
   Lisp_Object arg = Qnil;
   int state;
 
-  EVENT_INIT (inev);
+  EVENT_INIT (inev.ie);
 
   f = pgtk_any_window_to_frame (gtk_widget_get_window (self));
   eassert (f);
@@ -6687,12 +6666,12 @@ touch_event_cb (GtkWidget *self, GdkEvent *event, gpointer user_data)
                                            event->touch.x, event->touch.y,
                                            f);
       /* Generate the input event.  */
-      inev.kind = TOUCHSCREEN_BEGIN_EVENT;
-      inev.timestamp = event->touch.time;
-      XSETFRAME (inev.frame_or_window, f);
-      XSETINT (inev.x, lrint (event->touch.x));
-      XSETINT (inev.y, lrint (event->touch.y));
-      XSETINT (inev.arg, local_detail);
+      inev.ie.kind = TOUCHSCREEN_BEGIN_EVENT;
+      inev.ie.timestamp = event->touch.time;
+      XSETFRAME (inev.ie.frame_or_window, f);
+      XSETINT (inev.ie.x, lrint (event->touch.x));
+      XSETINT (inev.ie.y, lrint (event->touch.y));
+      XSETINT (inev.ie.arg, local_detail);
       break;
 
     case GDK_TOUCH_UPDATE:
@@ -6709,9 +6688,9 @@ touch_event_cb (GtkWidget *self, GdkEvent *event, gpointer user_data)
       /* Construct the input event.  */
       touchpoint->x = lrint (event->touch.x);
       touchpoint->y = lrint (event->touch.y);
-      inev.kind = TOUCHSCREEN_UPDATE_EVENT;
-      inev.timestamp = event->touch.time;
-      XSETFRAME (inev.frame_or_window, f);
+      inev.ie.kind = TOUCHSCREEN_UPDATE_EVENT;
+      inev.ie.timestamp = event->touch.time;
+      XSETFRAME (inev.ie.frame_or_window, f);
 
       for (touchpoint = dpyinfo->touchpoints;
           touchpoint; touchpoint = touchpoint->next)
@@ -6722,7 +6701,7 @@ touch_event_cb (GtkWidget *self, GdkEvent *event, gpointer user_data)
                         arg);
        }
 
-      inev.arg = arg;
+      inev.ie.arg = arg;
       break;
 
     case GDK_TOUCH_END:
@@ -6735,14 +6714,14 @@ touch_event_cb (GtkWidget *self, GdkEvent *event, gpointer user_data)
       if (state)
        {
          /* ... generate a suitable event.  */
-         inev.kind = TOUCHSCREEN_END_EVENT;
-         inev.timestamp = event->touch.time;
-         inev.modifiers = (event->type != GDK_TOUCH_END);
-
-         XSETFRAME (inev.frame_or_window, f);
-         XSETINT (inev.x, lrint (event->touch.x));
-         XSETINT (inev.y, lrint (event->touch.y));
-         XSETINT (inev.arg, local_detail);
+         inev.ie.kind = TOUCHSCREEN_END_EVENT;
+         inev.ie.timestamp = event->touch.time;
+         inev.ie.modifiers = (event->type != GDK_TOUCH_END);
+
+         XSETFRAME (inev.ie.frame_or_window, f);
+         XSETINT (inev.ie.x, lrint (event->touch.x));
+         XSETINT (inev.ie.y, lrint (event->touch.y));
+         XSETINT (inev.ie.arg, local_detail);
        }
       break;
 
@@ -6753,9 +6732,9 @@ touch_event_cb (GtkWidget *self, GdkEvent *event, gpointer user_data)
   /* If the above produced a workable event, report the name of the
      device that gave rise to it.  */
 
-  if (inev.kind != NO_EVENT)
+  if (inev.ie.kind != NO_EVENT)
     {
-      inev.device = pgtk_get_device_for_event (dpyinfo, event);
+      inev.ie.device = pgtk_get_device_for_event (dpyinfo, event);
       evq_enqueue (&inev);
 
       /* Next, save this event for future menu activations, unless it is
@@ -6768,7 +6747,7 @@ touch_event_cb (GtkWidget *self, GdkEvent *event, gpointer user_data)
        }
     }
 
-  return inev.kind != NO_EVENT;
+  return inev.ie.kind != NO_EVENT;
 }
 
 \f
@@ -6779,12 +6758,12 @@ static void
 pgtk_monitors_changed_cb (GdkScreen *screen, gpointer user_data)
 {
   struct terminal *terminal;
-  struct input_event inev;
+  union buffered_input_event inev;
 
-  EVENT_INIT (inev);
+  EVENT_INIT (inev.ie);
   terminal = user_data;
-  inev.kind = MONITORS_CHANGED_EVENT;
-  XSETTERMINAL (inev.arg, terminal);
+  inev.ie.kind = MONITORS_CHANGED_EVENT;
+  XSETTERMINAL (inev.ie.arg, terminal);
 
   evq_enqueue (&inev);
 }
@@ -6946,6 +6925,7 @@ pgtk_selection_event (GtkWidget *widget, GdkEvent *event,
                      gpointer user_data)
 {
   struct frame *f;
+  union buffered_input_event inev;
 
   if (event->type == GDK_PROPERTY_NOTIFY)
     pgtk_handle_property_notify (&event->property);
@@ -6956,15 +6936,15 @@ pgtk_selection_event (GtkWidget *widget, GdkEvent *event,
 
       if (f)
        {
-         struct selection_input_event sinev = {0};
+         EVENT_INIT (inev.ie);
 
-         sinev.kind = (event->type == GDK_SELECTION_CLEAR
+         inev.sie.kind = (event->type == GDK_SELECTION_CLEAR
                           ? SELECTION_CLEAR_EVENT
                           : SELECTION_REQUEST_EVENT);
 
-         SELECTION_EVENT_DPYINFO (&sinev) = FRAME_DISPLAY_INFO (f);
-         SELECTION_EVENT_SELECTION (&sinev) = event->selection.selection;
-         SELECTION_EVENT_TIME (&sinev) = event->selection.time;
+         SELECTION_EVENT_DPYINFO (&inev.sie) = FRAME_DISPLAY_INFO (f);
+         SELECTION_EVENT_SELECTION (&inev.sie) = event->selection.selection;
+         SELECTION_EVENT_TIME (&inev.sie) = event->selection.time;
 
          if (event->type == GDK_SELECTION_REQUEST)
            {
@@ -6974,12 +6954,12 @@ pgtk_selection_event (GtkWidget *widget, GdkEvent *event,
                 It would make sense to wait for the transfer to
                 complete.  But I don't know if GDK actually does
                 that.  */
-             SELECTION_EVENT_REQUESTOR (&sinev) = event->selection.requestor;
-             SELECTION_EVENT_TARGET (&sinev) = event->selection.target;
-             SELECTION_EVENT_PROPERTY (&sinev) = event->selection.property;
+             SELECTION_EVENT_REQUESTOR (&inev.sie) = event->selection.requestor;
+             SELECTION_EVENT_TARGET (&inev.sie) = event->selection.target;
+             SELECTION_EVENT_PROPERTY (&inev.sie) = event->selection.property;
            }
 
-         evq_selection_enqueue (&sinev);
+         evq_enqueue (&inev);
          return TRUE;
        }
     }
index aa2116a4b9fc870f91aa2d9dd3a40ed598321899..2ccf267bbd31326bea69ff91c99b08c0faa3005b 100644 (file)
@@ -18881,7 +18881,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 #endif
                   int *finish, struct input_event *hold_quit)
 {
-  struct input_event inev;
+  union buffered_input_event inev;
   int count = 0;
   int do_help = 0;
 #ifdef HAVE_XINPUT2
@@ -18924,9 +18924,9 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 
   *finish = X_EVENT_NORMAL;
 
-  EVENT_INIT (inev);
-  inev.kind = NO_EVENT;
-  inev.arg = Qnil;
+  EVENT_INIT (inev.ie);
+  inev.ie.kind = NO_EVENT;
+  inev.ie.arg = Qnil;
 #ifdef HAVE_XINPUT2
   gen_help_device = NULL;
 #endif
@@ -19257,9 +19257,9 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                 if (!f)
                  goto OTHER; /* May be a dialog that is to be removed  */
 
-               inev.kind = DELETE_WINDOW_EVENT;
-               inev.timestamp = event->xclient.data.l[1];
-               XSETFRAME (inev.frame_or_window, f);
+               inev.ie.kind = DELETE_WINDOW_EVENT;
+               inev.ie.timestamp = event->xclient.data.l[1];
+               XSETFRAME (inev.ie.frame_or_window, f);
                goto done;
               }
 
@@ -19413,7 +19413,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
            /* Convert the scroll bar event to an input event using
               the first window entered into the scroll bar event
               queue. */
-           x_scroll_bar_to_input_event (dpyinfo, event, &inev);
+            x_scroll_bar_to_input_event (dpyinfo, event, &inev.ie);
 
            *finish = X_EVENT_GOTO_OUT;
             goto done;
@@ -19423,7 +19423,8 @@ handle_one_xevent (struct x_display_info *dpyinfo,
            /* Convert the horizontal scroll bar event to an input
               event using the first window entered into the scroll
               bar event queue. */
-           x_horizontal_scroll_bar_to_input_event (dpyinfo, event, &inev);
+            x_horizontal_scroll_bar_to_input_event (dpyinfo, event,
+                                                   &inev.ie);
 
            *finish = X_EVENT_GOTO_OUT;
             goto done;
@@ -19435,7 +19436,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
           {
            enum xembed_message msg = event->xclient.data.l[1];
            if (msg == XEMBED_FOCUS_IN || msg == XEMBED_FOCUS_OUT)
-             x_detect_focus_change (dpyinfo, any, event, &inev);
+             x_detect_focus_change (dpyinfo, any, event, &inev.ie);
 
            *finish = X_EVENT_GOTO_OUT;
             goto done;
@@ -19474,7 +19475,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
        rc = x_coords_from_dnd_message (dpyinfo, (XEvent *) event,
                                        &dx, &dy);
 
-       if (x_handle_dnd_message (f, &event->xclient, dpyinfo, &inev,
+       if (x_handle_dnd_message (f, &event->xclient, dpyinfo, &inev.ie,
                                  rc, dx, dy))
          *finish = X_EVENT_DROP;
       }
@@ -19510,18 +19511,15 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                || dpyinfo->motif_drag_atom_time <= eventp->time))
          dpyinfo->motif_drag_atom = None;
 
-       struct selection_input_event sinev = {0};
-       sinev.kind = SELECTION_CLEAR_EVENT;
-       SELECTION_EVENT_DPYINFO (&sinev) = dpyinfo;
-       SELECTION_EVENT_SELECTION (&sinev) = eventp->selection;
-       SELECTION_EVENT_TIME (&sinev) = eventp->time;
+        inev.sie.kind = SELECTION_CLEAR_EVENT;
+        SELECTION_EVENT_DPYINFO (&inev.sie) = dpyinfo;
+        SELECTION_EVENT_SELECTION (&inev.sie) = eventp->selection;
+        SELECTION_EVENT_TIME (&inev.sie) = eventp->time;
 
        if (x_use_pending_selection_requests)
-         x_push_selection_request (&sinev);
-       else
          {
-           kbd_buffer_store_selection_event_hold (&sinev, hold_quit);
-           count++;
+           x_push_selection_request (&inev.sie);
+           EVENT_INIT (inev.ie);
          }
       }
       break;
@@ -19537,25 +19535,22 @@ handle_one_xevent (struct x_display_info *dpyinfo,
       {
        const XSelectionRequestEvent *eventp = &event->xselectionrequest;
 
-       struct selection_input_event sinev;
-       sinev.kind = SELECTION_REQUEST_EVENT;
-       SELECTION_EVENT_DPYINFO (&sinev) = dpyinfo;
-       SELECTION_EVENT_REQUESTOR (&sinev) = eventp->requestor;
-       SELECTION_EVENT_SELECTION (&sinev) = eventp->selection;
-       SELECTION_EVENT_TARGET (&sinev) = eventp->target;
-       SELECTION_EVENT_PROPERTY (&sinev) = eventp->property;
-       SELECTION_EVENT_TIME (&sinev) = eventp->time;
+       inev.sie.kind = SELECTION_REQUEST_EVENT;
+       SELECTION_EVENT_DPYINFO (&inev.sie) = dpyinfo;
+       SELECTION_EVENT_REQUESTOR (&inev.sie) = eventp->requestor;
+       SELECTION_EVENT_SELECTION (&inev.sie) = eventp->selection;
+       SELECTION_EVENT_TARGET (&inev.sie) = eventp->target;
+       SELECTION_EVENT_PROPERTY (&inev.sie) = eventp->property;
+       SELECTION_EVENT_TIME (&inev.sie) = eventp->time;
 
        /* If drag-and-drop or another modal dialog/menu is in
           progress, handle SelectionRequest events immediately, by
           pushing it onto the selection queue.  */
 
        if (x_use_pending_selection_requests)
-         x_push_selection_request (&sinev);
-       else
          {
-           kbd_buffer_store_selection_event_hold (&sinev, hold_quit);
-           count++;
+           x_push_selection_request (&inev.sie);
+           EVENT_INIT (inev.ie);
          }
 
        if (x_dnd_waiting_for_finish
@@ -19654,7 +19649,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
              SET_FRAME_ICONIFIED (f, false);
 
              f->output_data.x->has_been_visible = true;
-             inev.kind = DEICONIFY_EVENT;
+             inev.ie.kind = DEICONIFY_EVENT;
 #if defined USE_GTK && defined HAVE_GTK3
              /* If GTK3 wants to impose some old size here (Bug#24526),
                 tell it that the current size is what we want.  */
@@ -19665,7 +19660,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                  f->was_invisible = false;
                }
 #endif
-             XSETFRAME (inev.frame_or_window, f);
+             XSETFRAME (inev.ie.frame_or_window, f);
            }
          else if (!not_hidden && !FRAME_ICONIFIED_P (f))
            {
@@ -19675,8 +19670,8 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 
              SET_FRAME_VISIBLE (f, 0);
              SET_FRAME_ICONIFIED (f, true);
-             inev.kind = ICONIFY_EVENT;
-             XSETFRAME (inev.frame_or_window, f);
+             inev.ie.kind = ICONIFY_EVENT;
+             XSETFRAME (inev.ie.frame_or_window, f);
            }
        }
 
@@ -19691,7 +19686,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
           set.  Handling UnmapNotify also checks for
           _NET_WM_STATE_HIDDEN, and thus suffers from the same
           problem.  */
-       x_handle_wm_state (f, &inev);
+       x_handle_wm_state (f, &inev.ie);
 
       if (f && FRAME_X_OUTPUT (f)->alpha_identical_p
          && (event->xproperty.atom
@@ -20093,8 +20088,8 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                  (f, build_string ("UnmapNotify, visible | iconified"));
 
               SET_FRAME_ICONIFIED (f, true);
-             inev.kind = ICONIFY_EVENT;
-             XSETFRAME (inev.frame_or_window, f);
+             inev.ie.kind = ICONIFY_EVENT;
+              XSETFRAME (inev.ie.frame_or_window, f);
             }
          else if (CONSP (frame_size_history))
            frame_size_history_plain
@@ -20203,8 +20198,8 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 
           if ((not_hidden || FRAME_X_EMBEDDED_P (f)) && iconified)
             {
-             inev.kind = DEICONIFY_EVENT;
-             XSETFRAME (inev.frame_or_window, f);
+              inev.ie.kind = DEICONIFY_EVENT;
+              XSETFRAME (inev.ie.frame_or_window, f);
             }
         }
       goto OTHER;
@@ -20470,17 +20465,18 @@ handle_one_xevent (struct x_display_info *dpyinfo,
           orig_keysym = keysym;
 
          /* Common for all keysym input events.  */
-         XSETFRAME (inev.frame_or_window, f);
-         inev.modifiers = x_x_to_emacs_modifiers (dpyinfo, modifiers);
-         inev.timestamp = xkey.time;
+         XSETFRAME (inev.ie.frame_or_window, f);
+         inev.ie.modifiers
+           = x_x_to_emacs_modifiers (dpyinfo, modifiers);
+         inev.ie.timestamp = xkey.time;
 
          /* First deal with keysyms which have defined
             translations to characters.  */
          if (keysym >= 32 && keysym < 128)
            /* Avoid explicitly decoding each ASCII character.  */
            {
-             inev.kind = ASCII_KEYSTROKE_EVENT;
-             inev.code = keysym;
+             inev.ie.kind = ASCII_KEYSTROKE_EVENT;
+             inev.ie.code = keysym;
 
 #ifdef HAVE_XINPUT2
              if (event->xkey.time == pending_keystroke_time)
@@ -20489,7 +20485,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                                              dpyinfo->pending_keystroke_source);
 
                  if (source)
-                   inev.device = source->name;
+                   inev.ie.device = source->name;
                }
 #endif
 
@@ -20500,10 +20496,10 @@ handle_one_xevent (struct x_display_info *dpyinfo,
          if (keysym >= 0x01000000 && keysym <= 0x0110FFFF)
            {
              if (keysym < 0x01000080)
-               inev.kind = ASCII_KEYSTROKE_EVENT;
+               inev.ie.kind = ASCII_KEYSTROKE_EVENT;
              else
-               inev.kind = MULTIBYTE_CHAR_KEYSTROKE_EVENT;
-             inev.code = keysym & 0xFFFFFF;
+               inev.ie.kind = MULTIBYTE_CHAR_KEYSTROKE_EVENT;
+             inev.ie.code = keysym & 0xFFFFFF;
 
 #ifdef HAVE_XINPUT2
              if (event->xkey.time == pending_keystroke_time)
@@ -20512,7 +20508,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                                              dpyinfo->pending_keystroke_source);
 
                  if (source)
-                   inev.device = source->name;
+                   inev.ie.device = source->name;
                }
 #endif
 
@@ -20526,10 +20522,10 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                                Qnil),
                  FIXNATP (c)))
            {
-             inev.kind = (SINGLE_BYTE_CHAR_P (XFIXNAT (c))
-                          ? ASCII_KEYSTROKE_EVENT
-                          : MULTIBYTE_CHAR_KEYSTROKE_EVENT);
-             inev.code = XFIXNAT (c);
+             inev.ie.kind = (SINGLE_BYTE_CHAR_P (XFIXNAT (c))
+                              ? ASCII_KEYSTROKE_EVENT
+                              : MULTIBYTE_CHAR_KEYSTROKE_EVENT);
+             inev.ie.code = XFIXNAT (c);
 
 #ifdef HAVE_XINPUT2
              if (event->xkey.time == pending_keystroke_time)
@@ -20538,7 +20534,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                                              dpyinfo->pending_keystroke_source);
 
                  if (source)
-                   inev.device = source->name;
+                   inev.ie.device = source->name;
                }
 #endif
 
@@ -20644,8 +20640,8 @@ handle_one_xevent (struct x_display_info *dpyinfo,
              STORE_KEYSYM_FOR_DEBUG (keysym);
              /* make_lispy_event will convert this to a symbolic
                 key.  */
-             inev.kind = NON_ASCII_KEYSTROKE_EVENT;
-             inev.code = keysym;
+             inev.ie.kind = NON_ASCII_KEYSTROKE_EVENT;
+             inev.ie.code = keysym;
 
 #ifdef HAVE_XINPUT2
              if (event->xkey.time == pending_keystroke_time)
@@ -20654,7 +20650,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                                              dpyinfo->pending_keystroke_source);
 
                  if (source)
-                   inev.device = source->name;
+                   inev.ie.device = source->name;
                }
 #endif
 
@@ -20671,11 +20667,11 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 
            if (nbytes)
              {
-               inev.kind = MULTIBYTE_CHAR_KEYSTROKE_EVENT;
-               inev.arg = make_unibyte_string ((char *) copy_bufptr, nbytes);
+               inev.ie.kind = MULTIBYTE_CHAR_KEYSTROKE_EVENT;
+               inev.ie.arg = make_unibyte_string ((char *) copy_bufptr, nbytes);
 
                Fput_text_property (make_fixnum (0), make_fixnum (nbytes),
-                                   Qcoding, coding, inev.arg);
+                                   Qcoding, coding, inev.ie.arg);
 
 #ifdef HAVE_XINPUT2
                if (event->xkey.time == pending_keystroke_time
@@ -20689,7 +20685,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                                                dpyinfo->pending_keystroke_source);
 
                    if (source)
-                     inev.device = source->name;
+                     inev.ie.device = source->name;
                  }
 #endif
              }
@@ -20764,7 +20760,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
         to treat implicit focus correctly.  (bug#65919) */
 #if defined USE_X_TOOLKIT || (defined USE_GTK && !defined HAVE_GTK3)
       if (x_top_window_to_frame (dpyinfo, event->xcrossing.window))
-       x_detect_focus_change (dpyinfo, any, event, &inev);
+       x_detect_focus_change (dpyinfo, any, event, &inev.ie);
 #endif /* defined USE_X_TOOLKIT || (defined USE_GTK && !defined HAVE_GTK3) */
 
 #ifdef HAVE_XINPUT2
@@ -20783,7 +20779,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
         builds.  */
 #if !defined USE_X_TOOLKIT || (!defined USE_GTK || defined HAVE_GTK3)
       if (x_top_window_to_frame (dpyinfo, event->xcrossing.window))
-       x_detect_focus_change (dpyinfo, any, event, &inev);
+       x_detect_focus_change (dpyinfo, any, event, &inev.ie);
 #endif /* !defined USE_X_TOOLKIT || (!defined USE_GTK || defined HAVE_GTK3) */
 
       f = any;
@@ -20857,12 +20853,12 @@ handle_one_xevent (struct x_display_info *dpyinfo,
              SET_FRAME_VISIBLE (f, 1);
              SET_FRAME_ICONIFIED (f, false);
              f->output_data.x->has_been_visible = true;
-             inev.kind = DEICONIFY_EVENT;
-             XSETFRAME (inev.frame_or_window, f);
+             inev.ie.kind = DEICONIFY_EVENT;
+             XSETFRAME (inev.ie.frame_or_window, f);
            }
        }
 
-      x_detect_focus_change (dpyinfo, any, event, &inev);
+      x_detect_focus_change (dpyinfo, any, event, &inev.ie);
       goto OTHER;
 
     case LeaveNotify:
@@ -20874,7 +20870,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
         to treat implicit focus correctly.  */
 #if defined USE_X_TOOLKIT || (defined USE_GTK && !defined HAVE_GTK3)
       if (x_top_window_to_frame (dpyinfo, event->xcrossing.window))
-       x_detect_focus_change (dpyinfo, any, event, &inev);
+       x_detect_focus_change (dpyinfo, any, event, &inev.ie);
 #endif /* defined USE_X_TOOLKIT || (defined USE_GTK && !defined HAVE_GTK3) */
 
 #ifdef HAVE_XINPUT2
@@ -20906,7 +20902,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
         builds.  */
 #if !defined USE_X_TOOLKIT || (!defined USE_GTK || defined HAVE_GTK3)
       if (x_top_window_to_frame (dpyinfo, event->xcrossing.window))
-       x_detect_focus_change (dpyinfo, any, event, &inev);
+       x_detect_focus_change (dpyinfo, any, event, &inev.ie);
 #endif /* !defined USE_X_TOOLKIT || (!defined USE_GTK || defined HAVE_GTK3) */
 
 #ifdef HAVE_XWIDGETS
@@ -21007,7 +21003,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
       if (dpyinfo->supports_xi2)
        goto OTHER;
 #endif
-      x_detect_focus_change (dpyinfo, any, event, &inev);
+      x_detect_focus_change (dpyinfo, any, event, &inev.ie);
       goto OTHER;
 
     case MotionNotify:
@@ -21317,8 +21313,8 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                    && !EQ (window, last_mouse_window)
                    && !EQ (window, selected_window))
                  {
-                   inev.kind = SELECT_WINDOW_EVENT;
-                   inev.frame_or_window = window;
+                   inev.ie.kind = SELECT_WINDOW_EVENT;
+                   inev.ie.frame_or_window = window;
                  }
 
                /* Remember the last window where we saw the mouse.  */
@@ -21409,13 +21405,13 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                 hook.  */
              if (!x_find_monitors_changed_event (dpyinfo))
                {
-                 inev.kind = MONITORS_CHANGED_EVENT;
-                 XSETTERMINAL (inev.arg, dpyinfo->terminal);
+                 inev.ie.kind = MONITORS_CHANGED_EVENT;
+                 XSETTERMINAL (inev.ie.arg, dpyinfo->terminal);
 
-                 /* Store this event now since inev.type could be set to
+                 /* Store this event now since inev.ie.type could be set to
                     MOVE_FRAME_EVENT later.  */
-                 kbd_buffer_store_event (&inev);
-                 inev.kind = NO_EVENT;
+                 kbd_buffer_store_event (&inev.ie);
+                 inev.ie.kind = NO_EVENT;
                }
 
              /* Also update the position of the drag-and-drop
@@ -21682,8 +21678,8 @@ handle_one_xevent (struct x_display_info *dpyinfo,
              if (!FRAME_TOOLTIP_P (f)
                  && (old_left != f->left_pos || old_top != f->top_pos))
                {
-                 inev.kind = MOVE_FRAME_EVENT;
-                 XSETFRAME (inev.frame_or_window, f);
+                 inev.ie.kind = MOVE_FRAME_EVENT;
+                 XSETFRAME (inev.ie.frame_or_window, f);
                }
            }
 
@@ -21749,8 +21745,8 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 
             if (!EQ (selected_window, xvw->w) && (event->xbutton.button < 4))
               {
-               inev.kind = SELECT_WINDOW_EVENT;
-               inev.frame_or_window = xvw->w;
+               inev.ie.kind = SELECT_WINDOW_EVENT;
+               inev.ie.frame_or_window = xvw->w;
              }
 
            *finish = X_EVENT_DROP;
@@ -22006,14 +22002,14 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                        && event->xbutton.time > ignore_next_mouse_click_timeout)
                      {
                        ignore_next_mouse_click_timeout = 0;
-                       x_construct_mouse_click (&inev, &event->xbutton,
+                       x_construct_mouse_click (&inev.ie, &event->xbutton,
                                                 f, false);
                      }
                    if (event->type == ButtonRelease)
                      ignore_next_mouse_click_timeout = 0;
                  }
                else
-                 x_construct_mouse_click (&inev, &event->xbutton, f, false);
+                 x_construct_mouse_click (&inev.ie, &event->xbutton, f, false);
 
                *finish = X_EVENT_DROP;
                goto OTHER;
@@ -22083,18 +22079,18 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                           && event->xbutton.time > ignore_next_mouse_click_timeout)
                         {
                           ignore_next_mouse_click_timeout = 0;
-                         x_construct_mouse_click (&inev, &event->xbutton,
+                          x_construct_mouse_click (&inev.ie, &event->xbutton,
                                                    f, false);
                         }
                       if (event->type == ButtonRelease)
                         ignore_next_mouse_click_timeout = 0;
                     }
                   else
-                   x_construct_mouse_click (&inev, &event->xbutton,
+                    x_construct_mouse_click (&inev.ie, &event->xbutton,
                                              f, false);
 
                  if (!NILP (tab_bar_arg))
-                   inev.arg = tab_bar_arg;
+                   inev.ie.arg = tab_bar_arg;
                 }
 
             if (FRAME_X_EMBEDDED_P (f)
@@ -22113,12 +22109,12 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                scroll bars.  */
             if (bar && event->xbutton.state & ControlMask)
               {
-               x_scroll_bar_handle_click (bar, event, &inev, Qnil);
+                x_scroll_bar_handle_click (bar, event, &inev.ie, Qnil);
                 *finish = X_EVENT_DROP;
               }
 #else /* not USE_TOOLKIT_SCROLL_BARS */
             if (bar)
-             x_scroll_bar_handle_click (bar, event, &inev, Qnil);
+              x_scroll_bar_handle_click (bar, event, &inev.ie, Qnil);
 #endif /* not USE_TOOLKIT_SCROLL_BARS */
           }
 
@@ -22175,8 +22171,8 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                if (!f->output_data.x->saved_menu_event)
                  f->output_data.x->saved_menu_event = xmalloc (sizeof *event);
                *f->output_data.x->saved_menu_event = *event;
-               inev.kind = MENU_BAR_ACTIVATE_EVENT;
-               XSETFRAME (inev.frame_or_window, f);
+               inev.ie.kind = MENU_BAR_ACTIVATE_EVENT;
+               XSETFRAME (inev.ie.frame_or_window, f);
                *finish = X_EVENT_DROP;
 #ifdef USE_MOTIF
              }
@@ -22327,8 +22323,8 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                      SET_FRAME_VISIBLE (f, 1);
                      SET_FRAME_ICONIFIED (f, false);
                      f->output_data.x->has_been_visible = true;
-                     inev.kind = DEICONIFY_EVENT;
-                     XSETFRAME (inev.frame_or_window, f);
+                     inev.ie.kind = DEICONIFY_EVENT;
+                     XSETFRAME (inev.ie.frame_or_window, f);
                    }
                }
 
@@ -22878,36 +22874,36 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 
                      if (fabs (total_x) > 0 || fabs (total_y) > 0)
                        {
-                         inev.kind = (fabs (total_y) >= fabs (total_x)
-                                      ? WHEEL_EVENT : HORIZ_WHEEL_EVENT);
-                         inev.timestamp = xev->time;
-
-                         XSETINT (inev.x, lrint (real_x));
-                         XSETINT (inev.y, lrint (real_y));
-                         XSETFRAME (inev.frame_or_window, f);
-
-                         inev.modifiers = (signbit (fabs (total_y) >= fabs (total_x)
-                                                    ? total_y : total_x)
-                                           ? down_modifier : up_modifier);
-                         inev.modifiers
+                         inev.ie.kind = (fabs (total_y) >= fabs (total_x)
+                                         ? WHEEL_EVENT : HORIZ_WHEEL_EVENT);
+                         inev.ie.timestamp = xev->time;
+
+                         XSETINT (inev.ie.x, lrint (real_x));
+                         XSETINT (inev.ie.y, lrint (real_y));
+                         XSETFRAME (inev.ie.frame_or_window, f);
+
+                         inev.ie.modifiers = (signbit (fabs (total_y) >= fabs (total_x)
+                                                       ? total_y : total_x)
+                                              ? down_modifier : up_modifier);
+                         inev.ie.modifiers
                            |= x_x_to_emacs_modifiers (dpyinfo,
                                                       xev->mods.effective);
-                         inev.arg = list3 (Qnil,
-                                           make_float (total_x),
-                                           make_float (total_y));
+                         inev.ie.arg = list3 (Qnil,
+                                              make_float (total_x),
+                                              make_float (total_y));
                        }
                      else
                        {
-                         inev.kind = TOUCH_END_EVENT;
-                         inev.timestamp = xev->time;
+                         inev.ie.kind = TOUCH_END_EVENT;
+                         inev.ie.timestamp = xev->time;
 
-                         XSETINT (inev.x, lrint (real_x));
-                         XSETINT (inev.y, lrint (real_y));
-                         XSETFRAME (inev.frame_or_window, f);
+                         XSETINT (inev.ie.x, lrint (real_x));
+                         XSETINT (inev.ie.y, lrint (real_y));
+                         XSETFRAME (inev.ie.frame_or_window, f);
                        }
 
                      if (source && !NILP (source->name))
-                       inev.device = source->name;
+                       inev.ie.device = source->name;
 
                      if (!other_valuators_found)
                        goto XI_OTHER;
@@ -23248,11 +23244,11 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                          && !EQ (window, last_mouse_window)
                          && !EQ (window, selected_window))
                        {
-                         inev.kind = SELECT_WINDOW_EVENT;
-                         inev.frame_or_window = window;
+                         inev.ie.kind = SELECT_WINDOW_EVENT;
+                         inev.ie.frame_or_window = window;
 
                          if (source)
-                           inev.device = source->name;
+                           inev.ie.device = source->name;
                        }
 
                      /* Remember the last window where we saw the mouse.  */
@@ -23640,11 +23636,11 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 
                  if (!EQ (selected_window, xvw->w) && (xev->detail < 4))
                    {
-                     inev.kind = SELECT_WINDOW_EVENT;
-                     inev.frame_or_window = xvw->w;
+                     inev.ie.kind = SELECT_WINDOW_EVENT;
+                     inev.ie.frame_or_window = xvw->w;
 
                      if (source)
-                       inev.device = source->name;
+                       inev.ie.device = source->name;
                    }
 
                  *finish = X_EVENT_DROP;
@@ -23743,24 +23739,24 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                                                     &real_x, &real_y);
 
                          if (xev->detail <= 5)
-                           inev.kind = WHEEL_EVENT;
+                           inev.ie.kind = WHEEL_EVENT;
                          else
-                           inev.kind = HORIZ_WHEEL_EVENT;
+                           inev.ie.kind = HORIZ_WHEEL_EVENT;
 
                          if (source)
-                           inev.device = source->name;
+                           inev.ie.device = source->name;
 
-                         inev.timestamp = xev->time;
+                         inev.ie.timestamp = xev->time;
 
-                         XSETINT (inev.x, real_x);
-                         XSETINT (inev.y, real_y);
-                         XSETFRAME (inev.frame_or_window, f);
+                         XSETINT (inev.ie.x, real_x);
+                         XSETINT (inev.ie.y, real_y);
+                         XSETFRAME (inev.ie.frame_or_window, f);
 
-                         inev.modifiers
+                         inev.ie.modifiers
                            |= x_x_to_emacs_modifiers (dpyinfo,
                                                       xev->mods.effective);
 
-                         inev.modifiers |= xev->detail % 2 ? down_modifier : up_modifier;
+                         inev.ie.modifiers |= xev->detail % 2 ? down_modifier : up_modifier;
                        }
 
                      *finish = X_EVENT_DROP;
@@ -23781,24 +23777,24 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                      if (xev->evtype == XI_ButtonRelease)
                        {
                          if (xev->detail <= 5)
-                           inev.kind = WHEEL_EVENT;
+                           inev.ie.kind = WHEEL_EVENT;
                          else
-                           inev.kind = HORIZ_WHEEL_EVENT;
+                           inev.ie.kind = HORIZ_WHEEL_EVENT;
 
                          if (source)
-                           inev.device = source->name;
+                           inev.ie.device = source->name;
 
-                         inev.timestamp = xev->time;
+                         inev.ie.timestamp = xev->time;
 
-                         XSETINT (inev.x, lrint (xev->event_x));
-                         XSETINT (inev.y, lrint (xev->event_y));
-                         XSETFRAME (inev.frame_or_window, f);
+                         XSETINT (inev.ie.x, lrint (xev->event_x));
+                         XSETINT (inev.ie.y, lrint (xev->event_y));
+                         XSETFRAME (inev.ie.frame_or_window, f);
 
-                         inev.modifiers
+                         inev.ie.modifiers
                            |= x_x_to_emacs_modifiers (dpyinfo,
                                                       xev->mods.effective);
 
-                         inev.modifiers |= xev->detail % 2 ? down_modifier : up_modifier;
+                         inev.ie.modifiers |= xev->detail % 2 ? down_modifier : up_modifier;
                        }
 
                      goto XI_OTHER;
@@ -23867,16 +23863,16 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                                && xev->time > ignore_next_mouse_click_timeout)
                              {
                                ignore_next_mouse_click_timeout = 0;
-                               x_construct_mouse_click (&inev, &bv, f, true);
+                               x_construct_mouse_click (&inev.ie, &bv, f, true);
                              }
                            if (xev->evtype == XI_ButtonRelease)
                              ignore_next_mouse_click_timeout = 0;
                          }
                        else
-                         x_construct_mouse_click (&inev, &bv, f, true);
+                         x_construct_mouse_click (&inev.ie, &bv, f, true);
 
                        if (!NILP (tab_bar_arg))
-                         inev.arg = tab_bar_arg;
+                         inev.ie.arg = tab_bar_arg;
                      }
 
                  if (FRAME_X_EMBEDDED_P (f)
@@ -23892,14 +23888,14 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 
 #ifndef USE_TOOLKIT_SCROLL_BARS
                  if (bar)
-                   x_scroll_bar_handle_click (bar, (XEvent *) &bv, &inev,
+                   x_scroll_bar_handle_click (bar, (XEvent *) &bv, &inev.ie,
                                               source ? source->name : Qnil);
 #else
                  /* Make the "Ctrl-Mouse-2 splits window" work for toolkit
                     scroll bars.  */
                  if (bar && xev->mods.effective & ControlMask)
                    {
-                     x_scroll_bar_handle_click (bar, (XEvent *) &bv, &inev,
+                     x_scroll_bar_handle_click (bar, (XEvent *) &bv, &inev.ie,
                                                 source ? source->name : Qnil);
                      *finish = X_EVENT_DROP;
                    }
@@ -23925,8 +23921,8 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                  device->grab &= ~(1 << xev->detail);
                }
 
-             if (source && inev.kind != NO_EVENT)
-               inev.device = source->name;
+             if (source && inev.ie.kind != NO_EVENT)
+               inev.ie.device = source->name;
 
              if (f)
                f->mouse_moved = false;
@@ -24247,8 +24243,8 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                  *finish = X_EVENT_DROP;
 #endif /* USE_GTK */
 
-                 XSETFRAME (inev.frame_or_window, f);
-                 inev.timestamp = xev->time;
+                 XSETFRAME (inev.ie.frame_or_window, f);
+                 inev.ie.timestamp = xev->time;
 
 #ifdef HAVE_X_I18N
                  if (FRAME_XIC (f))
@@ -24360,7 +24356,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                        }
                    }
 
-                 inev.modifiers = x_x_to_emacs_modifiers (dpyinfo, state);
+                 inev.ie.modifiers = x_x_to_emacs_modifiers (dpyinfo, state);
 
 #ifdef XK_F1
                  if (x_dnd_in_progress
@@ -24398,11 +24394,11 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                  if (keysym >= 32 && keysym < 128)
                    /* Avoid explicitly decoding each ASCII character.  */
                    {
-                     inev.kind = ASCII_KEYSTROKE_EVENT;
-                     inev.code = keysym;
+                     inev.ie.kind = ASCII_KEYSTROKE_EVENT;
+                     inev.ie.code = keysym;
 
                      if (source)
-                       inev.device = source->name;
+                       inev.ie.device = source->name;
 
                      goto xi_done_keysym;
                    }
@@ -24411,14 +24407,14 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                  if (keysym >= 0x01000000 && keysym <= 0x0110FFFF)
                    {
                      if (keysym < 0x01000080)
-                       inev.kind = ASCII_KEYSTROKE_EVENT;
+                       inev.ie.kind = ASCII_KEYSTROKE_EVENT;
                      else
-                       inev.kind = MULTIBYTE_CHAR_KEYSTROKE_EVENT;
+                       inev.ie.kind = MULTIBYTE_CHAR_KEYSTROKE_EVENT;
 
                      if (source)
-                       inev.device = source->name;
+                       inev.ie.device = source->name;
 
-                     inev.code = keysym & 0xFFFFFF;
+                     inev.ie.code = keysym & 0xFFFFFF;
                      goto xi_done_keysym;
                    }
 
@@ -24429,13 +24425,13 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                                        Qnil),
                          FIXNATP (c)))
                    {
-                     inev.kind = (SINGLE_BYTE_CHAR_P (XFIXNAT (c))
+                     inev.ie.kind = (SINGLE_BYTE_CHAR_P (XFIXNAT (c))
                                      ? ASCII_KEYSTROKE_EVENT
                                      : MULTIBYTE_CHAR_KEYSTROKE_EVENT);
-                     inev.code = XFIXNAT (c);
+                     inev.ie.code = XFIXNAT (c);
 
                      if (source)
-                       inev.device = source->name;
+                       inev.ie.device = source->name;
 
                      goto xi_done_keysym;
                    }
@@ -24539,11 +24535,11 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                      STORE_KEYSYM_FOR_DEBUG (keysym);
                      /* make_lispy_event will convert this to a symbolic
                         key.  */
-                     inev.kind = NON_ASCII_KEYSTROKE_EVENT;
-                     inev.code = keysym;
+                     inev.ie.kind = NON_ASCII_KEYSTROKE_EVENT;
+                     inev.ie.code = keysym;
 
                      if (source)
-                       inev.device = source->name;
+                       inev.ie.device = source->name;
 
                      goto xi_done_keysym;
                    }
@@ -24555,14 +24551,14 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 
                  if (nbytes)
                    {
-                     inev.kind = MULTIBYTE_CHAR_KEYSTROKE_EVENT;
-                     inev.arg = make_unibyte_string (copy_bufptr, nbytes);
+                     inev.ie.kind = MULTIBYTE_CHAR_KEYSTROKE_EVENT;
+                     inev.ie.arg = make_unibyte_string (copy_bufptr, nbytes);
 
                      Fput_text_property (make_fixnum (0), make_fixnum (nbytes),
-                                         Qcoding, coding, inev.arg);
+                                         Qcoding, coding, inev.ie.arg);
 
                      if (source)
-                       inev.device = source->name;
+                       inev.ie.device = source->name;
                    }
                  goto xi_done_keysym;
                }
@@ -24916,15 +24912,15 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                                                   xev->event_x,
                                                   xev->event_y, f);
 
-                         inev.kind = TOUCHSCREEN_BEGIN_EVENT;
-                         inev.timestamp = xev->time;
-                         XSETFRAME (inev.frame_or_window, f);
-                         XSETINT (inev.x, lrint (xev->event_x));
-                         XSETINT (inev.y, lrint (xev->event_y));
-                         XSETINT (inev.arg, local_detail);
+                         inev.ie.kind = TOUCHSCREEN_BEGIN_EVENT;
+                         inev.ie.timestamp = xev->time;
+                         XSETFRAME (inev.ie.frame_or_window, f);
+                         XSETINT (inev.ie.x, lrint (xev->event_x));
+                         XSETINT (inev.ie.y, lrint (xev->event_y));
+                         XSETINT (inev.ie.arg, local_detail);
 
                          if (source)
-                           inev.device = source->name;
+                           inev.ie.device = source->name;
                        }
 
                      x_uncatch_errors ();
@@ -25030,9 +25026,9 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 
              if (f && device->direct_p)
                {
-                 inev.kind = TOUCHSCREEN_UPDATE_EVENT;
-                 inev.timestamp = xev->time;
-                 XSETFRAME (inev.frame_or_window, f);
+                 inev.ie.kind = TOUCHSCREEN_UPDATE_EVENT;
+                 inev.ie.timestamp = xev->time;
+                 XSETFRAME (inev.ie.frame_or_window, f);
 
                  for (touchpoint = device->touchpoints;
                       touchpoint; touchpoint = touchpoint->next)
@@ -25044,9 +25040,9 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                    }
 
                  if (source)
-                   inev.device = source->name;
+                   inev.ie.device = source->name;
 
-                 inev.arg = arg;
+                 inev.ie.arg = arg;
                }
 
              goto XI_OTHER;
@@ -25081,17 +25077,17 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 
                  if (f && device->direct_p)
                    {
-                     inev.kind = TOUCHSCREEN_END_EVENT;
-                     inev.timestamp = xev->time;
-                     inev.modifiers = state != 2;
+                     inev.ie.kind = TOUCHSCREEN_END_EVENT;
+                     inev.ie.timestamp = xev->time;
+                     inev.ie.modifiers = state != 2;
 
-                     XSETFRAME (inev.frame_or_window, f);
-                     XSETINT (inev.x, lrint (xev->event_x));
-                     XSETINT (inev.y, lrint (xev->event_y));
-                     XSETINT (inev.arg, local_detail);
+                     XSETFRAME (inev.ie.frame_or_window, f);
+                     XSETINT (inev.ie.x, lrint (xev->event_x));
+                     XSETINT (inev.ie.y, lrint (xev->event_y));
+                     XSETINT (inev.ie.arg, local_detail);
 
                      if (source)
-                       inev.device = source->name;
+                       inev.ie.device = source->name;
                    }
                }
 
@@ -25160,20 +25156,20 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                  if (pev->event == FRAME_X_WINDOW (any))
                    xi_compute_root_window_offset_pinch (any, pev);
 
-                 inev.kind = PINCH_EVENT;
-                 inev.modifiers
+                 inev.ie.kind = PINCH_EVENT;
+                 inev.ie.modifiers
                    = x_x_to_emacs_modifiers (dpyinfo, pev->mods.effective);
 
-                 XSETINT (inev.x, lrint (pev->event_x));
-                 XSETINT (inev.y, lrint (pev->event_y));
-                 XSETFRAME (inev.frame_or_window, any);
-                 inev.arg = list4 (make_float (pev->delta_x),
-                                   make_float (pev->delta_y),
-                                   make_float (pev->scale),
-                                   make_float (pev->delta_angle));
+                 XSETINT (inev.ie.x, lrint (pev->event_x));
+                 XSETINT (inev.ie.y, lrint (pev->event_y));
+                 XSETFRAME (inev.ie.frame_or_window, any);
+                 inev.ie.arg = list4 (make_float (pev->delta_x),
+                                      make_float (pev->delta_y),
+                                      make_float (pev->scale),
+                                      make_float (pev->delta_angle));
 
                  if (source)
-                   inev.device = source->name;
+                   inev.ie.device = source->name;
                }
 
              /* Once again GTK seems to crash when confronted by
@@ -25528,26 +25524,26 @@ handle_one_xevent (struct x_display_info *dpyinfo,
               already an undelivered event on the queue.  */
            goto OTHER;
 
-         inev.kind = MONITORS_CHANGED_EVENT;
-         inev.timestamp = timestamp;
-         XSETTERMINAL (inev.arg, dpyinfo->terminal);
+         inev.ie.kind = MONITORS_CHANGED_EVENT;
+         inev.ie.timestamp = timestamp;
+         XSETTERMINAL (inev.ie.arg, dpyinfo->terminal);
 
          /* Also don't do anything if the monitor configuration
             didn't really change.  */
 
          current_monitors
-           = Fx_display_monitor_attributes_list (inev.arg);
+           = Fx_display_monitor_attributes_list (inev.ie.arg);
 
          if (!NILP (Fequal (current_monitors,
                             dpyinfo->last_monitor_attributes_list)))
-           inev.kind = NO_EVENT;
+           inev.ie.kind = NO_EVENT;
 
          dpyinfo->last_monitor_attributes_list = current_monitors;
 
          if (x_dnd_in_progress && x_dnd_update_tooltip)
            x_dnd_monitors = current_monitors;
 
-         if (inev.kind != NO_EVENT)
+         if (inev.ie.kind != NO_EVENT)
            x_dnd_update_tooltip_now ();
        }
 #endif
@@ -25595,9 +25591,9 @@ handle_one_xevent (struct x_display_info *dpyinfo,
     }
 
  done:
-  if (inev.kind != NO_EVENT)
+  if (inev.ie.kind != NO_EVENT)
     {
-      kbd_buffer_store_event_hold (&inev, hold_quit);
+      kbd_buffer_store_buffered_event (&inev, hold_quit);
       count++;
     }