diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-23 21:46:38 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-23 21:46:38 +0000 |
commit | 9da67aa021c15d0954831b02e9592c2fd575f083 (patch) | |
tree | 51cbd466424a24ef6c26a2962829a3a5caaf2d68 /chrome | |
parent | b6d432335f59500e092de2be4fcf42ed303ae1c5 (diff) | |
download | chromium_src-9da67aa021c15d0954831b02e9592c2fd575f083.zip chromium_src-9da67aa021c15d0954831b02e9592c2fd575f083.tar.gz chromium_src-9da67aa021c15d0954831b02e9592c2fd575f083.tar.bz2 |
Lands http://codereview.chromium.org/227008 for Charlie:
Add touchpad sensitivity setting.
BUG=22848
TEST=none
Review URL: http://codereview.chromium.org/223012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26996 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/app/generated_resources.grd | 3 | ||||
-rw-r--r-- | chrome/browser/chromeos/settings_contents_view.cc | 34 | ||||
-rw-r--r-- | chrome/browser/chromeos/touchpad.cc | 53 | ||||
-rw-r--r-- | chrome/browser/chromeos/touchpad.h | 14 | ||||
-rw-r--r-- | chrome/browser/options_util.cc | 1 | ||||
-rw-r--r-- | chrome/common/pref_names.cc | 5 | ||||
-rw-r--r-- | chrome/common/pref_names.h | 1 |
7 files changed, 85 insertions, 26 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 8de9f3b..1280209 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -5263,6 +5263,9 @@ Keep your key file in a safe place. You will need it to create new versions of y <message name="IDS_OPTIONS_SETTINGS_VERT_EDGE_SCROLL_ENABLED_DESCRIPTION" desc="In the settings tab, the text next to the checkbox that enables vertical edge scrolling."> Enable vertical edge scrolling </message> + <message name="IDS_OPTIONS_SETTINGS_SENSITIVITY_DESCRIPTION" desc="In the settings tab, the text next to the slider for the touchpad touch sensitivity."> + Touch Sensitivity: + </message> <message name="IDS_OPTIONS_SETTINGS_SPEED_FACTOR_DESCRIPTION" desc="In the settings tab, the text next to the slider for the touchpad speed factor."> Speed Sensitivity: </message> diff --git a/chrome/browser/chromeos/settings_contents_view.cc b/chrome/browser/chromeos/settings_contents_view.cc index 7dbee18..4c38b34 100644 --- a/chrome/browser/chromeos/settings_contents_view.cc +++ b/chrome/browser/chromeos/settings_contents_view.cc @@ -381,11 +381,13 @@ class TouchpadSection : public OptionsPageView, views::Checkbox* enable_tap_to_click_checkbox_; views::Checkbox* enable_vert_edge_scroll_checkbox_; views::Slider* speed_factor_slider_; + views::Slider* sensitivity_slider_; // Preferences for this section: BooleanPrefMember tap_to_click_enabled_; BooleanPrefMember vert_edge_scroll_enabled_; - RealPrefMember speed_factor_; + IntegerPrefMember speed_factor_; + IntegerPrefMember sensitivity_; DISALLOW_COPY_AND_ASSIGN(TouchpadSection); }; @@ -395,7 +397,8 @@ TouchpadSection::TouchpadSection(Profile* profile) contents_(NULL), enable_tap_to_click_checkbox_(NULL), enable_vert_edge_scroll_checkbox_(NULL), - speed_factor_slider_(NULL) { + speed_factor_slider_(NULL), + sensitivity_slider_(NULL) { } void TouchpadSection::ButtonPressed( @@ -423,6 +426,11 @@ void TouchpadSection::SliderValueChanged(views::Slider* sender) { UserMetricsRecordAction(L"Options_SpeedFactorSlider_Changed", profile()->GetPrefs()); speed_factor_.SetValue(value); + } else if (sender == sensitivity_slider_) { + double value = sensitivity_slider_->value(); + UserMetricsRecordAction(L"Options_SensitivitySlider_Changed", + profile()->GetPrefs()); + sensitivity_.SetValue(value); } } @@ -467,11 +475,16 @@ void TouchpadSection::InitContents() { IDS_OPTIONS_SETTINGS_VERT_EDGE_SCROLL_ENABLED_DESCRIPTION)); enable_vert_edge_scroll_checkbox_->set_listener(this); enable_vert_edge_scroll_checkbox_->SetMultiLine(true); - // Create speed factor slider with values between 0.1 and 1.0 step 0.1 - speed_factor_slider_ = new views::Slider(0.1, 1.0, 0.1, + // Create speed factor slider with values between 1 and 10 step 1 + speed_factor_slider_ = new views::Slider(1, 10, 1, + static_cast<views::Slider::StyleFlags>( + views::Slider::STYLE_DRAW_VALUE | + views::Slider::STYLE_UPDATE_ON_RELEASE), + this); + // Create sensitivity slider with values between 1 and 10 step 1 + sensitivity_slider_ = new views::Slider(1, 10, 1, static_cast<views::Slider::StyleFlags>( views::Slider::STYLE_DRAW_VALUE | - views::Slider::STYLE_ONE_DIGIT | views::Slider::STYLE_UPDATE_ON_RELEASE), this); @@ -490,6 +503,11 @@ void TouchpadSection::InitContents() { layout->StartRow(0, double_column_view_set_id); layout->AddView(new views::Label( + l10n_util::GetString(IDS_OPTIONS_SETTINGS_SENSITIVITY_DESCRIPTION))); + layout->AddView(sensitivity_slider_); + layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); + layout->StartRow(0, double_column_view_set_id); + layout->AddView(new views::Label( l10n_util::GetString(IDS_OPTIONS_SETTINGS_SPEED_FACTOR_DESCRIPTION))); layout->AddView(speed_factor_slider_); layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); @@ -507,6 +525,8 @@ void TouchpadSection::InitContents() { profile()->GetPrefs(), this); speed_factor_.Init(prefs::kTouchpadSpeedFactor, profile()->GetPrefs(), this); + sensitivity_.Init(prefs::kTouchpadSensitivity, + profile()->GetPrefs(), this); } void TouchpadSection::NotifyPrefChanged(const std::wstring* pref_name) { @@ -522,6 +542,10 @@ void TouchpadSection::NotifyPrefChanged(const std::wstring* pref_name) { double value = speed_factor_.GetValue(); speed_factor_slider_->SetValue(value); } + if (!pref_name || *pref_name == prefs::kTouchpadSensitivity) { + double value = sensitivity_.GetValue(); + sensitivity_slider_->SetValue(value); + } } } // namespace diff --git a/chrome/browser/chromeos/touchpad.cc b/chrome/browser/chromeos/touchpad.cc index 5c43270..6031201 100644 --- a/chrome/browser/chromeos/touchpad.cc +++ b/chrome/browser/chromeos/touchpad.cc @@ -32,18 +32,21 @@ void RunnableMethodTraits<Touchpad>::ReleaseCallee( void Touchpad::RegisterUserPrefs(PrefService* prefs) { prefs->RegisterBooleanPref(prefs::kTapToClickEnabled, false); prefs->RegisterBooleanPref(prefs::kVertEdgeScrollEnabled, true); - prefs->RegisterRealPref(prefs::kTouchpadSpeedFactor, 0.5); + prefs->RegisterIntegerPref(prefs::kTouchpadSpeedFactor, 5); + prefs->RegisterIntegerPref(prefs::kTouchpadSensitivity, 5); } void Touchpad::Init(PrefService* prefs) { tap_to_click_enabled_.Init(prefs::kTapToClickEnabled, prefs, this); vert_edge_scroll_enabled_.Init(prefs::kVertEdgeScrollEnabled, prefs, this); speed_factor_.Init(prefs::kTouchpadSpeedFactor, prefs, this); + sensitivity_.Init(prefs::kTouchpadSensitivity, prefs, this); // Initialize touchpad settings to what's saved in user preferences. SetTapToClick(); SetVertEdgeScroll(); SetSpeedFactor(); + SetSensitivity(); } void Touchpad::Observe(NotificationType type, @@ -60,10 +63,11 @@ void Touchpad::NotifyPrefChanged(const std::wstring* pref_name) { SetVertEdgeScroll(); if (!pref_name || *pref_name == prefs::kTouchpadSpeedFactor) SetSpeedFactor(); + if (!pref_name || *pref_name == prefs::kTouchpadSensitivity) + SetSensitivity(); } -void Touchpad::SetSynclientParam(const std::string& param, - const std::string& value) { +void Touchpad::SetSynclientParam(const std::string& param, double value) { // If not running on the file thread, then re-run on the file thread. if (!ChromeThread::CurrentlyOn(ChromeThread::FILE)) { base::Thread* file_thread = g_browser_process->file_thread(); @@ -74,7 +78,7 @@ void Touchpad::SetSynclientParam(const std::string& param, // launch binary synclient to set the parameter std::vector<std::string> argv; argv.push_back("/usr/bin/synclient"); - argv.push_back(param + "=" + value); + argv.push_back(StringPrintf("%s=%f", param.c_str(), value)); base::file_handle_mapping_vector no_files; base::ProcessHandle handle; if (!base::LaunchApp(argv, no_files, true, &handle)) @@ -87,9 +91,9 @@ void Touchpad::SetTapToClick() { // mouse click event), we set MaxTapTime to 0. MaxTapTime is the maximum time // (in milliseconds) for detecting a tap. The default is 180. if (tap_to_click_enabled_.GetValue()) - SetSynclientParam("MaxTapTime", "180"); + SetSynclientParam("MaxTapTime", 180); else - SetSynclientParam("MaxTapTime", "0"); + SetSynclientParam("MaxTapTime", 0); } void Touchpad::SetVertEdgeScroll() { @@ -97,20 +101,39 @@ void Touchpad::SetVertEdgeScroll() { // scroll lets you use the right edge of the touchpad to control the movement // of the vertical scroll bar. if (vert_edge_scroll_enabled_.GetValue()) - SetSynclientParam("VertEdgeScroll", "1"); + SetSynclientParam("VertEdgeScroll", 1); else - SetSynclientParam("VertEdgeScroll", "0"); + SetSynclientParam("VertEdgeScroll", 0); } void Touchpad::SetSpeedFactor() { // To set speed factor, we use MinSpeed. Both MaxSpeed and AccelFactor are 0. // So MinSpeed will control the speed of the cursor with respect to the // touchpad movement and there will not be any acceleration. - // We enforce that MinSpeed is between 0.01 and 1.00. - double value = speed_factor_.GetValue(); - if (value < 0.01) - value = 0.01; - if (value > 1.0) - value = 1.0; - SetSynclientParam("MinSpeed", StringPrintf("%f", value)); + // MinSpeed is between 0.01 and 1.00. The preference is an integer between + // 1 and 10, so we divide that by 10 for the value of MinSpeed. + int value = speed_factor_.GetValue(); + if (value < 1) + value = 1; + if (value > 10) + value = 10; + // Convert from 1-10 to 0.1-1.0 + double d = static_cast<double>(value) / 10.0; + SetSynclientParam("MinSpeed", d); +} + +void Touchpad::SetSensitivity() { + // To set the touch sensitivity, we use FingerHigh, which represents the + // the pressure needed for a tap to be registered. The range of FingerHigh + // goes from 30 to 75. We store the sensitivity preference as an int from + // 1 to 10. So we need to map the preference value of 1 to 10 to the + // FingerHigh value of 30 to 75. + int value = sensitivity_.GetValue(); + if (value < 1) + value = 1; + if (value > 10) + value = 10; + // Convert from 1-10 to 30-75. + double d = value * 5 + 25; + SetSynclientParam("FingerHigh", d); } diff --git a/chrome/browser/chromeos/touchpad.h b/chrome/browser/chromeos/touchpad.h index c4c783c..17171c3 100644 --- a/chrome/browser/chromeos/touchpad.h +++ b/chrome/browser/chromeos/touchpad.h @@ -43,20 +43,24 @@ class Touchpad : public NotificationObserver { private: // This methods makes a system call to synclient to change touchpad settings. // The system call will be invoked on the file thread. - void SetSynclientParam(const std::string& param, const std::string& value); + void SetSynclientParam(const std::string& param, double value); - // Set tap-to-click to value stored in preference. + // Set tap-to-click to value stored in preferences. void SetTapToClick(); - // Set vertical edge scrolling to value stored in preference. + // Set vertical edge scrolling to value stored in preferences. void SetVertEdgeScroll(); - // Set touchpad speed factor to value stored in preference. + // Set touchpad speed factor to value stored in preferences. void SetSpeedFactor(); + // Set tap sensitivity to value stored in preferences. + void SetSensitivity(); + BooleanPrefMember tap_to_click_enabled_; BooleanPrefMember vert_edge_scroll_enabled_; - RealPrefMember speed_factor_; + IntegerPrefMember speed_factor_; + IntegerPrefMember sensitivity_; DISALLOW_COPY_AND_ASSIGN(Touchpad); }; diff --git a/chrome/browser/options_util.cc b/chrome/browser/options_util.cc index 94bed68..764c0dc 100644 --- a/chrome/browser/options_util.cc +++ b/chrome/browser/options_util.cc @@ -34,6 +34,7 @@ void OptionsUtil::ResetToDefaults(Profile* profile) { prefs::kTapToClickEnabled, prefs::kVertEdgeScrollEnabled, prefs::kTouchpadSpeedFactor, + prefs::kTouchpadSensitivity, #endif prefs::kDownloadDefaultDirectory, prefs::kDownloadExtensionsToOpen, diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc index a5210e8..b1104da 100644 --- a/chrome/common/pref_names.cc +++ b/chrome/common/pref_names.cc @@ -190,8 +190,11 @@ extern const wchar_t kTapToClickEnabled[] = extern const wchar_t kVertEdgeScrollEnabled[] = L"settings.touchpad.enable_vert_edge_scroll"; -// A double pref for the touchpad speed factor. +// A integer pref for the touchpad speed factor. extern const wchar_t kTouchpadSpeedFactor[] = L"settings.touchpad.speed_factor"; + +// A integer pref for the touchpad sensitivity. +extern const wchar_t kTouchpadSensitivity[] = L"settings.touchpad.sensitivity"; #endif // The disabled messages in IPC logging. diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h index 7ec556a..01fb279 100644 --- a/chrome/common/pref_names.h +++ b/chrome/common/pref_names.h @@ -72,6 +72,7 @@ extern const wchar_t kTLS1Enabled[]; extern const wchar_t kTapToClickEnabled[]; extern const wchar_t kVertEdgeScrollEnabled[]; extern const wchar_t kTouchpadSpeedFactor[]; +extern const wchar_t kTouchpadSensitivity[]; #endif extern const wchar_t kIpcDisabledMessages[]; extern const wchar_t kShowHomeButton[]; |