OLD | NEW |
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/devices/x11/device_data_manager_x11.h" | 5 #include "ui/events/devices/x11/device_data_manager_x11.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.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/Xlib.h> | 10 #include <X11/Xlib.h> |
11 | 11 |
12 #include <utility> | 12 #include <utility> |
13 | 13 |
14 #include "base/bind.h" | 14 #include "base/bind.h" |
15 #include "base/bind_helpers.h" | 15 #include "base/bind_helpers.h" |
16 #include "base/command_line.h" | 16 #include "base/command_line.h" |
17 #include "base/logging.h" | 17 #include "base/logging.h" |
18 #include "base/macros.h" | 18 #include "base/macros.h" |
19 #include "base/memory/singleton.h" | 19 #include "base/memory/singleton.h" |
20 #include "base/sys_info.h" | 20 #include "base/sys_info.h" |
21 #include "build/build_config.h" | 21 #include "build/build_config.h" |
22 #include "ui/display/display.h" | 22 #include "ui/display/display.h" |
23 #include "ui/events/devices/x11/device_list_cache_x11.h" | 23 #include "ui/events/devices/x11/device_list_cache_x11.h" |
24 #include "ui/events/devices/x11/touch_factory_x11.h" | 24 #include "ui/events/devices/x11/touch_factory_x11.h" |
25 #include "ui/events/event_constants.h" | 25 #include "ui/events/event_constants.h" |
26 #include "ui/events/event_switches.h" | 26 #include "ui/events/event_switches.h" |
27 #include "ui/events/keycodes/keyboard_code_conversion_x.h" | 27 #include "ui/events/keycodes/keyboard_code_conversion_x.h" |
28 #include "ui/gfx/geometry/point3_f.h" | 28 #include "ui/gfx/geometry/point3_f.h" |
| 29 #include "ui/gfx/x/x11_atom_cache.h" |
29 | 30 |
30 // XIScrollClass was introduced in XI 2.1 so we need to define it here | 31 // XIScrollClass was introduced in XI 2.1 so we need to define it here |
31 // for backward-compatibility with older versions of XInput. | 32 // for backward-compatibility with older versions of XInput. |
32 #if !defined(XIScrollClass) | 33 #if !defined(XIScrollClass) |
33 #define XIScrollClass 3 | 34 #define XIScrollClass 3 |
34 #endif | 35 #endif |
35 | 36 |
36 // Multi-touch support was introduced in XI 2.2. Add XI event types here | 37 // Multi-touch support was introduced in XI 2.2. Add XI event types here |
37 // for backward-compatibility with older versions of XInput. | 38 // for backward-compatibility with older versions of XInput. |
38 #if !defined(XI_TouchBegin) | 39 #if !defined(XI_TouchBegin) |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 } | 159 } |
159 | 160 |
160 // static | 161 // static |
161 DeviceDataManagerX11* DeviceDataManagerX11::GetInstance() { | 162 DeviceDataManagerX11* DeviceDataManagerX11::GetInstance() { |
162 return static_cast<DeviceDataManagerX11*>(DeviceDataManager::GetInstance()); | 163 return static_cast<DeviceDataManagerX11*>(DeviceDataManager::GetInstance()); |
163 } | 164 } |
164 | 165 |
165 DeviceDataManagerX11::DeviceDataManagerX11() | 166 DeviceDataManagerX11::DeviceDataManagerX11() |
166 : xi_opcode_(-1), | 167 : xi_opcode_(-1), |
167 high_precision_scrolling_disabled_(IsHighPrecisionScrollingDisabled()), | 168 high_precision_scrolling_disabled_(IsHighPrecisionScrollingDisabled()), |
168 atom_cache_(gfx::GetXDisplay(), kCachedAtoms), | |
169 button_map_count_(0) { | 169 button_map_count_(0) { |
170 CHECK(gfx::GetXDisplay()); | 170 CHECK(gfx::GetXDisplay()); |
171 InitializeXInputInternal(); | 171 InitializeXInputInternal(); |
172 | 172 |
173 // Make sure the sizes of enum and kCachedAtoms are aligned. | 173 // Make sure the sizes of enum and kCachedAtoms are aligned. |
174 CHECK(arraysize(kCachedAtoms) == static_cast<size_t>(DT_LAST_ENTRY) + 1); | 174 CHECK(arraysize(kCachedAtoms) == static_cast<size_t>(DT_LAST_ENTRY) + 1); |
175 UpdateDeviceList(gfx::GetXDisplay()); | 175 UpdateDeviceList(gfx::GetXDisplay()); |
176 UpdateButtonMap(); | 176 UpdateButtonMap(); |
177 } | 177 } |
178 | 178 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 scroll_data_[i].horizontal.seen = false; | 236 scroll_data_[i].horizontal.seen = false; |
237 scroll_data_[i].vertical.number = -1; | 237 scroll_data_[i].vertical.number = -1; |
238 scroll_data_[i].vertical.seen = false; | 238 scroll_data_[i].vertical.seen = false; |
239 for (int j = 0; j < kMaxSlotNum; j++) | 239 for (int j = 0; j < kMaxSlotNum; j++) |
240 last_seen_valuator_[i][j].clear(); | 240 last_seen_valuator_[i][j].clear(); |
241 } | 241 } |
242 | 242 |
243 // Find all the touchpad devices. | 243 // Find all the touchpad devices. |
244 const XDeviceList& dev_list = | 244 const XDeviceList& dev_list = |
245 ui::DeviceListCacheX11::GetInstance()->GetXDeviceList(display); | 245 ui::DeviceListCacheX11::GetInstance()->GetXDeviceList(display); |
246 Atom xi_touchpad = XInternAtom(display, XI_TOUCHPAD, false); | 246 Atom xi_touchpad = ui::X11AtomCache::GetInstance()->GetAtom(XI_TOUCHPAD); |
247 for (int i = 0; i < dev_list.count; ++i) | 247 for (int i = 0; i < dev_list.count; ++i) |
248 if (dev_list[i].type == xi_touchpad) | 248 if (dev_list[i].type == xi_touchpad) |
249 touchpads_[dev_list[i].id] = true; | 249 touchpads_[dev_list[i].id] = true; |
250 | 250 |
251 if (!IsXInput2Available()) | 251 if (!IsXInput2Available()) |
252 return; | 252 return; |
253 | 253 |
254 // Update the structs with new valuator information | 254 // Update the structs with new valuator information |
255 const XIDeviceList& info_list = | 255 const XIDeviceList& info_list = |
256 ui::DeviceListCacheX11::GetInstance()->GetXI2DeviceList(display); | 256 ui::DeviceListCacheX11::GetInstance()->GetXI2DeviceList(display); |
257 Atom atoms[DT_LAST_ENTRY]; | 257 Atom atoms[DT_LAST_ENTRY]; |
258 for (int data_type = 0; data_type < DT_LAST_ENTRY; ++data_type) | 258 for (int data_type = 0; data_type < DT_LAST_ENTRY; ++data_type) |
259 atoms[data_type] = atom_cache_.GetAtom(kCachedAtoms[data_type]); | 259 atoms[data_type] = |
| 260 ui::X11AtomCache::GetInstance()->GetAtom(kCachedAtoms[data_type]); |
260 | 261 |
261 for (int i = 0; i < info_list.count; ++i) { | 262 for (int i = 0; i < info_list.count; ++i) { |
262 const XIDeviceInfo& info = info_list[i]; | 263 const XIDeviceInfo& info = info_list[i]; |
263 | 264 |
264 if (info.use == XIMasterPointer) | 265 if (info.use == XIMasterPointer) |
265 master_pointers_.push_back(info.deviceid); | 266 master_pointers_.push_back(info.deviceid); |
266 | 267 |
267 // We currently handle only slave, non-keyboard devices | 268 // We currently handle only slave, non-keyboard devices |
268 if (info.use != XISlavePointer && info.use != XIFloatingSlave) | 269 if (info.use != XISlavePointer && info.use != XIFloatingSlave) |
269 continue; | 270 continue; |
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
895 } else { | 896 } else { |
896 keyboards.erase(it); | 897 keyboards.erase(it); |
897 ++blocked_iter; | 898 ++blocked_iter; |
898 } | 899 } |
899 } | 900 } |
900 // Notify base class of updated list. | 901 // Notify base class of updated list. |
901 DeviceDataManager::OnKeyboardDevicesUpdated(keyboards); | 902 DeviceDataManager::OnKeyboardDevicesUpdated(keyboards); |
902 } | 903 } |
903 | 904 |
904 } // namespace ui | 905 } // namespace ui |
OLD | NEW |