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

Side by Side Diff: ui/events/ozone/evdev/input_device_factory_evdev.cc

Issue 956793002: ozone: evdev: Keep track of settings & apply to new devices (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2311
Patch Set: Created 5 years, 10 months 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "ui/events/ozone/evdev/input_device_factory_evdev.h" 5 #include "ui/events/ozone/evdev/input_device_factory_evdev.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <linux/input.h> 8 #include <linux/input.h>
9 9
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 311
312 // If we have an existing device, detach it. We don't want two 312 // If we have an existing device, detach it. We don't want two
313 // devices with the same name open at the same time. 313 // devices with the same name open at the same time.
314 if (converters_[path]) 314 if (converters_[path])
315 DetachInputDevice(path); 315 DetachInputDevice(path);
316 316
317 // Add initialized device to map. 317 // Add initialized device to map.
318 converters_[path] = converter.release(); 318 converters_[path] = converter.release();
319 converters_[path]->Start(); 319 converters_[path]->Start();
320 UpdateDirtyFlags(converters_[path]); 320 UpdateDirtyFlags(converters_[path]);
321
322 // Sync settings to new device.
323 ApplyInputDeviceSettings();
321 } 324 }
322 325
323 if (--pending_device_changes_ == 0) 326 if (--pending_device_changes_ == 0)
324 NotifyDevicesUpdated(); 327 NotifyDevicesUpdated();
325 } 328 }
326 329
327 void InputDeviceFactoryEvdev::DetachInputDevice(const base::FilePath& path) { 330 void InputDeviceFactoryEvdev::DetachInputDevice(const base::FilePath& path) {
328 TRACE_EVENT1("ozone", "DetachInputDevice", "path", path.value()); 331 TRACE_EVENT1("ozone", "DetachInputDevice", "path", path.value());
329 DCHECK(task_runner_->RunsTasksOnCurrentThread()); 332 DCHECK(task_runner_->RunsTasksOnCurrentThread());
330 333
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 void InputDeviceFactoryEvdev::EnableInternalKeyboard() { 386 void InputDeviceFactoryEvdev::EnableInternalKeyboard() {
384 for (const auto& it : converters_) { 387 for (const auto& it : converters_) {
385 EventConverterEvdev* converter = it.second; 388 EventConverterEvdev* converter = it.second;
386 if (converter->type() == InputDeviceType::INPUT_DEVICE_INTERNAL && 389 if (converter->type() == InputDeviceType::INPUT_DEVICE_INTERNAL &&
387 converter->HasKeyboard()) { 390 converter->HasKeyboard()) {
388 converter->AllowAllKeys(); 391 converter->AllowAllKeys();
389 } 392 }
390 } 393 }
391 } 394 }
392 395
393 void InputDeviceFactoryEvdev::SetTouchpadSensitivity(int value) { 396 void InputDeviceFactoryEvdev::UpdateInputDeviceSettings(
394 SetIntPropertyForOneType(DT_TOUCHPAD, "Pointer Sensitivity", value); 397 const InputDeviceSettingsEvdev& settings) {
395 SetIntPropertyForOneType(DT_TOUCHPAD, "Scroll Sensitivity", value); 398 input_device_settings_ = settings;
396 } 399 ApplyInputDeviceSettings();
397
398 void InputDeviceFactoryEvdev::SetTapToClick(bool enabled) {
399 SetBoolPropertyForOneType(DT_TOUCHPAD, "Tap Enable", enabled);
400 }
401
402 void InputDeviceFactoryEvdev::SetThreeFingerClick(bool enabled) {
403 SetBoolPropertyForOneType(DT_TOUCHPAD, "T5R2 Three Finger Click Enable",
404 enabled);
405 }
406
407 void InputDeviceFactoryEvdev::SetTapDragging(bool enabled) {
408 SetBoolPropertyForOneType(DT_TOUCHPAD, "Tap Drag Enable", enabled);
409 }
410
411 void InputDeviceFactoryEvdev::SetNaturalScroll(bool enabled) {
412 SetBoolPropertyForOneType(DT_MULTITOUCH, "Australian Scrolling", enabled);
413 }
414
415 void InputDeviceFactoryEvdev::SetMouseSensitivity(int value) {
416 SetIntPropertyForOneType(DT_MOUSE, "Pointer Sensitivity", value);
417 SetIntPropertyForOneType(DT_MOUSE, "Scroll Sensitivity", value);
418 }
419
420 void InputDeviceFactoryEvdev::SetTapToClickPaused(bool state) {
421 SetBoolPropertyForOneType(DT_TOUCHPAD, "Tap Paused", state);
422 } 400 }
423 401
424 void InputDeviceFactoryEvdev::GetTouchDeviceStatus( 402 void InputDeviceFactoryEvdev::GetTouchDeviceStatus(
425 const GetTouchDeviceStatusReply& reply) { 403 const GetTouchDeviceStatusReply& reply) {
426 scoped_ptr<std::string> status(new std::string); 404 scoped_ptr<std::string> status(new std::string);
427 #if defined(USE_EVDEV_GESTURES) 405 #if defined(USE_EVDEV_GESTURES)
428 DumpTouchDeviceStatus(gesture_property_provider_.get(), status.get()); 406 DumpTouchDeviceStatus(gesture_property_provider_.get(), status.get());
429 #endif 407 #endif
430 reply.Run(status.Pass()); 408 reply.Run(status.Pass());
431 } 409 }
432 410
433 base::WeakPtr<InputDeviceFactoryEvdev> InputDeviceFactoryEvdev::GetWeakPtr() { 411 base::WeakPtr<InputDeviceFactoryEvdev> InputDeviceFactoryEvdev::GetWeakPtr() {
434 return weak_ptr_factory_.GetWeakPtr(); 412 return weak_ptr_factory_.GetWeakPtr();
435 } 413 }
436 414
415 void InputDeviceFactoryEvdev::ApplyInputDeviceSettings() {
416 SetIntPropertyForOneType(DT_TOUCHPAD, "Pointer Sensitivity",
417 input_device_settings_.touchpad_sensitivity);
418 SetIntPropertyForOneType(DT_TOUCHPAD, "Scroll Sensitivity",
419 input_device_settings_.touchpad_sensitivity);
420
421 SetBoolPropertyForOneType(DT_TOUCHPAD, "Tap Enable",
422 input_device_settings_.tap_to_click_enabled);
423 SetBoolPropertyForOneType(DT_TOUCHPAD, "T5R2 Three Finger Click Enable",
424 input_device_settings_.three_finger_click_enabled);
425 SetBoolPropertyForOneType(DT_TOUCHPAD, "Tap Drag Enable",
426 input_device_settings_.tap_dragging_enabled);
427
428 SetBoolPropertyForOneType(DT_MULTITOUCH, "Australian Scrolling",
429 input_device_settings_.natural_scroll_enabled);
430
431 SetIntPropertyForOneType(DT_MOUSE, "Pointer Sensitivity",
432 input_device_settings_.mouse_sensitivity);
433 SetIntPropertyForOneType(DT_MOUSE, "Scroll Sensitivity",
434 input_device_settings_.mouse_sensitivity);
435
436 SetBoolPropertyForOneType(DT_TOUCHPAD, "Tap Paused",
437 input_device_settings_.tap_to_click_paused);
438 }
439
437 void InputDeviceFactoryEvdev::UpdateDirtyFlags( 440 void InputDeviceFactoryEvdev::UpdateDirtyFlags(
438 const EventConverterEvdev* converter) { 441 const EventConverterEvdev* converter) {
439 if (converter->HasTouchscreen()) 442 if (converter->HasTouchscreen())
440 touchscreen_list_dirty_ = true; 443 touchscreen_list_dirty_ = true;
441 444
442 if (converter->HasKeyboard()) 445 if (converter->HasKeyboard())
443 keyboard_list_dirty_ = true; 446 keyboard_list_dirty_ = true;
444 447
445 if (converter->HasMouse()) 448 if (converter->HasMouse())
446 mouse_list_dirty_ = true; 449 mouse_list_dirty_ = true;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 std::vector<int> ids; 536 std::vector<int> ids;
534 gesture_property_provider_->GetDeviceIdsByType(type, &ids); 537 gesture_property_provider_->GetDeviceIdsByType(type, &ids);
535 for (size_t i = 0; i < ids.size(); ++i) { 538 for (size_t i = 0; i < ids.size(); ++i) {
536 SetGestureBoolProperty(gesture_property_provider_.get(), ids[i], name, 539 SetGestureBoolProperty(gesture_property_provider_.get(), ids[i], name,
537 value); 540 value);
538 } 541 }
539 #endif 542 #endif
540 } 543 }
541 544
542 } // namespace ui 545 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/ozone/evdev/input_device_factory_evdev.h ('k') | ui/events/ozone/evdev/input_device_factory_evdev_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698