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

Side by Side Diff: chrome/browser/chromeos/system/input_device_settings_impl_x11.cc

Issue 1412623006: Developer Feature: Add Debug Accelerators to Toggle Touchscreen/Touchpad On or Off (CrOS) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compile error 2 Created 5 years, 1 month 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/system/input_device_settings.h" 5 #include "chrome/browser/chromeos/system/input_device_settings.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/files/file_util.h" 13 #include "base/files/file_util.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/message_loop/message_loop.h" 15 #include "base/message_loop/message_loop.h"
16 #include "base/process/kill.h" 16 #include "base/process/kill.h"
17 #include "base/process/launch.h" 17 #include "base/process/launch.h"
18 #include "base/process/process_handle.h" 18 #include "base/process/process_handle.h"
19 #include "base/strings/string_util.h" 19 #include "base/strings/string_util.h"
20 #include "base/strings/stringprintf.h" 20 #include "base/strings/stringprintf.h"
21 #include "base/sys_info.h" 21 #include "base/sys_info.h"
22 #include "base/task_runner.h" 22 #include "base/task_runner.h"
23 #include "base/threading/sequenced_worker_pool.h" 23 #include "base/threading/sequenced_worker_pool.h"
24 #include "content/public/browser/browser_thread.h" 24 #include "content/public/browser/browser_thread.h"
25 #include "ui/events/devices/x11/device_data_manager_x11.h"
26 #include "ui/events/devices/x11/device_list_cache_x11.h"
27 #include "ui/gfx/x/x11_types.h"
25 28
26 namespace chromeos { 29 namespace chromeos {
27 namespace system { 30 namespace system {
28 31
29 namespace { 32 namespace {
30 33
31 InputDeviceSettings* g_instance = nullptr; 34 InputDeviceSettings* g_instance = nullptr;
32 InputDeviceSettings* g_test_instance = nullptr; 35 InputDeviceSettings* g_test_instance = nullptr;
33 36
34 const char kDeviceTypeTouchpad[] = "touchpad"; 37 const char kDeviceTypeTouchpad[] = "touchpad";
35 const char kDeviceTypeMouse[] = "mouse"; 38 const char kDeviceTypeMouse[] = "mouse";
36 const char kInputControl[] = "/opt/google/input/inputcontrol"; 39 const char kInputControl[] = "/opt/google/input/inputcontrol";
37 40
41 // The name of the xinput device corresponding to the internal touchpad.
42 const char kInternalTouchpadName[] = "Elan Touchpad";
43
38 typedef base::RefCountedData<bool> RefCountedBool; 44 typedef base::RefCountedData<bool> RefCountedBool;
39 45
40 bool ScriptExists(const std::string& script) { 46 bool ScriptExists(const std::string& script) {
41 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); 47 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
42 return base::PathExists(base::FilePath(script)); 48 return base::PathExists(base::FilePath(script));
43 } 49 }
44 50
45 // Executes the input control script asynchronously, if it exists. 51 // Executes the input control script asynchronously, if it exists.
46 void ExecuteScriptOnFileThread(const std::vector<std::string>& argv) { 52 void ExecuteScriptOnFileThread(const std::vector<std::string>& argv) {
47 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); 53 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 void SetTapToClick(bool enabled) override; 159 void SetTapToClick(bool enabled) override;
154 void SetThreeFingerClick(bool enabled) override; 160 void SetThreeFingerClick(bool enabled) override;
155 void SetTapDragging(bool enabled) override; 161 void SetTapDragging(bool enabled) override;
156 void SetNaturalScroll(bool enabled) override; 162 void SetNaturalScroll(bool enabled) override;
157 void MouseExists(const DeviceExistsCallback& callback) override; 163 void MouseExists(const DeviceExistsCallback& callback) override;
158 void UpdateMouseSettings(const MouseSettings& settings) override; 164 void UpdateMouseSettings(const MouseSettings& settings) override;
159 void SetMouseSensitivity(int value) override; 165 void SetMouseSensitivity(int value) override;
160 void SetPrimaryButtonRight(bool right) override; 166 void SetPrimaryButtonRight(bool right) override;
161 void ReapplyTouchpadSettings() override; 167 void ReapplyTouchpadSettings() override;
162 void ReapplyMouseSettings() override; 168 void ReapplyMouseSettings() override;
169 void SetInternalTouchpadEnabled(bool enabled) override;
163 170
164 // Generate arguments for the inputcontrol script. 171 // Generate arguments for the inputcontrol script.
165 // 172 //
166 // |argv| is filled with arguments of script, that should be launched in order 173 // |argv| is filled with arguments of script, that should be launched in order
167 // to apply update. 174 // to apply update.
168 void GenerateTouchpadArguments(std::vector<std::string>* argv); 175 void GenerateTouchpadArguments(std::vector<std::string>* argv);
169 void GenerateMouseArguments(std::vector<std::string>* argv); 176 void GenerateMouseArguments(std::vector<std::string>* argv);
170 177
171 TouchpadSettings current_touchpad_settings_; 178 TouchpadSettings current_touchpad_settings_;
172 MouseSettings current_mouse_settings_; 179 MouseSettings current_mouse_settings_;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 current_touchpad_settings_ = TouchpadSettings(); 261 current_touchpad_settings_ = TouchpadSettings();
255 UpdateTouchpadSettings(settings); 262 UpdateTouchpadSettings(settings);
256 } 263 }
257 264
258 void InputDeviceSettingsImplX11::ReapplyMouseSettings() { 265 void InputDeviceSettingsImplX11::ReapplyMouseSettings() {
259 MouseSettings settings = current_mouse_settings_; 266 MouseSettings settings = current_mouse_settings_;
260 current_mouse_settings_ = MouseSettings(); 267 current_mouse_settings_ = MouseSettings();
261 UpdateMouseSettings(settings); 268 UpdateMouseSettings(settings);
262 } 269 }
263 270
271 void InputDeviceSettingsImplX11::SetInternalTouchpadEnabled(bool enabled) {
272 ui::DeviceDataManagerX11* device_data_manager =
273 ui::DeviceDataManagerX11::GetInstance();
274 if (device_data_manager->IsXInput2Available()) {
sadrul 2015/11/03 19:09:26 early exit instead.
afakhry 2015/11/04 02:28:21 Done.
275 const XIDeviceList& xi_dev_list =
276 ui::DeviceListCacheX11::GetInstance()->GetXI2DeviceList(
277 gfx::GetXDisplay());
278 for (int i = 0; i < xi_dev_list.count; ++i) {
279 std::string device_name(xi_dev_list[i].name);
280 base::TrimWhitespaceASCII(device_name, base::TRIM_TRAILING, &device_name);
281 if (device_name == kInternalTouchpadName) {
282 if (enabled)
283 device_data_manager->EnableDevice(xi_dev_list[i].deviceid);
284 else
285 device_data_manager->DisableDevice(xi_dev_list[i].deviceid);
286
287 return;
288 }
289 }
290 }
291 }
292
264 void InputDeviceSettingsImplX11::GenerateTouchpadArguments( 293 void InputDeviceSettingsImplX11::GenerateTouchpadArguments(
265 std::vector<std::string>* argv) { 294 std::vector<std::string>* argv) {
266 argv->push_back(kInputControl); 295 argv->push_back(kInputControl);
267 if (current_touchpad_settings_.IsSensitivitySet()) { 296 if (current_touchpad_settings_.IsSensitivitySet()) {
268 AddSensitivityArguments(kDeviceTypeTouchpad, 297 AddSensitivityArguments(kDeviceTypeTouchpad,
269 current_touchpad_settings_.GetSensitivity(), argv); 298 current_touchpad_settings_.GetSensitivity(), argv);
270 } 299 }
271 if (current_touchpad_settings_.IsTapToClickSet()) { 300 if (current_touchpad_settings_.IsTapToClickSet()) {
272 AddTPControlArguments("tapclick", 301 AddTPControlArguments("tapclick",
273 current_touchpad_settings_.GetTapToClick(), argv); 302 current_touchpad_settings_.GetTapToClick(), argv);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 void InputDeviceSettings::SetSettingsForTesting( 344 void InputDeviceSettings::SetSettingsForTesting(
316 InputDeviceSettings* test_settings) { 345 InputDeviceSettings* test_settings) {
317 if (g_test_instance == test_settings) 346 if (g_test_instance == test_settings)
318 return; 347 return;
319 delete g_test_instance; 348 delete g_test_instance;
320 g_test_instance = test_settings; 349 g_test_instance = test_settings;
321 } 350 }
322 351
323 } // namespace system 352 } // namespace system
324 } // namespace chromeos 353 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698