summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-01 20:09:31 +0000
committerrlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-01 20:09:31 +0000
commit9a1d0d7f92dd754a4b29f8bd507a7cbeabce1c71 (patch)
treef5c5c944da290436f5aeb527f27f31956ed24631
parent36c455852d581784b4181151ce61022de2fc04b7 (diff)
downloadchromium_src-9a1d0d7f92dd754a4b29f8bd507a7cbeabce1c71.zip
chromium_src-9a1d0d7f92dd754a4b29f8bd507a7cbeabce1c71.tar.gz
chromium_src-9a1d0d7f92dd754a4b29f8bd507a7cbeabce1c71.tar.bz2
Revert of Don't handle NaturalScroll in Chrome but pass it to CMT instead (https://codereview.chromium.org/212603005/)
Reason for revert: Has caused many compile failures. We think the trybots didn't catch it because they didn't build ash_unittests. Example: http://build.chromium.org/p/chromium.chromiumos/builders/Linux%20ChromiumOS%20Builder%20%28dbg%29/builds/46547 ../../ash/sticky_keys/sticky_keys_unittest.cc: In member function 'virtual void ash::StickyKeysTest_ScrollEventOneshot_Test::TestBody()': ../../ash/sticky_keys/sticky_keys_unittest.cc:622:41:error: 'class ui::DeviceDataManager' has no member named 'set_natural_scroll_enabled' ../../ash/sticky_keys/sticky_keys_unittest.cc: In member function 'virtual void ash::StickyKeysTest_ScrollDirectionChanged_Test::TestBody()': ../../ash/sticky_keys/sticky_keys_unittest.cc:674:41:error: 'class ui::DeviceDataManager' has no member named 'set_natural_scroll_enabled' ../../ash/sticky_keys/sticky_keys_unittest.cc: In member function 'virtual void ash::StickyKeysTest_ScrollEventLocked_Test::TestBody()': ../../ash/sticky_keys/sticky_keys_unittest.cc:711:41:error: 'class ui::DeviceDataManager' has no member named 'set_natural_scroll_enabled' ninja: build stopped: subcommand failed. Original issue's description: > Don't handle NaturalScroll in Chrome but pass it to CMT instead > > In order to support mice via CMT (Project Cobra) we will have to do > the natural scroll handling in the CMT driver instead of Chrome. > > BUG=chromium:285663 > TEST=test with touchpads and traditional mice. Everything should work as before, > touchpad should have natural scroll applied, scroll wheels should not. > Test changing the natural scroll property and see if it's applied correctly. > Also test if touch mice have natural scroll applied. > > Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=260926 TBR=achuith@chromium.org,sky@chromium.org,sadrul@chromium.org,denniskempin@chromium.org NOTREECHECKS=true NOTRY=true BUG=chromium:285663 Review URL: https://codereview.chromium.org/221363002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@260932 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chromeos/chrome_browser_main_chromeos.cc3
-rw-r--r--chrome/browser/chromeos/login/login_display_host_impl.cc6
-rw-r--r--chrome/browser/chromeos/preferences.cc2
-rw-r--r--chrome/browser/chromeos/preferences_browsertest.cc2
-rw-r--r--chrome/browser/chromeos/system/fake_input_device_settings.cc6
-rw-r--r--chrome/browser/chromeos/system/fake_input_device_settings.h2
-rw-r--r--chrome/browser/chromeos/system/input_device_settings.cc22
-rw-r--r--chrome/browser/chromeos/system/input_device_settings.h7
-rw-r--r--chrome/browser/ui/views/ash/tab_scrubber.cc2
-rw-r--r--ui/events/event_utils.h6
-rw-r--r--ui/events/x/device_data_manager.cc33
-rw-r--r--ui/events/x/device_data_manager.h10
-rw-r--r--ui/events/x/events_x.cc8
13 files changed, 57 insertions, 52 deletions
diff --git a/chrome/browser/chromeos/chrome_browser_main_chromeos.cc b/chrome/browser/chromeos/chrome_browser_main_chromeos.cc
index 4979adf..4dfc642 100644
--- a/chrome/browser/chromeos/chrome_browser_main_chromeos.cc
+++ b/chrome/browser/chromeos/chrome_browser_main_chromeos.cc
@@ -65,7 +65,6 @@
#include "chrome/browser/chromeos/settings/device_settings_service.h"
#include "chrome/browser/chromeos/settings/owner_key_util.h"
#include "chrome/browser/chromeos/status/data_promo_notification.h"
-#include "chrome/browser/chromeos/system/input_device_settings.h"
#include "chrome/browser/chromeos/upgrade_detector_chromeos.h"
#include "chrome/browser/defaults.h"
#include "chrome/browser/metrics/metrics_service.h"
@@ -715,7 +714,7 @@ void ChromeBrowserMainPartsChromeos::PreBrowserStart() {
if (ui::ShouldDefaultToNaturalScroll()) {
CommandLine::ForCurrentProcess()->AppendSwitch(
chromeos::switches::kNaturalScrollDefault);
- system::InputDeviceSettings::Get()->SetTapToClick(true);
+ ui::SetNaturalScroll(true);
}
ChromeBrowserMainPartsLinux::PreBrowserStart();
diff --git a/chrome/browser/chromeos/login/login_display_host_impl.cc b/chrome/browser/chromeos/login/login_display_host_impl.cc
index b7e072f..51f6897 100644
--- a/chrome/browser/chromeos/login/login_display_host_impl.cc
+++ b/chrome/browser/chromeos/login/login_display_host_impl.cc
@@ -1055,9 +1055,9 @@ void ShowLoginWizard(const std::string& first_screen_name) {
system::InputDeviceSettings::Get()->SetTapToClick(
prefs->GetBoolean(prefs::kOwnerTapToClickEnabled));
}
- system::InputDeviceSettings::Get()->SetNaturalScroll(
- CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kNaturalScrollDefault));
+
+ ui::SetNaturalScroll(CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kNaturalScrollDefault));
gfx::Rect screen_bounds(chromeos::CalculateScreenBounds(gfx::Size()));
diff --git a/chrome/browser/chromeos/preferences.cc b/chrome/browser/chromeos/preferences.cc
index 758d12c..44048d6 100644
--- a/chrome/browser/chromeos/preferences.cc
+++ b/chrome/browser/chromeos/preferences.cc
@@ -442,7 +442,7 @@ void Preferences::ApplyPreferences(ApplyReason reason,
const bool enabled = natural_scroll_.GetValue();
DVLOG(1) << "Natural scroll set to " << enabled;
if (user_is_active)
- touchpad_settings.SetNaturalScroll(enabled);
+ ui::SetNaturalScroll(enabled);
if (reason == REASON_PREF_CHANGED)
UMA_HISTOGRAM_BOOLEAN("Touchpad.NaturalScroll.Changed", enabled);
else if (reason == REASON_INITIALIZATION)
diff --git a/chrome/browser/chromeos/preferences_browsertest.cc b/chrome/browser/chromeos/preferences_browsertest.cc
index 295bb9f..e955511 100644
--- a/chrome/browser/chromeos/preferences_browsertest.cc
+++ b/chrome/browser/chromeos/preferences_browsertest.cc
@@ -89,6 +89,8 @@ class PreferencesTest : public LoginManagerTest {
EXPECT_EQ(prefs->GetBoolean(prefs::kEnableTouchpadThreeFingerClick),
input_settings_->current_touchpad_settings()
.GetThreeFingerClick());
+ EXPECT_EQ(prefs->GetBoolean(prefs::kNaturalScroll),
+ ui::IsNaturalScrollEnabled());
EXPECT_EQ(prefs->GetInteger(prefs::kMouseSensitivity),
input_settings_->current_mouse_settings().GetSensitivity());
EXPECT_EQ(prefs->GetInteger(prefs::kTouchpadSensitivity),
diff --git a/chrome/browser/chromeos/system/fake_input_device_settings.cc b/chrome/browser/chromeos/system/fake_input_device_settings.cc
index 50e8038..b422f97 100644
--- a/chrome/browser/chromeos/system/fake_input_device_settings.cc
+++ b/chrome/browser/chromeos/system/fake_input_device_settings.cc
@@ -46,12 +46,6 @@ void FakeInputDeviceSettings::SetTapDragging(bool enabled) {
UpdateTouchpadSettings(settings);
}
-void FakeInputDeviceSettings::SetNaturalScroll(bool enabled) {
- TouchpadSettings settings;
- settings.SetNaturalScroll(enabled);
- UpdateTouchpadSettings(settings);
-}
-
void FakeInputDeviceSettings::MouseExists(
const DeviceExistsCallback& callback) {
callback.Run(false);
diff --git a/chrome/browser/chromeos/system/fake_input_device_settings.h b/chrome/browser/chromeos/system/fake_input_device_settings.h
index b1aa6b8..78e7038 100644
--- a/chrome/browser/chromeos/system/fake_input_device_settings.h
+++ b/chrome/browser/chromeos/system/fake_input_device_settings.h
@@ -30,8 +30,6 @@ class FakeInputDeviceSettings : public InputDeviceSettings {
virtual void UpdateMouseSettings(const MouseSettings& settings) OVERRIDE;
virtual void SetMouseSensitivity(int value) OVERRIDE;
virtual void SetPrimaryButtonRight(bool right) OVERRIDE;
- virtual void SetNaturalScroll(bool enabled) OVERRIDE;
-
virtual bool ForceKeyboardDrivenUINavigation() OVERRIDE;
virtual void ReapplyTouchpadSettings() OVERRIDE;
virtual void ReapplyMouseSettings() OVERRIDE;
diff --git a/chrome/browser/chromeos/system/input_device_settings.cc b/chrome/browser/chromeos/system/input_device_settings.cc
index e92b31a..10cc5a6 100644
--- a/chrome/browser/chromeos/system/input_device_settings.cc
+++ b/chrome/browser/chromeos/system/input_device_settings.cc
@@ -151,7 +151,6 @@ class InputDeviceSettingsImpl : public InputDeviceSettings {
virtual void SetTapToClick(bool enabled) OVERRIDE;
virtual void SetThreeFingerClick(bool enabled) OVERRIDE;
virtual void SetTapDragging(bool enabled) OVERRIDE;
- virtual void SetNaturalScroll(bool enabled) OVERRIDE;
virtual void MouseExists(const DeviceExistsCallback& callback) OVERRIDE;
virtual void UpdateMouseSettings(const MouseSettings& update) OVERRIDE;
virtual void SetMouseSensitivity(int value) OVERRIDE;
@@ -187,12 +186,6 @@ void InputDeviceSettingsImpl::SetTouchpadSensitivity(int value) {
UpdateTouchpadSettings(settings);
}
-void InputDeviceSettingsImpl::SetNaturalScroll(bool enabled) {
- TouchpadSettings settings;
- settings.SetNaturalScroll(enabled);
- UpdateTouchpadSettings(settings);
-}
-
void InputDeviceSettingsImpl::SetTapToClick(bool enabled) {
TouchpadSettings settings;
settings.SetTapToClick(enabled);
@@ -283,7 +276,6 @@ TouchpadSettings& TouchpadSettings::operator=(const TouchpadSettings& other) {
tap_to_click_ = other.tap_to_click_;
three_finger_click_ = other.three_finger_click_;
tap_dragging_ = other.tap_dragging_;
- natural_scroll_ = other.natural_scroll_;
}
return *this;
}
@@ -304,14 +296,6 @@ bool TouchpadSettings::GetTapToClick() const {
return tap_to_click_.value();
}
-void TouchpadSettings::SetNaturalScroll(bool enabled) {
- natural_scroll_.Set(enabled);
-}
-
-bool TouchpadSettings::GetNaturalScroll() const {
- return natural_scroll_.value();
-}
-
void TouchpadSettings::SetThreeFingerClick(bool enabled) {
three_finger_click_.Set(enabled);
}
@@ -355,12 +339,6 @@ bool TouchpadSettings::Update(const TouchpadSettings& settings,
if (argv)
AddTPControlArguments("tapdrag", tap_dragging_.value(), argv);
}
- if (natural_scroll_.Update(settings.natural_scroll_)) {
- updated = true;
- if (argv)
- AddTPControlArguments("australian_scrolling", natural_scroll_.value(),
- argv);
- }
return updated;
}
diff --git a/chrome/browser/chromeos/system/input_device_settings.h b/chrome/browser/chromeos/system/input_device_settings.h
index ba938a1..901106a 100644
--- a/chrome/browser/chromeos/system/input_device_settings.h
+++ b/chrome/browser/chromeos/system/input_device_settings.h
@@ -96,9 +96,6 @@ class TouchpadSettings {
void SetTapDragging(bool enabled);
bool GetTapDragging() const;
- void SetNaturalScroll(bool enabled);
- bool GetNaturalScroll() const;
-
// Updates |this| with |settings|. If at least one setting was updated returns
// true.
// |argv| is filled with arguments of script, that should be launched in order
@@ -110,7 +107,6 @@ class TouchpadSettings {
internal::Optional<bool> tap_to_click_;
internal::Optional<bool> three_finger_click_;
internal::Optional<bool> tap_dragging_;
- internal::Optional<bool> natural_scroll_;
};
// Auxiliary class used to update several mouse settings at a time. User
@@ -177,9 +173,6 @@ class InputDeviceSettings {
// Turns tap-dragging on/off.
virtual void SetTapDragging(bool enabled) = 0;
- // Turns natural scrolling on/off for all devices except wheel mice
- virtual void SetNaturalScroll(bool enabled) = 0;
-
// Calls |callback| asynchronously after determining if a mouse is connected.
virtual void MouseExists(const DeviceExistsCallback& callback) = 0;
diff --git a/chrome/browser/ui/views/ash/tab_scrubber.cc b/chrome/browser/ui/views/ash/tab_scrubber.cc
index 49ef35a..9cc6f46 100644
--- a/chrome/browser/ui/views/ash/tab_scrubber.cc
+++ b/chrome/browser/ui/views/ash/tab_scrubber.cc
@@ -109,6 +109,8 @@ void TabScrubber::OnScrollEvent(ui::ScrollEvent* event) {
event->StopPropagation();
float x_offset = event->x_offset();
+ if (!ui::IsNaturalScrollEnabled())
+ x_offset = -x_offset;
int last_tab_index = highlighted_tab_ == -1 ?
browser->tab_strip_model()->active_index() : highlighted_tab_;
if (!scrubbing_) {
diff --git a/ui/events/event_utils.h b/ui/events/event_utils.h
index 9c40ab5..e077522 100644
--- a/ui/events/event_utils.h
+++ b/ui/events/event_utils.h
@@ -123,6 +123,12 @@ EVENTS_EXPORT bool GetGestureTimes(const base::NativeEvent& native_event,
double* start_time,
double* end_time);
+// Enable/disable natural scrolling for touchpads.
+EVENTS_EXPORT void SetNaturalScroll(bool enabled);
+
+// In natural scrolling enabled for touchpads?
+EVENTS_EXPORT bool IsNaturalScrollEnabled();
+
// Returns whether natural scrolling should be used for touchpad.
EVENTS_EXPORT bool ShouldDefaultToNaturalScroll();
diff --git a/ui/events/x/device_data_manager.cc b/ui/events/x/device_data_manager.cc
index cac9dfd..a2e0292 100644
--- a/ui/events/x/device_data_manager.cc
+++ b/ui/events/x/device_data_manager.cc
@@ -110,7 +110,8 @@ DeviceDataManager* DeviceDataManager::GetInstance() {
}
DeviceDataManager::DeviceDataManager()
- : xi_opcode_(-1),
+ : natural_scroll_enabled_(false),
+ xi_opcode_(-1),
atom_cache_(gfx::GetXDisplay(), kCachedAtoms),
button_map_count_(0) {
CHECK(gfx::GetXDisplay());
@@ -176,6 +177,14 @@ bool DeviceDataManager::IsXInput2Available() const {
return xi_opcode_ != -1;
}
+float DeviceDataManager::GetNaturalScrollFactor(int sourceid) const {
+ // Natural scroll is touchpad-only.
+ if (sourceid >= kMaxDeviceNum || !touchpads_[sourceid])
+ return -1.0f;
+
+ return natural_scroll_enabled_ ? 1.0f : -1.0f;
+}
+
void DeviceDataManager::UpdateDeviceList(Display* display) {
cmt_devices_.reset();
touchpads_.reset();
@@ -451,17 +460,20 @@ void DeviceDataManager::GetScrollOffsets(const base::NativeEvent& native_event,
*y_offset_ordinal = 0;
*finger_count = 2;
+ XIDeviceEvent* xiev =
+ static_cast<XIDeviceEvent*>(native_event->xcookie.data);
+ const float natural_scroll_factor = GetNaturalScrollFactor(xiev->sourceid);
EventData data;
GetEventRawData(*native_event, &data);
if (data.find(DT_CMT_SCROLL_X) != data.end())
- *x_offset = data[DT_CMT_SCROLL_X];
+ *x_offset = data[DT_CMT_SCROLL_X] * natural_scroll_factor;
if (data.find(DT_CMT_SCROLL_Y) != data.end())
- *y_offset = data[DT_CMT_SCROLL_Y];
+ *y_offset = data[DT_CMT_SCROLL_Y] * natural_scroll_factor;
if (data.find(DT_CMT_ORDINAL_X) != data.end())
- *x_offset_ordinal = data[DT_CMT_ORDINAL_X];
+ *x_offset_ordinal = data[DT_CMT_ORDINAL_X] * natural_scroll_factor;
if (data.find(DT_CMT_ORDINAL_Y) != data.end())
- *y_offset_ordinal = data[DT_CMT_ORDINAL_Y];
+ *y_offset_ordinal = data[DT_CMT_ORDINAL_Y] * natural_scroll_factor;
if (data.find(DT_CMT_FINGER_COUNT) != data.end())
*finger_count = static_cast<int>(data[DT_CMT_FINGER_COUNT]);
}
@@ -476,19 +488,22 @@ void DeviceDataManager::GetFlingData(const base::NativeEvent& native_event,
*vy_ordinal = 0;
*is_cancel = false;
+ XIDeviceEvent* xiev =
+ static_cast<XIDeviceEvent*>(native_event->xcookie.data);
+ const float natural_scroll_factor = GetNaturalScrollFactor(xiev->sourceid);
EventData data;
GetEventRawData(*native_event, &data);
if (data.find(DT_CMT_FLING_X) != data.end())
- *vx = data[DT_CMT_FLING_X];
+ *vx = data[DT_CMT_FLING_X] * natural_scroll_factor;
if (data.find(DT_CMT_FLING_Y) != data.end())
- *vy = data[DT_CMT_FLING_Y];
+ *vy = data[DT_CMT_FLING_Y] * natural_scroll_factor;
if (data.find(DT_CMT_FLING_STATE) != data.end())
*is_cancel = !!static_cast<unsigned int>(data[DT_CMT_FLING_STATE]);
if (data.find(DT_CMT_ORDINAL_X) != data.end())
- *vx_ordinal = data[DT_CMT_ORDINAL_X];
+ *vx_ordinal = data[DT_CMT_ORDINAL_X] * natural_scroll_factor;
if (data.find(DT_CMT_ORDINAL_Y) != data.end())
- *vy_ordinal = data[DT_CMT_ORDINAL_Y];
+ *vy_ordinal = data[DT_CMT_ORDINAL_Y] * natural_scroll_factor;
}
void DeviceDataManager::GetMetricsData(const base::NativeEvent& native_event,
diff --git a/ui/events/x/device_data_manager.h b/ui/events/x/device_data_manager.h
index ce009a0..aff0649 100644
--- a/ui/events/x/device_data_manager.h
+++ b/ui/events/x/device_data_manager.h
@@ -104,9 +104,18 @@ class EVENTS_BASE_EXPORT DeviceDataManager {
// Returns the DeviceDataManager singleton.
static DeviceDataManager* GetInstance();
+ // Natural scroll setter/getter.
+ bool natural_scroll_enabled() const { return natural_scroll_enabled_; }
+ void set_natural_scroll_enabled(bool enabled) {
+ natural_scroll_enabled_ = enabled;
+ }
+
// Returns if XInput2 is available on the system.
bool IsXInput2Available() const;
+ // Get the natural scroll direction multiplier (1.0f or -1.0f).
+ float GetNaturalScrollFactor(int sourceid) const;
+
// Updates the list of devices.
void UpdateDeviceList(Display* display);
@@ -239,6 +248,7 @@ class EVENTS_BASE_EXPORT DeviceDataManager {
static const int kMaxDeviceNum = 128;
static const int kMaxXIEventType = XI_LASTEVENT + 1;
static const int kMaxSlotNum = 10;
+ bool natural_scroll_enabled_;
// Major opcode for the XInput extension. Used to identify XInput events.
int xi_opcode_;
diff --git a/ui/events/x/events_x.cc b/ui/events/x/events_x.cc
index bf8b04e..9fec9df 100644
--- a/ui/events/x/events_x.cc
+++ b/ui/events/x/events_x.cc
@@ -667,6 +667,14 @@ bool GetGestureTimes(const base::NativeEvent& native_event,
return true;
}
+void SetNaturalScroll(bool enabled) {
+ DeviceDataManager::GetInstance()->set_natural_scroll_enabled(enabled);
+}
+
+bool IsNaturalScrollEnabled() {
+ return DeviceDataManager::GetInstance()->natural_scroll_enabled();
+}
+
bool IsTouchpadEvent(const base::NativeEvent& event) {
return DeviceDataManager::GetInstance()->IsTouchpadXInputEvent(event);
}