Subject: bug#58980: 29.0.50; Mouse wheel scroll twitches up sometimes when I scroll down

From: Mickey Petersen <[email-masked]>
Date: Thu, 3 Nov 2022 09:46:46 +0000

On 03/11/2022 8:31 am, Eli Zaretskii wrote:
>> Date: Wed, 2 Nov 2022 16:20:40 +0000
>> From: Mickey Petersen <[email-masked]>
>>
>> When I scroll down with my mouse wheel -- typically after an existing
>> window has changed
>> buffers, such as after selecting (via keyboard or mouse) an Info manual
>> node --
>> the scroll action sometimes (but not always) jerks upwards several
>> lines. I can then keep scrolling and it'll start scrolling down
>> again. This may sometimes happen after scrolling for a little while, and
>> sometimes not at all.
>>
>> It's hard to reproduce; but the issue affects a baseline Emacs build (-Q or
>> -q) and only sometimes.
> Please provide some kind of reproduction recipe, even if it doesn't
> happen every time.  When it does happen, type "C-h l", and post the
> commands Emacs recorded that you were invoking immediately before the
> problem.  Otherwise, it's very hard to do anything about the problem,
> unless someone here can reproduce it (I couldn't).
Sure.

I was attempting to reproduce the issue -- by mouse-1 clicking in the 
already-open lossage buffer -- and then I began scrolling _down_ though 
the lossage buffer and it triggered the issue. It instead made me scroll 
up when I was in actual fact scrolling down.
The succession of wheel-up events eventually turned into wheel-down; 
despite the fact that I only scrolled down on my mouse wheel.

Lossage:

  C-h l               ;; view-lossage
  <down-mouse-1>      ;; mouse-drag-region <- I enter the lossage buffer
  <mouse-1>           ;; mouse-set-point
  <down-mouse-1>      ;; mouse-drag-region
  <mouse-1>           ;; mouse-set-point
  <wheel-up>          ;; mwheel-scroll <- I begin scrolling down on my 
physical mouse wheel
  <wheel-up>          ;; mwheel-scroll
  <wheel-up>          ;; mwheel-scroll
  <wheel-up>          ;; mwheel-scroll
  <wheel-up>          ;; mwheel-scroll
  <wheel-down>        ;; mwheel-scroll <- It corrects itself and 
actually starts scrolling down.
  <wheel-down>        ;; mwheel-scroll
  <wheel-down>        ;; mwheel-scroll
  <wheel-down>        ;; mwheel-scroll
  <double-wheel-down> ;; mwheel-scroll
  <triple-wheel-down> ;; mwheel-scroll
  <wheel-down>        ;; mwheel-scroll
  C-h l               ;; view-lossage <- I refresh the lossage.

I _do_, however, have a way that seems to reproduce the issue: when I 
scroll an inactive window and then go back to scrolling the active 
window the bug manifests itself more easily:

1. Ensure there are two windows minimum.
2. Select one.
3. Scroll the other down by hovering over it with your mouse.
4. Now attempt to scroll the active window. Mine will scroll up, and 
trigger "beginning of buffer" user errors if it's already at the top.

Seems there's some stateful behaviour that does or does not get carried 
over when the 'hovered window scroll' changes?

>> I had a look in the bug tracker for `scroll' and found nothing. I also
>> checked `M-x customize-changed' to look for likely culprits. I found
>> nothing that may cause this behaviour, beyond pixel scrolling, which
>> seems like a smoking gun to me,
>> but it's off by default in emacs -Q.
>>
>> 1. Is it possible there are changes the scrolling code that is active even
>> when that mode is not?
>>
>> 2. Could there be some sort of variable that determines scroll direction
>> that, somehow, gets confused?
> Hard to answer these questions, but maybe Po Lu with have clues.