Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(437)

Unified Diff: ui/events/cocoa/events_mac.mm

Issue 2461323002: Mac: Support Sierra's broken MouseWheel events. (Closed)
Patch Set: Horizontal is a trap - stay clear Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/renderer_host/input/web_input_event_builders_mac.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/events/cocoa/events_mac.mm
diff --git a/ui/events/cocoa/events_mac.mm b/ui/events/cocoa/events_mac.mm
index 4a8347fd25f67bb93125ef6f5ff82f407334ee13..4c334682c71f18536c8b0cf7438f4461f191b8f1 100644
--- a/ui/events/cocoa/events_mac.mm
+++ b/ui/events/cocoa/events_mac.mm
@@ -155,8 +155,26 @@ gfx::Vector2d GetMouseWheelOffset(const base::NativeEvent& event) {
// Use the same multiplier as content::WebMouseWheelEventBuilder. Note this
// differs from the value returned by CGEventSourceGetPixelsPerLine(), which
// is typically 10.
- return gfx::Vector2d(kScrollbarPixelsPerCocoaTick * [event deltaX],
- kScrollbarPixelsPerCocoaTick * [event deltaY]);
+ CGFloat deltaX = [event deltaX] * kScrollbarPixelsPerCocoaTick;
+ CGFloat deltaY = [event deltaY] * kScrollbarPixelsPerCocoaTick;
+
+ // A rounding bug on Sierra means that single-tick wheel scrolls may be
+ // truncated to zero. Prefer kCGScrollWheelEventPointDeltaAxisXY in those
+ // cases. However, kCGScrollWheelEventPointDeltaAxisXY has a "nasty bug"
+ // when holding Shift (see "Of Mice and Men", above). So only check vertical
+ // scrolls. Also, to be consistent with the values when truncation does NOT
+ // scroll, it needs to be multiplied by some factor. The documentation for
+ // CGEventSourceGetPixelsPerLine() says "By default, the scale is about ten
+ // pixels per line." However, the actual relationship is fuzzy because of
+ // acceleration. Using a constant of 10 for small values seems to "feel
+ // right" when this bug is encountered. See http://crbug.com/660773.
+ const float kPixelsPerLine = 10.0;
+ int64_t pointDeltaY = CGEventGetIntegerValueField(
+ [event CGEvent], kCGScrollWheelEventPointDeltaAxis1);
+ if (deltaY == 0 && pointDeltaY != 0)
+ deltaY = pointDeltaY * kPixelsPerLine;
+
+ return gfx::Vector2d(deltaX, deltaY);
}
}
« no previous file with comments | « content/browser/renderer_host/input/web_input_event_builders_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698