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: Fri, 08 Apr 2022 15:36:05 +0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.91 (gnu/linux)

Eli Zaretskii <eliz@gnu.org> writes:

> I wouldn't have asked if the commit message explained this enough for
> me to understand.  I see no rationale in the commit message.

Sorry, I will try to be more clear on that next time.

> What for?  Why do we care in Emacs which device generated a scroll
> event?  Emacs was always transparent regarding that, and did the same
> regardless of the particular device which caused the event.  Why do we
> suddenly need to distinguish between them?  This could add complexity
> to Emacs's application level that we don't particularly want.  So if
> we do add this, it had better be a very good reason.

Basically, precision scrolling comes in two forms: the first immediately
scrolls the screen by the deltas given, while the second "animates" a
scroll from the original position to the position with the deltas.

All the major programs and toolkits today seem to be converging on using
the first strategy for touchpad devices and tablets, and the second for
mice.

The ability to distinguish between different input devices is important
to be able to implement that behavior according to what users expect.

> Most input events nowadays come from the window-system, which
> typically hides the device level from the application.  For example,
> there are programs that allow you to inject mouse events by typing on
> the keyboard, and vice versa.  There are also programs that inject
> keyboard events programmatically.  Etc. etc.  Why would we want to
> know or care exactly what device generated an event?

That's not hidden under X Windows and GTK, where we see that many other
applications are relying on that information as well.  For example,
Firefox-based browsers and WebKit both use it to determine which form of
"precise scrolling" strategy to use.

NS doesn't expose the device name, but it does expose the kind of device
which generated the event.  On macOS, GTK uses that information to
compute an artificial device name, which works well enough.

> The question is why it is useful for Emacs to know which keyboard
> device generated a key sequence.

I can imagine an input method behaving differently depending on which
keyboard is being used, since individual keyboards can have different
layouts convenient for typing in separate languages.

> In any case, if we do agree to have this information in Emacs, the
> definition of a "device" should be abstract enough to allow its
> implementation on systems other than X.

It has already been implemented on Wayland, and the implementation on NS
is waiting for a machine on which it can be tested.  (I don't have
access to a real Mac, and GNUstep doesn't even try to implement what I
talked about correctly, to it everything is a mouse.)

> And then I will ask a question similar to that Stefan asked: why not
> make the device part of event object we have on the event queue?

It's already part of the `struct input_event', but compatibility
requirements prevent it from being made part of the Lisp events itself,
so we store it as one of the last-event-* variables instead.


reply via email to

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