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

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

Issue 7465072: Merge 94122 - [Mac] Respect natural/inverted scroll direction on Lion when gesturing. (Closed) Base URL: svn://svn.chromium.org/chrome/branches/835/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
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/browser_window_controller_private.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/browser_window_controller.mm
===================================================================
--- chrome/browser/ui/cocoa/browser_window_controller.mm (revision 94312)
+++ chrome/browser/ui/cocoa/browser_window_controller.mm (working copy)
@@ -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 @@
// 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 @@
// 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 @@
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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698