Closed inexorabletash closed 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'...
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.
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:
first_visible_line
is set (range is 0 to max_visible_line
)vthumbpos
is set (range is 0 to kVScrollMax
)thumbpos
(range is 0 to kVScrollMax
)vthumbpos
is NOT CHANGEDthumbmoved
flag is set (!)first_visible_line
= max_visible_line
* thumbpos
/ kVScrollMax
thumbpos
= kVScrollMax
* first_visible_line
/ max_visible_line
UpdateThumb
is called with new thumbpos
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.
... 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.
To Reproduce Steps to reproduce the behavior:
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.