xproto-fix-underflow-in-Fp1616ToDouble.patch 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. From 5ade494a9966c7a9675af86dc42aca62fb4d806d Mon Sep 17 00:00:00 2001
  2. From: Tom Anderson <thomasanderson@chromium.org>
  3. Date: Wed, 21 Oct 2020 22:02:35 +0000
  4. Subject: [PATCH] [XProto] Fix underflow in Fp1616ToDouble
  5. x11::Input::Fp1616 should be treated as a signed integer, otherwise
  6. -1 will underflow to 65535. When dragging a scrollbar, this would
  7. cause the scrollbar to snap to the bottom when the cursor is dragged
  8. above the window's y=0 coordinate. Verified that the issue is fixed
  9. after this CL.
  10. BUG=1139623,1136352
  11. R=sky
  12. Change-Id: Ie318006ceadde9b9ce3e267fb453ddeba0e81da0
  13. Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2485620
  14. Auto-Submit: Thomas Anderson <thomasanderson@chromium.org>
  15. Commit-Queue: Scott Violet <sky@chromium.org>
  16. Reviewed-by: Scott Violet <sky@chromium.org>
  17. Cr-Commit-Position: refs/heads/master@{#819538}
  18. ---
  19. ui/events/x/events_x_utils.cc | 2 +-
  20. 1 file changed, 1 insertion(+), 1 deletion(-)
  21. diff --git a/ui/events/x/events_x_utils.cc b/ui/events/x/events_x_utils.cc
  22. index 3010db5f40c..856dfb221e7 100644
  23. --- a/ui/events/x/events_x_utils.cc
  24. +++ b/ui/events/x/events_x_utils.cc
  25. @@ -376,7 +376,7 @@ base::TimeTicks TimeTicksFromXEvent(const x11::Event& xev) {
  26. // This is ported from libxi's FP1616toDBL in XExtInt.c
  27. double Fp1616ToDouble(x11::Input::Fp1616 x) {
  28. - auto x32 = static_cast<uint32_t>(x);
  29. + auto x32 = static_cast<int32_t>(x);
  30. return x32 * 1.0 / (1 << 16);
  31. }