Implementing smooth scrolling in an X client
Peter Hutterer
peter.hutterer at who-t.net
Mon Jun 11 18:25:08 PDT 2012
On Mon, Jun 04, 2012 at 06:50:47PM -0400, Paul Vojta wrote:
> Folks:
>
> I've started working on implementing smooth scrolling in xdvi, and I have a
> question about it.
>
> When I do
>
> xinput --test 9
>
> (where 9 is the deviceid of my Synaptics touchpad) and stroke my finger
> down the right-hand side of the touchpad, I get an increasing sequence of
> numbers:
>
> motion a[3]=1935
> motion a[3]=1950
> motion a[3]=1964
> motion a[3]=1979
> motion a[3]=2007
> motion a[3]=2017
> motion a[3]=2034
> motion a[3]=2062
> motion a[3]=2088
> motion a[3]=2124
> motion a[3]=2154
> motion a[3]=2185
> motion a[3]=2210
>
> etc. So far I've modified xdvi so that I can get a similar printout from
> xdvi.
>
> I guess that what I'm supposed to do with these numbers is keep track of
> the most recently reported number, and scroll based on the differences
> between the numbers.
correct
> But now if I move my mouse to some other window (e.g., xterm), scroll in
> that window for a while, and then move back, the numbers reported to
> xdvi would reflect the scrolling activity done in the other window.
correct
> So I would need to keep track of EnterNotify events for each window for
> which I'm doing smooth scrolling, and set a flag each time such an event
> is received.
yes, this is a bug in the protocol and that behaviour is what GTK has to do
as well.
http://who-t.blogspot.com.au/2012/06/xi-21-protocol-design-issues.html
> A problem with this (other than the extra programming effort required)
> is that on four-button Synaptics touchpads, the first button press of
> the third or fourth button after returning to the xdvi window would
> (I think) have no effect anymore. (More generally, the first scrolling
> distance would be ignored for every return to the window, but would not
> be noticeable unless it was produced by a button press or simulated button
> press.)
>
> Is this correct?
are you talking about the touchpads that have separate scroll buttons? I'd
not worry too much about those, I think even the newest ones are several
years old now (to the point that the next version of synaptics won't support
the scroll buttons anymore).
> And, more to the point, is there some way by which I could just receive the
> deltas of the scrolling valuators for when the pointer is in the designated
> window?
you can't really get the deltas only, you'll always have to calculate them
from the previous value. your only option for not skipping the first event
is to run XIQueryDevice after an EnterEvent to get the current value on the
valuator so you can use that first event with that delta. Of course, that is
prone to race conditions so you have to work around them too.
sorry :(
Cheers,
Peter
> I am using Debian on x86_64, with the following package versions:
>
> xserver-xorg-core 2:1.12.1.902-1
> xserver-xorg-input-synaptics 1.6.1-1
> xinput 1.6.0-1
More information about the xorg
mailing list