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

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

Issue 2263693003: Add palm suppression feature to EventConverterEvdev (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@stylus
Patch Set: fixed unit tests Created 4 years, 3 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 #include <stddef.h> 9 #include <stddef.h>
10 10
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 const base::FilePath& path = converter->path(); 232 const base::FilePath& path = converter->path();
233 233
234 TRACE_EVENT1("evdev", "AttachInputDevice", "path", path.value()); 234 TRACE_EVENT1("evdev", "AttachInputDevice", "path", path.value());
235 DCHECK(task_runner_->RunsTasksOnCurrentThread()); 235 DCHECK(task_runner_->RunsTasksOnCurrentThread());
236 236
237 // If we have an existing device, detach it. We don't want two 237 // If we have an existing device, detach it. We don't want two
238 // devices with the same name open at the same time. 238 // devices with the same name open at the same time.
239 if (converters_[path]) 239 if (converters_[path])
240 DetachInputDevice(path); 240 DetachInputDevice(path);
241 241
242 if (converter->type() == InputDeviceType::INPUT_DEVICE_INTERNAL &&
243 converter->HasPen()) {
244 converter->SetPalmSuppressionCallback(
245 base::Bind(&InputDeviceFactoryEvdev::EnablePalmSuppression,
246 base::Unretained(this)));
247 }
248
242 // Add initialized device to map. 249 // Add initialized device to map.
243 converters_[path] = converter.release(); 250 converters_[path] = converter.release();
244 converters_[path]->Start(); 251 converters_[path]->Start();
245 UpdateDirtyFlags(converters_[path]); 252 UpdateDirtyFlags(converters_[path]);
246 253
247 // Sync settings to new device. 254 // Sync settings to new device.
248 ApplyInputDeviceSettings(); 255 ApplyInputDeviceSettings();
249 ApplyCapsLockLed(); 256 ApplyCapsLockLed();
250 } 257 }
251 258
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 const EventConverterEvdev* converter) { 376 const EventConverterEvdev* converter) {
370 if (!input_device_settings_.enable_internal_touchpad && 377 if (!input_device_settings_.enable_internal_touchpad &&
371 converter->type() == InputDeviceType::INPUT_DEVICE_INTERNAL && 378 converter->type() == InputDeviceType::INPUT_DEVICE_INTERNAL &&
372 converter->HasTouchpad()) 379 converter->HasTouchpad())
373 return false; 380 return false;
374 381
375 if (!input_device_settings_.enable_touch_screens && 382 if (!input_device_settings_.enable_touch_screens &&
376 converter->HasTouchscreen()) 383 converter->HasTouchscreen())
377 return false; 384 return false;
378 385
386 if (palm_suppression_enabled_ &&
387 converter->type() == InputDeviceType::INPUT_DEVICE_INTERNAL &&
388 converter->HasTouchscreen() && !converter->HasPen())
389 return false;
390
379 return input_device_settings_.enable_devices; 391 return input_device_settings_.enable_devices;
380 } 392 }
381 393
382 void InputDeviceFactoryEvdev::UpdateDirtyFlags( 394 void InputDeviceFactoryEvdev::UpdateDirtyFlags(
383 const EventConverterEvdev* converter) { 395 const EventConverterEvdev* converter) {
384 if (converter->HasTouchscreen()) 396 if (converter->HasTouchscreen())
385 touchscreen_list_dirty_ = true; 397 touchscreen_list_dirty_ = true;
386 398
387 if (converter->HasKeyboard()) 399 if (converter->HasKeyboard())
388 keyboard_list_dirty_ = true; 400 keyboard_list_dirty_ = true;
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 #if defined(USE_EVDEV_GESTURES) 496 #if defined(USE_EVDEV_GESTURES)
485 std::vector<int> ids; 497 std::vector<int> ids;
486 gesture_property_provider_->GetDeviceIdsByType(type, &ids); 498 gesture_property_provider_->GetDeviceIdsByType(type, &ids);
487 for (size_t i = 0; i < ids.size(); ++i) { 499 for (size_t i = 0; i < ids.size(); ++i) {
488 SetGestureBoolProperty(gesture_property_provider_.get(), ids[i], name, 500 SetGestureBoolProperty(gesture_property_provider_.get(), ids[i], name,
489 value); 501 value);
490 } 502 }
491 #endif 503 #endif
492 } 504 }
493 505
506 void InputDeviceFactoryEvdev::EnablePalmSuppression(bool enabled) {
507 if (enabled == palm_suppression_enabled_)
508 return;
509 palm_suppression_enabled_ = enabled;
510
511 for (const auto& it : converters_) {
512 it.second->SetEnabled(IsDeviceEnabled(it.second));
513 }
514 }
515
494 } // namespace ui 516 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/ozone/evdev/input_device_factory_evdev.h ('k') | ui/events/ozone/evdev/touch_evdev_types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698