emacs-devel
[Top][All Lists]
Advanced

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

Re: master e37eb7f: Add support for pixel wheel deltas on NS


From: Po Lu
Subject: Re: master e37eb7f: Add support for pixel wheel deltas on NS
Date: Fri, 26 Nov 2021 17:37:22 +0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.60 (gnu/linux)

Eli Zaretskii <eliz@gnu.org> writes:

> How to compute the amount of pixels for a given amount of wheel delta?

I don't know, but I will try to ask some people I know who know
something about this.

> The wheel delta on MS-Windows is reported in abstract units, not
> directly related to any pixels, AFAICT.  I don't see the logic of the
> conversion to pixels documented anywhere in the X or NS code, and the
> comments, such as they are, make no sense at all to someone who knows
> nothing about X mouse-wheel handling.  In xterm.c, it seems like some
> kind of query of the device "valuators" (whatever that is) is being
> used?

On X, the states of the mouse wheels in each axis are stored as absolute
values inside "valuators" attached to each mouse device.  To obtain the
delta of the scroll wheel from a motion event (which is used to report
that some valuator has changed), it is necessary to iterate over every
valuator that changed, and compare its previous value to the current
value of the valuator.

Each individual valuator also has an "interval", which is the amount you
must divide that delta by in order to obtain a delta in the terms of
scroll units.

This delta however is still intermediate, to make driver implementations
easier.  The XInput developers recommend the following algorithm to
convert from scroll unit deltas to pixel deltas:

  pixels_scrolled = pow (window_height, 2.0 / 3.0) * delta;

> And on NS, it seems like the delta is already reported in pixels?

Yes.  The PGTK port can do something similar if it gains support for
this, as GTK also reports it in pixels directly.

> So I'm still in the dark here.  (We really need to document our
> algorithms better, unless we assume only GUI experts will read and
> maintain them.)

Perhaps I should place my explanation of XInput 2 scroll handling in a
comment somewhere.

Thanks.


reply via email to

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