Subject: Re: bug#74423: Low level key events

From: Po Lu <[email-masked]>
Date: Sat, 14 Dec 2024 09:16:45 +0800

Cecilio Pardo <[email-masked]> writes:

> +#ifndef HAVE_XINPUT2
> +static void
> +xg_maybe_send_low_level_key_event (struct frame *f,
> +				   GdkEvent *xev)
> +{
> +  GdkEventKey xkey = xev->key;
> +  bool is_press;
> +  Lisp_Object key, modifier;
> +  union buffered_input_event inev;
> +
> +  if (NILP (Venable_low_level_key_events))
> +    return;
> +
> +  switch (xev->type)
> +    {
> +    case GDK_KEY_PRESS:
> +      is_press = true;
> +      break;
> +    case GDK_KEY_RELEASE:
> +      is_press = false;
> +      break;
> +    default:
> +      return;
> +    }
> +
> +  modifier = x_get_modifier_for_keycode (FRAME_OUTPUT_DATA (f)->display_info,
> +					 xev->key.hardware_keycode);
> +
> +  int keysym = xkey.keyval;
> +
> +  if (keysym >= GDK_KEY_a && keysym <= GDK_KEY_z)
> +    keysym -= GDK_KEY_a - GDK_KEY_A;
> +
> +  if (!kbd_low_level_key_is_enabled (keysym, modifier))
> +    return;
> +
> +  key = make_fixnum (keysym);
> +
> +  EVENT_INIT (inev.ie);
> +  XSETFRAME (inev.ie.frame_or_window, f);
> +  inev.ie.kind = LOW_LEVEL_KEY_EVENT;
> +  inev.ie.timestamp = xkey.time;
> +  inev.ie.arg = list3 (is_press ? Qt : Qnil, key, modifier);
> +  kbd_buffer_store_buffered_event (&inev, &xg_pending_quit_event);
> +}
> +#endif

Why is this !HAVE_XINPUT2?  GTK input method support exists
independently of XInput 2.