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

Side by Side Diff: ui/events/device_data_manager.cc

Issue 618283003: Adds special support to the device manager for keyboards devices. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change in ozone. Created 6 years, 2 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 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/device_data_manager.h" 5 #include "ui/events/device_data_manager.h"
6 6
7 #include "base/at_exit.h" 7 #include "base/at_exit.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "ui/events/input_device_event_observer.h" 10 #include "ui/events/input_device_event_observer.h"
11 #include "ui/gfx/display.h" 11 #include "ui/gfx/display.h"
12 #include "ui/gfx/geometry/point3_f.h" 12 #include "ui/gfx/geometry/point3_f.h"
13 13
14 namespace ui { 14 namespace ui {
15 15
16 namespace {
17
18 bool TouchscreenEquals(const ui::TouchscreenDevice& a,
19 const ui::TouchscreenDevice& b) {
20 return a.id == b.id;
21 }
22
23 bool KeyboardEquals(const ui::KeyboardDevice& a,
24 const ui::KeyboardDevice& b) {
25 return a.id == b.id;
26 }
flackr 2014/10/06 18:31:11 Can this not be done with a single InputDeviceEqua
rsadam 2014/10/06 19:38:01 Done.
27
28 } // namespace
29
16 // static 30 // static
17 DeviceDataManager* DeviceDataManager::instance_ = NULL; 31 DeviceDataManager* DeviceDataManager::instance_ = NULL;
18 32
19 DeviceDataManager::DeviceDataManager() { 33 DeviceDataManager::DeviceDataManager() {
20 CHECK(!instance_) << "Can not create multiple instances of DeviceDataManager"; 34 CHECK(!instance_) << "Can not create multiple instances of DeviceDataManager";
21 instance_ = this; 35 instance_ = this;
22 36
23 base::AtExitManager::RegisterTask( 37 base::AtExitManager::RegisterTask(
24 base::Bind(&base::DeletePointer<DeviceDataManager>, this)); 38 base::Bind(&base::DeletePointer<DeviceDataManager>, this));
25 39
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 } 118 }
105 119
106 int64_t DeviceDataManager::GetDisplayForTouchDevice(int touch_device_id) const { 120 int64_t DeviceDataManager::GetDisplayForTouchDevice(int touch_device_id) const {
107 if (IsTouchDeviceIdValid(touch_device_id)) 121 if (IsTouchDeviceIdValid(touch_device_id))
108 return touch_device_to_display_map_[touch_device_id]; 122 return touch_device_to_display_map_[touch_device_id];
109 return gfx::Display::kInvalidDisplayID; 123 return gfx::Display::kInvalidDisplayID;
110 } 124 }
111 125
112 void DeviceDataManager::OnTouchscreenDevicesUpdated( 126 void DeviceDataManager::OnTouchscreenDevicesUpdated(
113 const std::vector<TouchscreenDevice>& devices) { 127 const std::vector<TouchscreenDevice>& devices) {
128 if (devices.size() == touchscreen_devices_.size() &&
129 std::equal(devices.begin(), devices.end(),
130 touchscreen_devices_.begin(), TouchscreenEquals)) {
131 return;
132 }
114 touchscreen_devices_ = devices; 133 touchscreen_devices_ = devices;
134 FOR_EACH_OBSERVER(InputDeviceEventObserver,
135 observers_,
136 OnTouchscreenDeviceConfigurationChanged());
137 }
115 138
139 void DeviceDataManager::OnKeyboardDevicesUpdated(
140 const std::vector<KeyboardDevice>& devices) {
141 if (devices.size() == keyboard_devices_.size() &&
142 std::equal(devices.begin(), devices.end(),
143 keyboard_devices_.begin(), KeyboardEquals)) {
144 return;
145 }
146 keyboard_devices_ = devices;
116 FOR_EACH_OBSERVER(InputDeviceEventObserver, 147 FOR_EACH_OBSERVER(InputDeviceEventObserver,
117 observers_, 148 observers_,
118 OnInputDeviceConfigurationChanged()); 149 OnKeyboardDeviceConfigurationChanged());
119 } 150 }
120 151
121 void DeviceDataManager::AddObserver(InputDeviceEventObserver* observer) { 152 void DeviceDataManager::AddObserver(InputDeviceEventObserver* observer) {
122 observers_.AddObserver(observer); 153 observers_.AddObserver(observer);
123 } 154 }
124 155
125 void DeviceDataManager::RemoveObserver(InputDeviceEventObserver* observer) { 156 void DeviceDataManager::RemoveObserver(InputDeviceEventObserver* observer) {
126 observers_.RemoveObserver(observer); 157 observers_.RemoveObserver(observer);
127 } 158 }
128 159
129 } // namespace ui 160 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698