Chromium Code Reviews| Index: chrome/browser/chromeos/system/input_device_settings_impl_x11.cc |
| diff --git a/chrome/browser/chromeos/system/input_device_settings_impl_x11.cc b/chrome/browser/chromeos/system/input_device_settings_impl_x11.cc |
| index b9be3aa079b6ff5f639939abf60e45f03c6e3a4b..7eebec2f368bf9c084fab2a81596bfa969d70e9e 100644 |
| --- a/chrome/browser/chromeos/system/input_device_settings_impl_x11.cc |
| +++ b/chrome/browser/chromeos/system/input_device_settings_impl_x11.cc |
| @@ -22,6 +22,9 @@ |
| #include "base/task_runner.h" |
| #include "base/threading/sequenced_worker_pool.h" |
| #include "content/public/browser/browser_thread.h" |
| +#include "ui/events/devices/x11/device_data_manager_x11.h" |
| +#include "ui/events/devices/x11/device_list_cache_x11.h" |
| +#include "ui/gfx/x/x11_types.h" |
| namespace chromeos { |
| namespace system { |
| @@ -35,6 +38,9 @@ const char kDeviceTypeTouchpad[] = "touchpad"; |
| const char kDeviceTypeMouse[] = "mouse"; |
| const char kInputControl[] = "/opt/google/input/inputcontrol"; |
| +// The name of the xinput device corresponding to the internal touchpad. |
| +const char kInternalTouchpadName[] = "Elan Touchpad"; |
| + |
| typedef base::RefCountedData<bool> RefCountedBool; |
| bool ScriptExists(const std::string& script) { |
| @@ -160,6 +166,7 @@ class InputDeviceSettingsImplX11 : public InputDeviceSettings { |
| void SetPrimaryButtonRight(bool right) override; |
| void ReapplyTouchpadSettings() override; |
| void ReapplyMouseSettings() override; |
| + void SetInternalTouchpadEnabled(bool enabled) override; |
| // Generate arguments for the inputcontrol script. |
| // |
| @@ -261,6 +268,28 @@ void InputDeviceSettingsImplX11::ReapplyMouseSettings() { |
| UpdateMouseSettings(settings); |
| } |
| +void InputDeviceSettingsImplX11::SetInternalTouchpadEnabled(bool enabled) { |
| + ui::DeviceDataManagerX11* device_data_manager = |
| + ui::DeviceDataManagerX11::GetInstance(); |
| + if (device_data_manager->IsXInput2Available()) { |
|
sadrul
2015/11/03 19:09:26
early exit instead.
afakhry
2015/11/04 02:28:21
Done.
|
| + const XIDeviceList& xi_dev_list = |
| + ui::DeviceListCacheX11::GetInstance()->GetXI2DeviceList( |
| + gfx::GetXDisplay()); |
| + for (int i = 0; i < xi_dev_list.count; ++i) { |
| + std::string device_name(xi_dev_list[i].name); |
| + base::TrimWhitespaceASCII(device_name, base::TRIM_TRAILING, &device_name); |
| + if (device_name == kInternalTouchpadName) { |
| + if (enabled) |
| + device_data_manager->EnableDevice(xi_dev_list[i].deviceid); |
| + else |
| + device_data_manager->DisableDevice(xi_dev_list[i].deviceid); |
| + |
| + return; |
| + } |
| + } |
| + } |
| +} |
| + |
| void InputDeviceSettingsImplX11::GenerateTouchpadArguments( |
| std::vector<std::string>* argv) { |
| argv->push_back(kInputControl); |