Fix scrolling in scroll containers #14702
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Should fix #14517; since this is a highly platform and compiler-specific issue, I am hesitant to claim that it always works, so make sure to test this thoroughly.
It seems
ButtonStates
was not initialized for scroll events, but accessed throughisLeftPressed
. With optimizations enabled this probably yielded nonzero values, which resulted in a mess: The scroll container sometimes falsely believed that the button was held down.How to test
Compile a release build with GCC on Linux. Verify that scrolling is choppy. Verify that with this PR applied, it isn't anymore. The following diff might help for testing:
Without the fix, not all SDL events "come through", even though you're not pressing any mouse buttons: You see "SDL says we scrollin" without "scrollin". After the fix, each "SDL says we scrollin" triggered inside the scroll container, without the mouse button being pressed, should be followed by a "scrollin".