OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/touch_factory_x11.h" | 5 #include "ui/events/devices/x11/touch_factory_x11.h" |
6 | 6 |
7 #include <X11/Xatom.h> | 7 #include <X11/Xatom.h> |
8 #include <X11/cursorfont.h> | 8 #include <X11/cursorfont.h> |
9 #include <X11/extensions/XInput.h> | 9 #include <X11/extensions/XInput.h> |
10 #include <X11/extensions/XInput2.h> | 10 #include <X11/extensions/XInput2.h> |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
76 ui::TouchFactory::GetInstance()->SetTouchDeviceList(device_ids); | 76 ui::TouchFactory::GetInstance()->SetTouchDeviceList(device_ids); |
77 } | 77 } |
78 } | 78 } |
79 | 79 |
80 void TouchFactory::UpdateDeviceList(Display* display) { | 80 void TouchFactory::UpdateDeviceList(Display* display) { |
81 // Detect touch devices. | 81 // Detect touch devices. |
82 touch_device_lookup_.reset(); | 82 touch_device_lookup_.reset(); |
83 touch_device_list_.clear(); | 83 touch_device_list_.clear(); |
84 touchscreen_ids_.clear(); | 84 touchscreen_ids_.clear(); |
85 | 85 |
86 // NOTE: The new API for retrieving the list of devices (XIQueryDevice) does | 86 // NOTE: If XInput2 is not supported, this will return null (with count of |
87 // not provide enough information to detect a touch device. As a result, the | 87 // -1) so we assume there cannot be any touch devices. |
88 // old version of query function (XListInputDevices) is used instead. | |
89 // If XInput2 is not supported, this will return null (with count of -1) so | |
90 // we assume there cannot be any touch devices. | |
91 // With XI2.1 or older, we allow only single touch devices. | 88 // With XI2.1 or older, we allow only single touch devices. |
sadrul
2015/03/30 21:19:00
Not sure what you mean by 'this will return null'.
lanwei
2015/03/30 21:36:28
I mean the two lists, touch_device_lookup_, touch_
| |
92 const XDeviceList& dev_list = | |
93 DeviceListCacheX11::GetInstance()->GetXDeviceList(display); | |
94 Atom xi_touchscreen = XInternAtom(display, XI_TOUCHSCREEN, false); | |
95 for (int i = 0; i < dev_list.count; i++) { | |
96 if (dev_list[i].type == xi_touchscreen) { | |
97 touch_device_lookup_[dev_list[i].id] = true; | |
98 touch_device_list_[dev_list[i].id] = false; | |
99 } | |
100 } | |
101 | |
102 if (!DeviceDataManagerX11::GetInstance()->IsXInput2Available()) | 89 if (!DeviceDataManagerX11::GetInstance()->IsXInput2Available()) |
103 return; | 90 return; |
104 | 91 |
105 // Instead of asking X for the list of devices all the time, let's maintain a | 92 // Instead of asking X for the list of devices all the time, let's maintain a |
106 // list of pointer devices we care about. | 93 // list of pointer devices we care about. |
107 // It should not be necessary to select for slave devices. XInput2 provides | 94 // It should not be necessary to select for slave devices. XInput2 provides |
108 // enough information to the event callback to decide which slave device | 95 // enough information to the event callback to decide which slave device |
109 // triggered the event, thus decide whether the 'pointer event' is a | 96 // triggered the event, thus decide whether the 'pointer event' is a |
110 // 'mouse event' or a 'touch event'. | 97 // 'mouse event' or a 'touch event'. |
111 // However, on some desktops, some events from a master pointer are | 98 // However, on some desktops, some events from a master pointer are |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
339 if (ptr[0] || ptr[1]) | 326 if (ptr[0] || ptr[1]) |
340 touchscreen_ids_.insert(std::make_pair(ptr[0], ptr[1])); | 327 touchscreen_ids_.insert(std::make_pair(ptr[0], ptr[1])); |
341 } | 328 } |
342 XFree(prop_return); | 329 XFree(prop_return); |
343 } | 330 } |
344 | 331 |
345 XCloseDevice(display, device); | 332 XCloseDevice(display, device); |
346 } | 333 } |
347 | 334 |
348 } // namespace ui | 335 } // namespace ui |
OLD | NEW |