emacs-devel
[Top][All Lists]
Advanced

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

Re: master 3b41141708: Expose the name of an event's input device to Lis


From: Po Lu
Subject: Re: master 3b41141708: Expose the name of an event's input device to Lisp
Date: Sat, 09 Apr 2022 18:03:20 +0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.91 (gnu/linux)

Eli Zaretskii <eliz@gnu.org> writes:

>> Well as another example, artist-mode might want to behave differently
>> with an "eraser" pointer, removing pixels from the picture instead of
>> adding them.
>
> Why cannot this be handled by producing special events that erase
> pixels?

Because this puts us on the very inflexible path of adding special
events for every single input device that users might want.  Besides,
the erasers send ordinary button and motion events, specifically so that
programs can better consume input they generate without needing to
handle a special new kind of event.

> I still don't understand why special-purpose events cannot solve the
> same problems.  Maybe even specialized mode with the same events.

>> That won't be very flexible, and it'll be very difficult for the user to
>> write customizations for some new kind of device (or just a different
>> device) without adding an entirely new kind of input event for it.  
>
> Please explain these two counter-arguments in more detail.  Why "not
> very flexible" and why it will make customizations more difficult?

Let's say the developers come up with a special input device for
entering notes.  Such a device would have a special name, and send
either key or button presses.

Without exposing slightly low level information about the device itself
to Lisp code, users of such a device would be forced to ask us to add an
event specifically for that device, in order to use it in Emacs
simultaneously with other keyboards or mice.

We would have to add events for every device users want to use with
Emacs (and there are many, ranging from electronic keyboards to foot
pedals), or we could simply expose the information necessary for their
own customizations to identify the device.

The device names are guaranteed to reliably identify a device on
GNU/Linux and other systems that run X Windows or Wayland.  If the
feature does not completely work on other systems, too bad, but I think
it can be made to work on NS with sufficient coaxing, and probably on MS
Windows too, via the "wintab" and "winpointer" APIs that GTK and Firefox
seem to be using.

> And why is that a problem?  We already interpret mouse-4 and mouse-5
> as the wheel, so why not have mouse-8 be interpreted in some special
> way?

Because mouse-8 is already the horizontal scroll wheel on normal mice.
The point is, the graphics tablet buttons send the exact same events
that ordinary mice do, but users might want them to behave differently.

So there has to be a way to identify each device connected to the
computer.  And with some use cases, we simply want different devices of
the same type (ordinary computer mice) to behave differently.

>> And what if the user has two ordinary mice connected, and wants one to
>> behave differently from the other, in effect giving him an extra set of
>> mouse buttons?
>
> What about it?  Why does this require to know about the device, and
> cannot be expressed as special events?

How would you decide from which mice ordinary button events should come,
and what others without knowing their names?  Or some other unique
identifier, A.K.A a name?

> Please tell more: how do they behave differently?  If you press a key
> that is labeled with some character, doesn't Emacs receive a keyboard
> input event with that character?

Let's say I want to insert "завод" from the Russian keyboard.  If I
don't manually switch the active keyboard layout on the X server-side
when I start typing, the characters the X server sends to Emacs are in
the US International keymap, so that becomes "pfdjl".  Similarly, if I
want to type "factory" in English, I have to switch the active keyboard
layout to US International, or otherwise what is sent to Emacs is
"афсещкн".

While with the feature to retrieve device information as it is currently
implemented, I could eventually configure the input method to be
`russian-computer' when the device which sent the keyboard input is
named "Innovation HID usb keyboard" instead of "AT Translated Set 2
keyboard", the built-in US International keyboard on my laptop.

> We could have a keyboard-layout switch event, which would change input
> methods automatically.  (On MS-Windows, we already have such an
> event.)  Once again, low-level code does know about these details, and
> that is not a problem IMO; it is exposing that to Lisp as "device"
> that I don't like.

That would still have to expose some way to uniquely identify each
keyboard to the user.  At the very least, we would need an alist of
keyboard device names to the correct keyboard layout.

Thanks in advance.


reply via email to

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