a2stuff / a2d

Disassembly of the Apple II Desktop - ProDOS GUI
https://a2desktop.com
261 stars 20 forks source link

Scroll position adjusts even if thumb not moved #778

Closed inexorabletash closed 6 months ago

inexorabletash commented 6 months ago

To Reproduce Steps to reproduce the behavior:

  1. Start DeskTop
  2. Navigate to Sample.Media
  3. Preview Lorem.Ipsum
  4. Scroll about 3/4 down the file
  5. Click in the vertical scrollbar thumb, and release without moving the thumb

Most of the time the thumb will shift by a few pixels and the content will scroll.

Expected behavior Scroll thumb stays where released, content doesn't scroll.

MGTK's TrackThumb logic appears to not be "stable"; that is, after moving the thumb (which may result in an adjustment as the pixel position is mapped to a scroll fraction, then back), a subsequent non-move of the thumb results in a different position.

To fix will probably require deconstructing the current math and figuring out where the loss is happening.

buserror commented 6 months ago

Could it be related to the code that seems to reduce the resolution of the mouse? For example, in a window, if you click+drag a selection, the selection doesn't follow the mouse exactly, it's quantified and moves in 'steps'...

inexorabletash commented 6 months ago

I don't think so. You can visually see the thumb rect being unchanged from the previous position, and it's the thumb rect that's the input to the calculation.

inexorabletash commented 6 months ago

After staring at the code for a while, the description is incomplete, and it may not be localized to MGTK. Here's the whole process for Show.Text.File:

In an example (with Lorem.Ipsum sample), I can see TrackThumb returning $B8 and then UpdateThumb called with $B3, so it's the client (Show Text File) at least partly to blame - those numbers should match! But when the thumb is next clicked w/o no movement, TrackThumb returns $B2, where I'd expect $B3 again.

inexorabletash commented 6 months ago

... and unsurprisingly, the thumbpos changing is due to integer math, e.g.

This can be avoided by just using the thumbpos returned from TrackThumb, with no changes to MGTK. However, this is still not ideal, because (1) it requires all clients to make similar logic changes and (2) the thumbpos change still happens due to MGTK's calculations and (3) if the flag is set it can still trigger an unnecessary redraw.

So a fix to the logic in MGTK's TrackThumbImpl is still desirable.