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

Side by Side Diff: ui/events/platform/x11/x11_hotplug_event_handler.cc

Issue 2019413002: Remove KeyboardDevice class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes for comments. Created 4 years, 6 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
« no previous file with comments | « ui/events/ozone/evdev/touch_event_converter_evdev_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "ui/events/platform/x11/x11_hotplug_event_handler.h" 5 #include "ui/events/platform/x11/x11_hotplug_event_handler.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <X11/extensions/XInput.h> 8 #include <X11/extensions/XInput.h>
9 #include <X11/extensions/XInput2.h> 9 #include <X11/extensions/XInput2.h>
10 #include <X11/Xatom.h> 10 #include <X11/Xatom.h>
(...skipping 11 matching lines...) Expand all
22 #include "base/process/launch.h" 22 #include "base/process/launch.h"
23 #include "base/single_thread_task_runner.h" 23 #include "base/single_thread_task_runner.h"
24 #include "base/strings/string_util.h" 24 #include "base/strings/string_util.h"
25 #include "base/sys_info.h" 25 #include "base/sys_info.h"
26 #include "base/threading/thread_task_runner_handle.h" 26 #include "base/threading/thread_task_runner_handle.h"
27 #include "base/threading/worker_pool.h" 27 #include "base/threading/worker_pool.h"
28 #include "ui/events/devices/device_data_manager.h" 28 #include "ui/events/devices/device_data_manager.h"
29 #include "ui/events/devices/device_hotplug_event_observer.h" 29 #include "ui/events/devices/device_hotplug_event_observer.h"
30 #include "ui/events/devices/device_util_linux.h" 30 #include "ui/events/devices/device_util_linux.h"
31 #include "ui/events/devices/input_device.h" 31 #include "ui/events/devices/input_device.h"
32 #include "ui/events/devices/keyboard_device.h"
33 #include "ui/events/devices/touchscreen_device.h" 32 #include "ui/events/devices/touchscreen_device.h"
34 #include "ui/gfx/x/x11_types.h" 33 #include "ui/gfx/x/x11_types.h"
35 34
36 #ifndef XI_PROP_PRODUCT_ID 35 #ifndef XI_PROP_PRODUCT_ID
37 #define XI_PROP_PRODUCT_ID "Device Product ID" 36 #define XI_PROP_PRODUCT_ID "Device Product ID"
38 #endif 37 #endif
39 38
40 namespace ui { 39 namespace ui {
41 40
42 namespace { 41 namespace {
(...skipping 20 matching lines...) Expand all
63 }; 62 };
64 63
65 enum DeviceType { 64 enum DeviceType {
66 DEVICE_TYPE_KEYBOARD, 65 DEVICE_TYPE_KEYBOARD,
67 DEVICE_TYPE_MOUSE, 66 DEVICE_TYPE_MOUSE,
68 DEVICE_TYPE_TOUCHPAD, 67 DEVICE_TYPE_TOUCHPAD,
69 DEVICE_TYPE_TOUCHSCREEN, 68 DEVICE_TYPE_TOUCHSCREEN,
70 DEVICE_TYPE_OTHER 69 DEVICE_TYPE_OTHER
71 }; 70 };
72 71
73 typedef base::Callback<void(const std::vector<KeyboardDevice>&)> 72 typedef base::Callback<void(const std::vector<InputDevice>&)>
74 KeyboardDeviceCallback; 73 KeyboardDeviceCallback;
75 74
76 typedef base::Callback<void(const std::vector<TouchscreenDevice>&)> 75 typedef base::Callback<void(const std::vector<TouchscreenDevice>&)>
77 TouchscreenDeviceCallback; 76 TouchscreenDeviceCallback;
78 77
79 typedef base::Callback<void(const std::vector<InputDevice>&)> 78 typedef base::Callback<void(const std::vector<InputDevice>&)>
80 InputDeviceCallback; 79 InputDeviceCallback;
81 80
82 // Used for updating the state on the UI thread once device information is 81 // Used for updating the state on the UI thread once device information is
83 // parsed on helper threads. 82 // parsed on helper threads.
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 244
246 return base::FilePath(path); 245 return base::FilePath(path);
247 } 246 }
248 247
249 // Helper used to parse keyboard information. When it is done it uses 248 // Helper used to parse keyboard information. When it is done it uses
250 // |reply_runner| and |callback| to update the state on the UI thread. 249 // |reply_runner| and |callback| to update the state on the UI thread.
251 void HandleKeyboardDevicesInWorker( 250 void HandleKeyboardDevicesInWorker(
252 const std::vector<DeviceInfo>& device_infos, 251 const std::vector<DeviceInfo>& device_infos,
253 scoped_refptr<base::TaskRunner> reply_runner, 252 scoped_refptr<base::TaskRunner> reply_runner,
254 const KeyboardDeviceCallback& callback) { 253 const KeyboardDeviceCallback& callback) {
255 std::vector<KeyboardDevice> devices; 254 std::vector<InputDevice> devices;
256 255
257 for (const DeviceInfo& device_info : device_infos) { 256 for (const DeviceInfo& device_info : device_infos) {
258 if (device_info.type != DEVICE_TYPE_KEYBOARD) 257 if (device_info.type != DEVICE_TYPE_KEYBOARD)
259 continue; 258 continue;
260 if (device_info.use != XISlaveKeyboard) 259 if (device_info.use != XISlaveKeyboard)
261 continue; // Assume all keyboards are keyboard slaves 260 continue; // Assume all keyboards are keyboard slaves
262 if (IsKnownInvalidKeyboardDevice(device_info.name)) 261 if (IsKnownInvalidKeyboardDevice(device_info.name))
263 continue; // Skip invalid devices. 262 continue; // Skip invalid devices.
264 InputDeviceType type = GetInputDeviceTypeFromPath(device_info.path); 263 InputDeviceType type = GetInputDeviceTypeFromPath(device_info.path);
265 KeyboardDevice keyboard(device_info.id, type, device_info.name); 264 InputDevice keyboard(device_info.id, type, device_info.name);
266 devices.push_back(keyboard); 265 devices.push_back(keyboard);
267 } 266 }
268 267
269 reply_runner->PostTask(FROM_HERE, base::Bind(callback, devices)); 268 reply_runner->PostTask(FROM_HERE, base::Bind(callback, devices));
270 } 269 }
271 270
272 // Helper used to parse mouse information. When it is done it uses 271 // Helper used to parse mouse information. When it is done it uses
273 // |reply_runner| and |callback| to update the state on the UI thread. 272 // |reply_runner| and |callback| to update the state on the UI thread.
274 void HandleMouseDevicesInWorker(const std::vector<DeviceInfo>& device_infos, 273 void HandleMouseDevicesInWorker(const std::vector<DeviceInfo>& device_infos,
275 scoped_refptr<base::TaskRunner> reply_runner, 274 scoped_refptr<base::TaskRunner> reply_runner,
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 HandleMouseDevicesInWorker(devices, reply_runner, callbacks.mouse_callback); 376 HandleMouseDevicesInWorker(devices, reply_runner, callbacks.mouse_callback);
378 HandleTouchpadDevicesInWorker(devices, reply_runner, 377 HandleTouchpadDevicesInWorker(devices, reply_runner,
379 callbacks.touchpad_callback); 378 callbacks.touchpad_callback);
380 reply_runner->PostTask(FROM_HERE, callbacks.hotplug_finished_callback); 379 reply_runner->PostTask(FROM_HERE, callbacks.hotplug_finished_callback);
381 } 380 }
382 381
383 DeviceHotplugEventObserver* GetHotplugEventObserver() { 382 DeviceHotplugEventObserver* GetHotplugEventObserver() {
384 return DeviceDataManager::GetInstance(); 383 return DeviceDataManager::GetInstance();
385 } 384 }
386 385
387 void OnKeyboardDevices(const std::vector<KeyboardDevice>& devices) { 386 void OnKeyboardDevices(const std::vector<InputDevice>& devices) {
388 GetHotplugEventObserver()->OnKeyboardDevicesUpdated(devices); 387 GetHotplugEventObserver()->OnKeyboardDevicesUpdated(devices);
389 } 388 }
390 389
391 void OnTouchscreenDevices(const std::vector<TouchscreenDevice>& devices) { 390 void OnTouchscreenDevices(const std::vector<TouchscreenDevice>& devices) {
392 GetHotplugEventObserver()->OnTouchscreenDevicesUpdated(devices); 391 GetHotplugEventObserver()->OnTouchscreenDevicesUpdated(devices);
393 } 392 }
394 393
395 void OnMouseDevices(const std::vector<InputDevice>& devices) { 394 void OnMouseDevices(const std::vector<InputDevice>& devices) {
396 GetHotplugEventObserver()->OnMouseDevicesUpdated(devices); 395 GetHotplugEventObserver()->OnMouseDevicesUpdated(devices);
397 } 396 }
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 // worker thread. Once the device information is extracted the parsed devices 493 // worker thread. Once the device information is extracted the parsed devices
495 // will be returned via the callbacks. 494 // will be returned via the callbacks.
496 base::WorkerPool::PostTask( 495 base::WorkerPool::PostTask(
497 FROM_HERE, 496 FROM_HERE,
498 base::Bind(&HandleHotplugEventInWorker, device_infos, display_state, 497 base::Bind(&HandleHotplugEventInWorker, device_infos, display_state,
499 base::ThreadTaskRunnerHandle::Get(), callbacks), 498 base::ThreadTaskRunnerHandle::Get(), callbacks),
500 true /* task_is_slow */); 499 true /* task_is_slow */);
501 } 500 }
502 501
503 } // namespace ui 502 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/ozone/evdev/touch_event_converter_evdev_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698