xi-editor / xi-mac

The xi-editor mac frontend.
Apache License 2.0
3.02k stars 147 forks source link

Fix janky scrolling on external mice #469

Closed nangtrongvuon closed 5 years ago

nangtrongvuon commented 5 years ago

Summary

This fixes an issue where the scroll(to: NSPoint) usage in xi-mac's case only supports smooth scrolling and thus doesn't properly take into account notched mouse wheel scroll (which usually means external mice).

Smooth scrolling (like the MacBook trackpad or Apple Magic Mouse) sends scrollEvents that are chunked, continuous and cumulative, and thus the scroll view's clipView's bounds is set properly for each of these small chunks of scrolling.

Scrolling with notched mice scrolls in discrete units, takes into account acceleration but does not redraw the view when the view is continuously redrawn during scrolling - this is because the bounds origin is only set after the scrolling has stopped completely, causing the janky scroll that is described in #411. This is likely a bug/oversight on Apple's part.

This PR simply sets the clipView's bound origin properly on all scrolling.

closes #411.

Review Checklist

cmyr commented 5 years ago

Very cool, will review this later today!

cmyr commented 5 years ago

So CI is failing because of an issue with a search test? I'm not sure what's up with that, but it might be due to some change in xi-editor. Maybe change this PR to only include the scroll change, and not update the submodule, and then we can look at the other problem separately?

cmyr commented 5 years ago

In any case if you do that change feel free to merge on green!