Subject: Re: bug#66765: 30.0.50; Building emacs with xinput2 breaks receiving XSendEvent events

From: Po Lu <[email-masked]>
Date: Fri, 27 Oct 2023 08:32:44 +0800

tags 66765 + notabug wontfix
thanks

Ami Fischman <[email-masked]> writes:

> 1. Run: `emacs -Q` on an X11 display for a binary that's been built
> with (the default) `--with-xinput2`
> 2. From another program, trigger an XSendEvent targeting the above
> emacs' window sending a key event.
> Expected:
> 3. The sent key event is seen by emacs.
> Actual:
> 4. Emacs doesn't seem to receive the sent key event.
>
> Simplest way to execute step 2 above is:
> $ git clone http://github.com/epitron/xse.git
> $ cd xse && ./configure  && xmkmf && make depend && make
> $ xwininfo
> (click the emacs window and note its reported "Window id" for the next command)
> $ ./xse -win <EMACS_WINDOW_ID> -Debug '<Key>l'
>
> When emacs is built with `--without-xinput2` the issue is gone, and
> sent events are received properly.
> Issue is not present in 27.1 or 28.1, but is present in 29.1 and HEAD.
> Confirmed with a git bisect that the issue showed up when xinput2 was
> enabled by default in
> https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=0105a4ddb8a58146f3fc71c265e57291c873af0b
>
> I stumbled across this issue when upgrading from 27.1 to 29.1 and
> noticing that ratpoison can no longer send its escape key (in my case,
> this is C-a) to emacs, even though it has no problems sending the same
> key to every other app on my system.

When the X input extension is in use, both Emacs and the X server ignore
core events.  It's also impossible to send extension events, so this
extension renders external event delivery effectively impossible.

This isn't a bug we can fix, sorry; but the XTEST extension is capable
of simulating real key presses, so I suggest whatever tools send Emacs
events be rewritten to make use of that extension.

The same issue can be observed in programs written to use version 3 or 4
of the GTK toolkit.