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

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

Issue 2474163003: Remove stl_util's deletion function use from ui/. (Closed)
Patch Set: braces Created 4 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 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
11 #include <utility> 11 #include <utility>
12 12
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "base/stl_util.h"
15 #include "base/threading/thread_task_runner_handle.h" 14 #include "base/threading/thread_task_runner_handle.h"
16 #include "base/threading/worker_pool.h" 15 #include "base/threading/worker_pool.h"
17 #include "base/time/time.h" 16 #include "base/time/time.h"
18 #include "base/trace_event/trace_event.h" 17 #include "base/trace_event/trace_event.h"
19 #include "ui/events/devices/device_data_manager.h" 18 #include "ui/events/devices/device_data_manager.h"
20 #include "ui/events/devices/device_util_linux.h" 19 #include "ui/events/devices/device_util_linux.h"
21 #include "ui/events/ozone/evdev/device_event_dispatcher_evdev.h" 20 #include "ui/events/ozone/evdev/device_event_dispatcher_evdev.h"
22 #include "ui/events/ozone/evdev/event_converter_evdev_impl.h" 21 #include "ui/events/ozone/evdev/event_converter_evdev_impl.h"
23 #include "ui/events/ozone/evdev/event_device_info.h" 22 #include "ui/events/ozone/evdev/event_device_info.h"
24 #include "ui/events/ozone/evdev/tablet_event_converter_evdev.h" 23 #include "ui/events/ozone/evdev/tablet_event_converter_evdev.h"
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 : task_runner_(base::ThreadTaskRunnerHandle::Get()), 153 : task_runner_(base::ThreadTaskRunnerHandle::Get()),
155 cursor_(cursor), 154 cursor_(cursor),
156 #if defined(USE_EVDEV_GESTURES) 155 #if defined(USE_EVDEV_GESTURES)
157 gesture_property_provider_(new GesturePropertyProvider), 156 gesture_property_provider_(new GesturePropertyProvider),
158 #endif 157 #endif
159 dispatcher_(std::move(dispatcher)), 158 dispatcher_(std::move(dispatcher)),
160 weak_ptr_factory_(this) { 159 weak_ptr_factory_(this) {
161 } 160 }
162 161
163 InputDeviceFactoryEvdev::~InputDeviceFactoryEvdev() { 162 InputDeviceFactoryEvdev::~InputDeviceFactoryEvdev() {
164 base::STLDeleteValues(&converters_);
165 } 163 }
166 164
167 void InputDeviceFactoryEvdev::AddInputDevice(int id, 165 void InputDeviceFactoryEvdev::AddInputDevice(int id,
168 const base::FilePath& path) { 166 const base::FilePath& path) {
169 OpenInputDeviceParams params; 167 OpenInputDeviceParams params;
170 params.id = id; 168 params.id = id;
171 params.path = path; 169 params.path = path;
172 params.cursor = cursor_; 170 params.cursor = cursor_;
173 params.dispatcher = dispatcher_.get(); 171 params.dispatcher = dispatcher_.get();
174 172
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 DetachInputDevice(path); 207 DetachInputDevice(path);
210 208
211 if (converter->type() == InputDeviceType::INPUT_DEVICE_INTERNAL && 209 if (converter->type() == InputDeviceType::INPUT_DEVICE_INTERNAL &&
212 converter->HasPen()) { 210 converter->HasPen()) {
213 converter->SetPalmSuppressionCallback( 211 converter->SetPalmSuppressionCallback(
214 base::Bind(&InputDeviceFactoryEvdev::EnablePalmSuppression, 212 base::Bind(&InputDeviceFactoryEvdev::EnablePalmSuppression,
215 base::Unretained(this))); 213 base::Unretained(this)));
216 } 214 }
217 215
218 // Add initialized device to map. 216 // Add initialized device to map.
219 converters_[path] = converter.release(); 217 converters_[path] = std::move(converter);
220 converters_[path]->Start(); 218 converters_[path]->Start();
221 UpdateDirtyFlags(converters_[path]); 219 UpdateDirtyFlags(converters_[path].get());
222 220
223 // Sync settings to new device. 221 // Sync settings to new device.
224 ApplyInputDeviceSettings(); 222 ApplyInputDeviceSettings();
225 ApplyCapsLockLed(); 223 ApplyCapsLockLed();
226 } 224 }
227 225
228 --pending_device_changes_; 226 --pending_device_changes_;
229 NotifyDevicesUpdated(); 227 NotifyDevicesUpdated();
230 } 228 }
231 229
232 void InputDeviceFactoryEvdev::DetachInputDevice(const base::FilePath& path) { 230 void InputDeviceFactoryEvdev::DetachInputDevice(const base::FilePath& path) {
233 TRACE_EVENT1("evdev", "DetachInputDevice", "path", path.value()); 231 TRACE_EVENT1("evdev", "DetachInputDevice", "path", path.value());
234 DCHECK(task_runner_->RunsTasksOnCurrentThread()); 232 DCHECK(task_runner_->RunsTasksOnCurrentThread());
235 233
236 // Remove device from map. 234 // Remove device from map.
237 std::unique_ptr<EventConverterEvdev> converter(converters_[path]); 235 std::unique_ptr<EventConverterEvdev> converter = std::move(converters_[path]);
238 converters_.erase(path); 236 converters_.erase(path);
239 237
240 if (converter) { 238 if (converter) {
241 // Disable the device (to release keys/buttons/etc). 239 // Disable the device (to release keys/buttons/etc).
242 converter->SetEnabled(false); 240 converter->SetEnabled(false);
243 241
244 // Cancel libevent notifications from this converter. 242 // Cancel libevent notifications from this converter.
245 converter->Stop(); 243 converter->Stop();
246 244
247 UpdateDirtyFlags(converter.get()); 245 UpdateDirtyFlags(converter.get());
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 304
307 SetIntPropertyForOneType(DT_MOUSE, "Pointer Sensitivity", 305 SetIntPropertyForOneType(DT_MOUSE, "Pointer Sensitivity",
308 input_device_settings_.mouse_sensitivity); 306 input_device_settings_.mouse_sensitivity);
309 SetIntPropertyForOneType(DT_MOUSE, "Scroll Sensitivity", 307 SetIntPropertyForOneType(DT_MOUSE, "Scroll Sensitivity",
310 input_device_settings_.mouse_sensitivity); 308 input_device_settings_.mouse_sensitivity);
311 309
312 SetBoolPropertyForOneType(DT_TOUCHPAD, "Tap Paused", 310 SetBoolPropertyForOneType(DT_TOUCHPAD, "Tap Paused",
313 input_device_settings_.tap_to_click_paused); 311 input_device_settings_.tap_to_click_paused);
314 312
315 for (const auto& it : converters_) { 313 for (const auto& it : converters_) {
316 EventConverterEvdev* converter = it.second; 314 EventConverterEvdev* converter = it.second.get();
317 converter->SetEnabled(IsDeviceEnabled(converter)); 315 converter->SetEnabled(IsDeviceEnabled(converter));
318 316
319 if (converter->type() == InputDeviceType::INPUT_DEVICE_INTERNAL && 317 if (converter->type() == InputDeviceType::INPUT_DEVICE_INTERNAL &&
320 converter->HasKeyboard()) { 318 converter->HasKeyboard()) {
321 converter->SetKeyFilter( 319 converter->SetKeyFilter(
322 input_device_settings_.enable_internal_keyboard_filter, 320 input_device_settings_.enable_internal_keyboard_filter,
323 input_device_settings_.internal_keyboard_allowed_keys); 321 input_device_settings_.internal_keyboard_allowed_keys);
324 } 322 }
325 323
326 converter->SetTouchEventLoggingEnabled( 324 converter->SetTouchEventLoggingEnabled(
327 input_device_settings_.touch_event_logging_enabled); 325 input_device_settings_.touch_event_logging_enabled);
328 } 326 }
329 } 327 }
330 328
331 void InputDeviceFactoryEvdev::ApplyCapsLockLed() { 329 void InputDeviceFactoryEvdev::ApplyCapsLockLed() {
332 for (const auto& it : converters_) { 330 for (const auto& it : converters_) {
333 EventConverterEvdev* converter = it.second; 331 EventConverterEvdev* converter = it.second.get();
334 converter->SetCapsLockLed(caps_lock_led_enabled_); 332 converter->SetCapsLockLed(caps_lock_led_enabled_);
335 } 333 }
336 } 334 }
337 335
338 bool InputDeviceFactoryEvdev::IsDeviceEnabled( 336 bool InputDeviceFactoryEvdev::IsDeviceEnabled(
339 const EventConverterEvdev* converter) { 337 const EventConverterEvdev* converter) {
340 if (!input_device_settings_.enable_internal_touchpad && 338 if (!input_device_settings_.enable_internal_touchpad &&
341 converter->type() == InputDeviceType::INPUT_DEVICE_INTERNAL && 339 converter->type() == InputDeviceType::INPUT_DEVICE_INTERNAL &&
342 converter->HasTouchpad()) 340 converter->HasTouchpad())
343 return false; 341 return false;
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 } 466 }
469 #endif 467 #endif
470 } 468 }
471 469
472 void InputDeviceFactoryEvdev::EnablePalmSuppression(bool enabled) { 470 void InputDeviceFactoryEvdev::EnablePalmSuppression(bool enabled) {
473 if (enabled == palm_suppression_enabled_) 471 if (enabled == palm_suppression_enabled_)
474 return; 472 return;
475 palm_suppression_enabled_ = enabled; 473 palm_suppression_enabled_ = enabled;
476 474
477 for (const auto& it : converters_) { 475 for (const auto& it : converters_) {
478 it.second->SetEnabled(IsDeviceEnabled(it.second)); 476 it.second->SetEnabled(IsDeviceEnabled(it.second.get()));
479 } 477 }
480 } 478 }
481 479
482 } // namespace ui 480 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/ozone/evdev/input_device_factory_evdev.h ('k') | ui/events/ozone/evdev/libgestures_glue/gesture_feedback.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698