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

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..1c732c526144af2e09a78070de2042f307beac21 100644
--- a/chrome/browser/ui/cocoa/browser_window_controller.mm
+++ b/chrome/browser/ui/cocoa/browser_window_controller.mm
@@ -40,6 +40,7 @@
#import "chrome/browser/ui/cocoa/focus_tracker.h"
#import "chrome/browser/ui/cocoa/fullscreen_controller.h"
#import "chrome/browser/ui/cocoa/fullscreen_window.h"
+#import "chrome/browser/ui/cocoa/gesture_utils.h"
#import "chrome/browser/ui/cocoa/image_utils.h"
#import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h"
#import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.h"
@@ -1673,13 +1674,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 (gesture_utils::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
@@ -1738,9 +1749,9 @@ typedef NSInteger NSWindowAnimationBehavior;
// the system gesture recognizer will automatically call |-swipeWithEvent:|
// and that will be handled as it would be on Snow Leopard. The two-finger
// gesture does not do this, so it must be manually recognized. See the note
- // inside |-recognizeTwoFingerGestures| for detailed information on the
+ // inside RecognizeTwoFingerGestures() for detailed information on the
// interaction of the different preferences.
- if (![self recognizeTwoFingerGestures])
+ if (!gesture_utils::RecognizeTwoFingerGestures())
return;
NSSet* touches = [event touchesMatchingPhase:NSTouchPhaseAny
inView:nil];
@@ -1787,6 +1798,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 (gesture_utils::IsScrollDirectionInverted())
+ sum *= -1;
+
int command_id = 0;
if (sum > 0.3)
command_id = IDC_FORWARD;
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/browser_window_controller_private.h » ('j') | chrome/browser/ui/cocoa/gesture_utils.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698