-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
First three interactivity fixes #9980
Conversation
Misspellings found, please review:
To accept these changes, run the following commands from this repository on this branch
✏️ Contributor please read thisBy default the command suggestion will generate a file named based on your commit. That's generally ok as long as you add the file to your commit. Someone can reorganize it later.
If the listed items are:
See the 🔬 You can test your commits without appending to a PR by creating a new branch with that extra change and pushing it to your fork. The check-spelling action will run in response to your push -- it doesn't require an open pull request. By using such a branch, you can limit the number of typos your peers see you make. 😉 🗜️ If you see a bunch of garbage and it relates to a binary-ish string, please add a file path to the File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.
|
const auto rowDelta = mouseDelta / (-1.0 * WHEEL_DELTA); | ||
const double rowDelta = mouseDelta / (-1.0 * 120.0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems very important to continue using the correct constant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea I just got spooked by int math vs float math. I'll revert this bit
// If the new scrollbar position, rounded to an int, is at a different | ||
// row, then actually update the scroll position in the core, and raise | ||
// a ScrollPositionChanged to inform the control. | ||
int viewTop = ::base::saturated_cast<int>(::std::round(_internalScrollbarPosition)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. Does rounding match the pre-split behavior?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might actually be better, a little smoother in both directions now. Hard to say for sure comparing Debug vs Release
void ControlInteractivity::_coreScrollPositionChanged(const IInspectable& /*sender*/, | ||
const Control::ScrollPositionChangedArgs& args) | ||
{ | ||
_internalScrollbarPosition = args.ViewTop(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just making sure: this fires every single time a line is printed to the terminal for the first 9001 lines. Is adding another event recipient worth it? Is there a way you can do this without having a double version of the viewport top every time it changes? :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You know, I was being cautious here. I'm not positive this is needed. The event might get caught by the TermControl, throttled, then have TermControl call UpdateScrollbar, which might fix it for us.
@@ -1302,8 +1302,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation | |||
return; | |||
} | |||
|
|||
const auto newValue = static_cast<int>(args.NewValue()); | |||
_core->UserScrollViewport(newValue); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hey, good!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like there's a good amount of auto
you can keep to leverage the base::ClampedNumeric
stuff. But I guess that's a bit scary.
// auto scrollChangedHandler = [&](auto&&, const Control::ScrollPositionChangedArgs& args) mutable { | ||
// // This mock emulates how the TermControl updates the | ||
// // interactivity's internal scrollbar when the core changes its | ||
// // viewport. | ||
// // | ||
// // In reality, the TermControl throttles scrollbar updates, and only | ||
// // calls back to UpdateScrollbar once every 60 seconds. | ||
// const auto newValue = args.ViewTop(); | ||
// if (newValue != core->ScrollOffset()) | ||
// { | ||
// interactivity->UpdateScrollbar(newValue); | ||
// } | ||
// }; | ||
// core->ScrollPositionChanged(scrollChangedHandler); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dead code
const double currentOffset = ::base::ClampedNumeric<double>(_core->ScrollOffset()); | ||
const double newValue = numRows + currentOffset; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought you'd want to keep auto currentOffset
. That way you get a safe chromium math add for newValue
.
@@ -428,35 +430,50 @@ namespace winrt::Microsoft::Terminal::Control::implementation | |||
// - Scroll the visible viewport in response to a mouse wheel event. | |||
// Arguments: | |||
// - mouseDelta: the mouse wheel delta that triggered this event. | |||
// - point: the location of the mouse during this event | |||
// - pixelPosition: the location of the mouse during this event |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// - pixelPosition: the location of the mouse during this event | |
// - pixelPosition: the pixel location of the mouse during this event |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eh. i hate when the name is obvious and we are forced to document the obvious name
const int currentInternalRow = ::base::saturated_cast<int>(::std::round(_internalScrollbarPosition)); | ||
const int currentCoreRow = _core->ScrollOffset(); | ||
const double currentOffset = currentInternalRow == currentCoreRow ? | ||
_internalScrollbarPosition : | ||
currentCoreRow; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't you want auto
or base::ClampedNumeric
s here? Isn't there a chance that currentCoreRow
won't fit in a double?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nope
// If the new scrollbar position, rounded to an int, is at a different | ||
// row, then actually update the scroll position in the core, and raise | ||
// a ScrollPositionChanged to inform the control. | ||
int viewTop = ::base::saturated_cast<int>(::std::round(_internalScrollbarPosition)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int viewTop = ::base::saturated_cast<int>(::std::round(_internalScrollbarPosition)); | |
const auto viewTop = ::base::saturated_cast<int>(::std::round(_internalScrollbarPosition)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
Hello @DHowett! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
🎉 Handy links: |
Summary of the Pull Request
This PR encompasses the first three bugs we found post-#9820.
A: Mousedown, select, SCROLL does a weird thing with endpoints that doesn't happen in stable
We were using the terminal position to set the selection anchor, when we should have used the pixel position.
This is fixed in 4f4df01.
B: Trackpad scrolling down with small increments seems buggy
This one's the most complicated. The touchpad sends very many small scroll deltas, less than one row at a time. The control scrollbar can store a
double
, so small deltas can accumulate. Originally, these would accumulate in the scrollbar, and we'd only read that out as anint
in the scrollbar updater, which is throttled.In the interactivity split, there's no place for us to store that double. We immediately narrow to an
int
forControlInteractivity::_updateScrollbar
.So this introduces a double inside
ControlInteractivity
as a fake scrollbar, with which to accumulate to.This is fixed in 33d29fa...0fefc5b
C: Looks like there's a selection issue when you click and drag too quickly.
The diff for this one is:
_terminal->SetSelectionAnchor(_GetTerminalPosition(touchdownPoint));
vs
_core->SetSelectionAnchor(terminalPosition);
We're now using the location of the drag event as the selection anchor, instead of the location that the user initially clicked. Oops.
PR Checklist
Detailed Description of the Pull Request / Additional comments
All three have tests, 🙌🙌🙌🙌
Validation Steps Performed
Manual, and automated via tests