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

Unified Diff: chrome/browser/ui/cocoa/browser_window_controller.mm

Issue 7461080: [Mac] Respect natural/inverted scroll direction on Lion when gesturing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 5 months 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
Index: chrome/browser/ui/cocoa/browser_window_controller.mm
diff --git a/chrome/browser/ui/cocoa/browser_window_controller.mm b/chrome/browser/ui/cocoa/browser_window_controller.mm
index 6e4a26ae3e6c2017a59688886d76f1bc2f4fb8eb..e8aaf325ec0d5b576754f54f06eceedbecaa657c 100644
--- a/chrome/browser/ui/cocoa/browser_window_controller.mm
+++ b/chrome/browser/ui/cocoa/browser_window_controller.mm
@@ -1673,13 +1673,23 @@ typedef NSInteger NSWindowAnimationBehavior;
// Documented in 10.6+, but present starting in 10.5. Called when we get a
// three-finger swipe.
- (void)swipeWithEvent:(NSEvent*)event {
+ CGFloat deltaX = [event deltaX];
+ CGFloat deltaY = [event deltaY];
+
+ // On Lion, the user can choose to use a "natural" scroll direction with
+ // inverted axes.
+ if ([self isScrollDirectionInverted]) {
+ deltaX *= -1;
+ deltaY *= -1;
+ }
+
// Map forwards and backwards to history; left is positive, right is negative.
unsigned int command = 0;
- if ([event deltaX] > 0.5) {
+ if (deltaX > 0.5) {
command = IDC_BACK;
- } else if ([event deltaX] < -0.5) {
+ } else if (deltaX < -0.5) {
command = IDC_FORWARD;
- } else if ([event deltaY] > 0.5) {
+ } else if (deltaY > 0.5) {
// TODO(pinkerton): figure out page-up, http://crbug.com/16305
} else if ([event deltaY] < -0.5) {
// TODO(pinkerton): figure out page-down, http://crbug.com/16305
@@ -1787,6 +1797,11 @@ typedef NSInteger NSWindowAnimationBehavior;
return;
CGFloat sum = std::accumulate(magnitudes.begin(), magnitudes.end(), 0.0f);
+ // On Lion, the user can choose to use a "natural" scroll direction with
+ // inverted axes.
+ if ([self isScrollDirectionInverted])
+ sum *= -1;
+
int command_id = 0;
if (sum > 0.3)
command_id = IDC_FORWARD;

Powered by Google App Engine
This is Rietveld 408576698