unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Po Lu <luangruo@yahoo.com>
Cc: monnier@iro.umontreal.ca, emacs-devel@gnu.org
Subject: Re: master 3b41141708: Expose the name of an event's input device to Lisp
Date: Sat, 09 Apr 2022 14:03:50 +0300	[thread overview]
Message-ID: <83o81a8qnd.fsf@gnu.org> (raw)
In-Reply-To: <871qy6o9p3.fsf@yahoo.com> (message from Po Lu on Sat, 09 Apr 2022 18:03:20 +0800)

> From: Po Lu <luangruo@yahoo.com>
> Cc: monnier@iro.umontreal.ca,  emacs-devel@gnu.org
> Date: Sat, 09 Apr 2022 18:03:20 +0800
> 
> 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.

No, only for events that are specific to the device and not available
in other devices.

> 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.

So, with your current design and implementation, what level will deal
with the device type and decide how to handle each event with the
device type in mind?  Events are bound to commands in Emacs, so does
this mean each command will need to know about the device to DTRT?

> >> 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.

And what would happen instead under your design and implementation?
won't we need to add code to recognize the new device?

> The device names are guaranteed to reliably identify a device on
> GNU/Linux and other systems that run X Windows or Wayland.

I don't see how can you so sure about this.  A name is just a string.
With devices development these days, chances are what is a unique name
today will cease to be that tomorrow.

In general, I have hard time imagining that modern systems let you
access the precise and detailed device information, because (AFAIK)
modern systems typically hide this information from applications.

> > 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.

How will this different behavior implemented, under your current
proposals?  Which code will deal with the device information, and how
will that eventually affect behavior?  Please show code examples if
possible.

> >> 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?

By appropriate numbering of their buttons, for example?

> > 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.

Instead of doing this on the level of input methods, why not do this
where we produce keyboard key events, by converting the keys to what
they are supposed to mean from the user's POV?  Then none of the
higher-level code will need to change, and moreover, users will be
able to use these different keyboards with input methods unrelated to
the keyboard type handling, whereas if this is done in an input
method, one cannot have another input method active at the same time
to use the characters that come from the "translation" input method.

> > 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.

No, we just need a mapping from this event to an Emacs command that
will do whatever is needed for the event.  And users can customize
that command if they need.



  reply	other threads:[~2022-04-09 11:03 UTC|newest]

Thread overview: 86+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <164933858147.29834.15050766441005536059@vcs2.savannah.gnu.org>
     [not found] ` <20220407133623.9C209C009A8@vcs2.savannah.gnu.org>
2022-04-07 14:05   ` master 3b41141708: Expose the name of an event's input device to Lisp Stefan Monnier
2022-04-07 23:31     ` Po Lu
2022-04-07 23:41       ` Stefan Monnier
2022-04-08  0:07         ` Po Lu
2022-04-08  6:02         ` Eli Zaretskii
2022-04-08  6:08           ` Po Lu
2022-04-08  6:26             ` Eli Zaretskii
2022-04-08  7:36               ` Po Lu
2022-04-08 11:12                 ` Eli Zaretskii
2022-04-08 11:31                   ` Po Lu
2022-04-08 12:12                     ` Eli Zaretskii
2022-04-08 12:35                       ` Po Lu
2022-04-09  6:48                         ` Eli Zaretskii
2022-04-09  9:06                           ` Po Lu
2022-04-09  9:09                             ` Lars Ingebrigtsen
2022-04-09  9:30                             ` Eli Zaretskii
2022-04-09 10:03                               ` Po Lu
2022-04-09 11:03                                 ` Eli Zaretskii [this message]
2022-04-09 11:44                                   ` Po Lu
2022-04-09 14:04                                     ` Eli Zaretskii
2022-04-09 16:33                                       ` Stefan Monnier
2022-04-09 16:41                                         ` Lars Ingebrigtsen
2022-04-09 17:06                                           ` Eli Zaretskii
2022-04-09 17:16                                             ` Eli Zaretskii
2022-04-09 17:52                                             ` Brian Cully
2022-04-09 19:18                                               ` Eli Zaretskii
2022-04-10  0:54                                               ` Po Lu
2022-04-10  1:46                                                 ` Brian Cully
2022-04-10  2:11                                                   ` Po Lu
2022-04-10  2:45                                                     ` Brian Cully
2022-04-10  3:30                                                       ` Po Lu
2022-04-10  0:37                                           ` Po Lu
2022-04-10  5:49                                             ` Eli Zaretskii
2022-04-10  6:09                                               ` Po Lu
2022-04-10  6:44                                                 ` Eli Zaretskii
2022-04-10  7:31                                                   ` Po Lu
2022-04-10  8:28                                                     ` Eli Zaretskii
2022-04-10  8:50                                                       ` Po Lu
2022-04-10  9:17                                                         ` Eli Zaretskii
2022-04-10  9:25                                                           ` Po Lu
2022-04-10 11:15                                                             ` Po Lu
2022-04-10 15:16                                                               ` Stefan Monnier
2022-04-11  1:02                                                                 ` Po Lu
2022-04-10 11:46                                                   ` Lars Ingebrigtsen
2022-04-10 11:41                                             ` Lars Ingebrigtsen
2022-04-10  0:48                                       ` Po Lu
2022-04-10  6:04                                         ` Eli Zaretskii
2022-04-10  6:17                                           ` Po Lu
2022-04-10  6:49                                             ` Eli Zaretskii
2022-04-10  7:01                                               ` Po Lu
2022-04-10  8:24                                                 ` Eli Zaretskii
2022-04-10  8:42                                                   ` Po Lu
2022-04-10  9:13                                                     ` Eli Zaretskii
2022-04-10 12:51                                                       ` Brian Cully
2022-04-10 13:21                                                         ` Po Lu
2022-04-10 18:08                                                           ` Brian Cully
2022-04-11  0:58                                                             ` Po Lu
2022-04-11  1:08                                                               ` Brian Cully
2022-04-11  2:00                                                                 ` Po Lu
2022-04-11  2:03                                                                   ` Po Lu
2022-04-11  2:21                                                                   ` Brian Cully
2022-04-11  3:12                                                                     ` Po Lu
2022-04-11  4:11                                                                       ` Brian Cully
2022-04-11  5:20                                                                         ` Po Lu
2022-04-11 11:33                                                                           ` Brian Cully
2022-04-11 14:09                                                                             ` Po Lu
2022-04-11 16:26                                                                               ` Brian Cully
2022-04-11 10:10                                                             ` Lars Ingebrigtsen
2022-04-10 12:44                                                     ` Brian Cully
2022-04-10 13:14                                                       ` Po Lu
2022-04-08 14:27         ` Stefan Monnier
2022-04-09  0:24           ` Po Lu
2022-04-09  2:52             ` Stefan Monnier
2022-04-09  3:17               ` Po Lu
2022-04-09 13:31                 ` Stefan Monnier
2022-04-09 13:37                   ` Po Lu
2022-04-09 14:20                     ` Stefan Monnier
2022-04-10  0:58                       ` Po Lu
2022-04-09 14:31                     ` Eli Zaretskii
2022-04-10  0:56                       ` Po Lu
2022-04-10  6:11                         ` Eli Zaretskii
2022-04-10  6:23                           ` Po Lu
2022-04-10  6:52                             ` Eli Zaretskii
2022-04-10  7:37                               ` Po Lu
2022-04-10  8:12                                 ` Eli Zaretskii
2022-04-09  6:22             ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83o81a8qnd.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=luangruo@yahoo.com \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).