summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/chromeos/settings_contents_view.cc34
-rw-r--r--chrome/browser/chromeos/touchpad.cc53
-rw-r--r--chrome/browser/chromeos/touchpad.h14
-rw-r--r--chrome/browser/options_util.cc1
4 files changed, 77 insertions, 25 deletions
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,