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

From: Eli Zaretskii <[email-masked]>
Date: Tue, 19 Nov 2024 17:29:00 +0200

> Date: Mon, 18 Nov 2024 21:35:40 +0100
> From: Cecilio Pardo <[email-masked]>
> 
> Here is a still incomplete patch for this, renamed from "physical 
> keyboard events", following up to
> https://lists.gnu.org/archive/html/emacs-devel/2024-11/msg00085.html
> 
> It provides events for press/release of keys, independently of the 
> normal keyboard events. These events are bound int the 
> special-event-map. Some lisp is included to implement detection of 
> multiple tapping on keys, and running commands or simulating modifiers.

Thanks, I have some minor comments, and also added Stefan to the
discussion, in case he will also have comments.

> +  if (!Venable_low_level_key_events)

You treat this variable as a C boolean, i.e. assume it was defined
with DEFVAR_BOOL, but in that case our convention is to call the C
variables without the leading 'V'.  OTOH, if you envision that this
variable could be something other than nil or t in Lisp, then you need
to use NILP here.

> +  DEFVAR_LISP ("enable-low-level-key-events", Venable_low_level_key_events,
> +	       doc: /* Enabled the recepcion of low level key events.
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
"If non-nil, reception of low-level key events is enabled."

> +static void
> +pgtk_maybe_send_low_level_key_event (GdkEvent *event)
> +{
> +  if (!Venable_low_level_key_events)
> +    return;

Same problem with the test here.

> --- a/src/w32fns.c
> +++ b/src/w32fns.c
> @@ -4669,6 +4669,11 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
>      case WM_KEYUP:
>      case WM_SYSKEYUP:
>        record_keyup (wParam, lParam);
> +      if (Venable_low_level_key_events)
> +	{
> +	  signal_user_input ();
> +	  my_post_msg( &wmsg, hwnd, WM_EMACS_LOW_LEVEL_KEY, wParam, lParam );
> +	}

And here (and in several other places in the patch).