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

Side by Side Diff: ui/events/x/touch_factory_x11.cc

Issue 103893005: Include external touchscreen vid/pid in UMA hardware profile (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 | Annotate | Revision Log
OLDNEW
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/x/touch_factory_x11.h" 5 #include "ui/events/x/touch_factory_x11.h"
6 6
7 #include <X11/cursorfont.h> 7 #include <X11/cursorfont.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/extensions/XIproto.h> 10 #include <X11/extensions/XIproto.h>
11 #include <X11/Xatom.h>
11 12
12 #include "base/basictypes.h" 13 #include "base/basictypes.h"
13 #include "base/command_line.h" 14 #include "base/command_line.h"
14 #include "base/compiler_specific.h" 15 #include "base/compiler_specific.h"
15 #include "base/logging.h" 16 #include "base/logging.h"
16 #include "base/memory/singleton.h" 17 #include "base/memory/singleton.h"
17 #include "base/message_loop/message_loop.h" 18 #include "base/message_loop/message_loop.h"
18 #include "base/strings/string_number_conversions.h" 19 #include "base/strings/string_number_conversions.h"
19 #include "base/strings/string_split.h" 20 #include "base/strings/string_split.h"
20 #include "ui/events/event_switches.h" 21 #include "ui/events/event_switches.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 } 75 }
75 ui::TouchFactory::GetInstance()->SetTouchDeviceList(device_ids); 76 ui::TouchFactory::GetInstance()->SetTouchDeviceList(device_ids);
76 } 77 }
77 } 78 }
78 79
79 void TouchFactory::UpdateDeviceList(Display* display) { 80 void TouchFactory::UpdateDeviceList(Display* display) {
80 // Detect touch devices. 81 // Detect touch devices.
81 touch_device_available_ = false; 82 touch_device_available_ = false;
82 touch_device_lookup_.reset(); 83 touch_device_lookup_.reset();
83 touch_device_list_.clear(); 84 touch_device_list_.clear();
85 touchscreen_ids_.clear();
84 max_touch_points_ = -1; 86 max_touch_points_ = -1;
85 87
86 #if !defined(USE_XI2_MT) 88 #if !defined(USE_XI2_MT)
87 // NOTE: The new API for retrieving the list of devices (XIQueryDevice) does 89 // NOTE: The new API for retrieving the list of devices (XIQueryDevice) does
88 // not provide enough information to detect a touch device. As a result, the 90 // not provide enough information to detect a touch device. As a result, the
89 // old version of query function (XListInputDevices) is used instead. 91 // old version of query function (XListInputDevices) is used instead.
90 // If XInput2 is not supported, this will return null (with count of -1) so 92 // If XInput2 is not supported, this will return null (with count of -1) so
91 // we assume there cannot be any touch devices. 93 // we assume there cannot be any touch devices.
92 // With XI2.1 or older, we allow only single touch devices. 94 // With XI2.1 or older, we allow only single touch devices.
93 XDeviceList dev_list = 95 XDeviceList dev_list =
(...skipping 26 matching lines...) Expand all
120 pointer_device_lookup_.reset(); 122 pointer_device_lookup_.reset();
121 XIDeviceList xi_dev_list = 123 XIDeviceList xi_dev_list =
122 DeviceListCacheX::GetInstance()->GetXI2DeviceList(display); 124 DeviceListCacheX::GetInstance()->GetXI2DeviceList(display);
123 for (int i = 0; i < xi_dev_list.count; i++) { 125 for (int i = 0; i < xi_dev_list.count; i++) {
124 XIDeviceInfo* devinfo = xi_dev_list.devices + i; 126 XIDeviceInfo* devinfo = xi_dev_list.devices + i;
125 if (devinfo->use == XIFloatingSlave || devinfo->use == XIMasterPointer) { 127 if (devinfo->use == XIFloatingSlave || devinfo->use == XIMasterPointer) {
126 #if defined(USE_XI2_MT) 128 #if defined(USE_XI2_MT)
127 for (int k = 0; k < devinfo->num_classes; ++k) { 129 for (int k = 0; k < devinfo->num_classes; ++k) {
128 XIAnyClassInfo* xiclassinfo = devinfo->classes[k]; 130 XIAnyClassInfo* xiclassinfo = devinfo->classes[k];
129 if (xiclassinfo->type == XITouchClass) { 131 if (xiclassinfo->type == XITouchClass) {
132 CacheTouchscreenIds(display, devinfo->deviceid);
130 XITouchClassInfo* tci = 133 XITouchClassInfo* tci =
131 reinterpret_cast<XITouchClassInfo *>(xiclassinfo); 134 reinterpret_cast<XITouchClassInfo *>(xiclassinfo);
132 // Only care direct touch device (such as touch screen) right now 135 // Only care direct touch device (such as touch screen) right now
133 if (tci->mode == XIDirectTouch) { 136 if (tci->mode == XIDirectTouch) {
134 touch_device_lookup_[devinfo->deviceid] = true; 137 touch_device_lookup_[devinfo->deviceid] = true;
135 touch_device_list_[devinfo->deviceid] = true; 138 touch_device_list_[devinfo->deviceid] = true;
136 touch_device_available_ = true; 139 touch_device_available_ = true;
137 if (tci->num_touches > 0 && tci->num_touches > max_touch_points_) 140 if (tci->num_touches > 0 && tci->num_touches > max_touch_points_)
138 max_touch_points_ = tci->num_touches; 141 max_touch_points_ = tci->num_touches;
139 } 142 }
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 264
262 void TouchFactory::SetPointerDeviceForTest( 265 void TouchFactory::SetPointerDeviceForTest(
263 const std::vector<unsigned int>& devices) { 266 const std::vector<unsigned int>& devices) {
264 pointer_device_lookup_.reset(); 267 pointer_device_lookup_.reset();
265 for (std::vector<unsigned int>::const_iterator iter = devices.begin(); 268 for (std::vector<unsigned int>::const_iterator iter = devices.begin();
266 iter != devices.end(); ++iter) { 269 iter != devices.end(); ++iter) {
267 pointer_device_lookup_[*iter] = true; 270 pointer_device_lookup_[*iter] = true;
268 } 271 }
269 } 272 }
270 273
274 void TouchFactory::CacheTouchscreenIds(Display* display, int id) {
275 XDevice* device = XOpenDevice(display, id);
276 Atom actual_type_return;
277 int actual_format_return;
278 unsigned long nitems_return;
279 unsigned long bytes_after_return;
280 unsigned char *prop_return;
281
282 if (XGetDeviceProperty(display, device, kDeviceProductIdAtom, 0, 2,
283 False, XA_INTEGER, &actual_type_return,
284 &actual_format_return, &nitems_return,
285 &bytes_after_return, &prop_return) == Success) {
286 // XA_INTEGER, which results in an actual_format_return of 32, implies that
287 // the returned data is an array of longs. See the description of
288 // |prop_return| in `man XGetDeviceProperty` for details.
289 long* ptr = reinterpret_cast<long*>(prop_return);
290 // Internal displays will have a vid and pid of 0. Ignore them.
291 if (ptr[0] || ptr[1])
292 touchscreen_ids_.insert(std::make_pair(ptr[0], ptr[1]));
sadrul 2013/12/12 18:22:19 How do you interpret these numbers?
tdresser 2013/12/12 19:05:01 Comment added.
293 XFree(prop_return);
294 }
295
296 XCloseDevice(display, device);
297 }
298
271 } // namespace ui 299 } // namespace ui
OLDNEW
« ui/events/x/touch_factory_x11.h ('K') | « ui/events/x/touch_factory_x11.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698