Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scrollfix #4554

Closed
wants to merge 3 commits into from
Closed

Scrollfix #4554

wants to merge 3 commits into from

Conversation

jamestut
Copy link
Contributor

Summary of the Pull Request

Fixed inconsistent scrolling when using both touchscreen and precision touchpad.

References

#1066 and #4542

PR Checklist

  • Closes #xxx
  • CLA signed. If not, go over here and sign the CLA
  • Tests added/passed
  • Requires documentation to be updated
  • I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: Inconsistent touch screen scrolling #4542

Detailed Description of the Pull Request / Additional comments

Scrolling jumpiness is caused by rounding errors. Instead of retrieving the current scrolling value from GetScrollOffset, which is already rounded in int, let the scrolling operation to operate on _scrollBar's Value directly (which uses double) in TermControl.cpp.

Validation Steps Performed

Testing scrolling on the following scenario manually:

  • nonscrollable terminal (e.g. the window is large enough to contain the current buffer).
  • scrolling to the topmost and bottom-most.
  • scrolling TUI apps such as nano and more in WSL.
  • after clearing the terminal, both in cmd and WSL.

has the same behavior between using touchscreen or precision trackpad and regular mouse wheel.

Directly apply fractional delta values to scrollbar instead of rounding them first before applying.
Directly apply fractional delta values to scrollbar instead of rounding them first before applying.
Copy link
Contributor

@leonMSFT leonMSFT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, this really does make the scrolling experience way more consistent and enjoyable, thanks!

@leonMSFT leonMSFT added the Needs-Second It's a PR that needs another sign-off label Feb 14, 2020
Copy link
Member

@carlos-zamora carlos-zamora left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@miniksa or @DHowett-MSFT I think we don't have Chromium Math in this repo. Is it ok to #include that at the top of this or was there a particular reason we didn't do that.

@jamestut Just in case you're not familiar with it, for reference on how to use this Chromium Math, here's the doc or just search our repo for base::Clamp and you should find a decent amount of examples.

Works great! 😊

src/cascadia/TerminalControl/TermControl.cpp Show resolved Hide resolved
const auto currentOffset = this->GetScrollOffset();
const double newValue = (numRows) + (currentOffset);
const auto currentOffset = _scrollBar.Value();
const double newValue = numRows + currentOffset;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use safemath here to force a clamped double.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used the chromium's safemath here for the clamped addition on the 3rd commit of this fork.

@ghost ghost added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Feb 14, 2020
@WSLUser
Copy link
Contributor

WSLUser commented Feb 18, 2020

#4179 is awaiting someone to pick up before we use chromium math in the repo.

@ghost ghost removed the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Feb 18, 2020
@DHowett-MSFT
Copy link
Contributor

Argh: I'm really sorry about the conflict. You will need to save and commit TermControl as CRLF, then merge in master. I was not aware that we had messed up the line endings so badly. :/

@DHowett-MSFT
Copy link
Contributor

FWIW: i did push a fixed version here; 9dc594b

Copy link
Contributor

@DHowett-MSFT DHowett-MSFT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is so so so much better.

@DHowett-MSFT
Copy link
Contributor

I pushed this commit to master after doing a build test myself. Consider this merged, and congrats on your first contribution!

DHowett added a commit that referenced this pull request Jul 13, 2020
This parameter was added as a workaround for our fast trackpad
scrolling. Since that was fixed before 1.0 shipped, in #4554, it has
been largely vestigial. There is no reason for us to keep it around any
longer.

It was also the only "logic" in TerminalSettings, which is otherwise a
library that only transits data between two other libraries.

I have not removed it from the schema, as I do not want to mark folks'
settings files invalid to a strict schema parser.

While I was in the area, I added support for "scroll one screen at a
time" (which is represented by the API returning -1), fixing #5610.

Fixes #5610
DHowett added a commit that referenced this pull request Jul 13, 2020
This parameter was added as a workaround for our fast trackpad
scrolling. Since that was fixed before 1.0 shipped, in #4554, it has
been largely vestigial. There is no reason for us to keep it around any
longer.

It was also the only "logic" in TerminalSettings, which is otherwise a
library that only transits data between two other libraries.

I have not removed it from the schema, as I do not want to mark folks'
settings files invalid to a strict schema parser.

While I was in the area, I added support for "scroll one screen at a
time" (which is represented by the API returning WHEEL_PAGESCROLL),
fixing #5610. We were also storing it in an int (whoops) instead of a
uint.

Fixes #5610
ghost pushed a commit that referenced this pull request Jul 14, 2020
#6891)

This parameter was added as a workaround for our fast trackpad
scrolling. Since that was fixed before 1.0 shipped, in #4554, it has
been largely vestigial. There is no reason for us to keep it around any
longer.

It was also the only "logic" in TerminalSettings, which is otherwise a
library that only transits data between two other libraries.

I have not removed it from the schema, as I do not want to mark folks'
settings files invalid to a strict schema parser.

While I was in the area, I added support for "scroll one screen at a
time" (which is represented by the API returning WHEEL_PAGESCROLL),
fixing #5610. We were also storing it in an int (whoops) instead of a
uint.

Fixes #5610
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs-Second It's a PR that needs another sign-off
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants