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

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

Issue 135763002: Revert 244210 "Include external touchscreen vid/pid in UMA hardw..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « trunk/src/ui/events/x/touch_factory_x11.h ('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 (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/Xatom.h>
8 #include <X11/cursorfont.h> 7 #include <X11/cursorfont.h>
9 #include <X11/extensions/XInput.h> 8 #include <X11/extensions/XInput.h>
10 #include <X11/extensions/XInput2.h> 9 #include <X11/extensions/XInput2.h>
11 #include <X11/extensions/XIproto.h> 10 #include <X11/extensions/XIproto.h>
12 11
13 #include "base/basictypes.h" 12 #include "base/basictypes.h"
14 #include "base/command_line.h" 13 #include "base/command_line.h"
15 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
16 #include "base/logging.h" 15 #include "base/logging.h"
17 #include "base/memory/singleton.h" 16 #include "base/memory/singleton.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 } 74 }
76 ui::TouchFactory::GetInstance()->SetTouchDeviceList(device_ids); 75 ui::TouchFactory::GetInstance()->SetTouchDeviceList(device_ids);
77 } 76 }
78 } 77 }
79 78
80 void TouchFactory::UpdateDeviceList(Display* display) { 79 void TouchFactory::UpdateDeviceList(Display* display) {
81 // Detect touch devices. 80 // Detect touch devices.
82 touch_device_available_ = false; 81 touch_device_available_ = false;
83 touch_device_lookup_.reset(); 82 touch_device_lookup_.reset();
84 touch_device_list_.clear(); 83 touch_device_list_.clear();
85 touchscreen_ids_.clear();
86 max_touch_points_ = -1; 84 max_touch_points_ = -1;
87 85
88 #if !defined(USE_XI2_MT) 86 #if !defined(USE_XI2_MT)
89 // NOTE: The new API for retrieving the list of devices (XIQueryDevice) does 87 // NOTE: The new API for retrieving the list of devices (XIQueryDevice) does
90 // not provide enough information to detect a touch device. As a result, the 88 // not provide enough information to detect a touch device. As a result, the
91 // old version of query function (XListInputDevices) is used instead. 89 // old version of query function (XListInputDevices) is used instead.
92 // If XInput2 is not supported, this will return null (with count of -1) so 90 // If XInput2 is not supported, this will return null (with count of -1) so
93 // we assume there cannot be any touch devices. 91 // we assume there cannot be any touch devices.
94 // With XI2.1 or older, we allow only single touch devices. 92 // With XI2.1 or older, we allow only single touch devices.
95 XDeviceList dev_list = 93 XDeviceList dev_list =
(...skipping 30 matching lines...) Expand all
126 XIDeviceInfo* devinfo = xi_dev_list.devices + i; 124 XIDeviceInfo* devinfo = xi_dev_list.devices + i;
127 if (devinfo->use == XIFloatingSlave || devinfo->use == XIMasterPointer) { 125 if (devinfo->use == XIFloatingSlave || devinfo->use == XIMasterPointer) {
128 #if defined(USE_XI2_MT) 126 #if defined(USE_XI2_MT)
129 for (int k = 0; k < devinfo->num_classes; ++k) { 127 for (int k = 0; k < devinfo->num_classes; ++k) {
130 XIAnyClassInfo* xiclassinfo = devinfo->classes[k]; 128 XIAnyClassInfo* xiclassinfo = devinfo->classes[k];
131 if (xiclassinfo->type == XITouchClass) { 129 if (xiclassinfo->type == XITouchClass) {
132 XITouchClassInfo* tci = 130 XITouchClassInfo* tci =
133 reinterpret_cast<XITouchClassInfo *>(xiclassinfo); 131 reinterpret_cast<XITouchClassInfo *>(xiclassinfo);
134 // Only care direct touch device (such as touch screen) right now 132 // Only care direct touch device (such as touch screen) right now
135 if (tci->mode == XIDirectTouch) { 133 if (tci->mode == XIDirectTouch) {
136 CacheTouchscreenIds(display, devinfo->deviceid);
137 touch_device_lookup_[devinfo->deviceid] = true; 134 touch_device_lookup_[devinfo->deviceid] = true;
138 touch_device_list_[devinfo->deviceid] = true; 135 touch_device_list_[devinfo->deviceid] = true;
139 touch_device_available_ = true; 136 touch_device_available_ = true;
140 if (tci->num_touches > 0 && tci->num_touches > max_touch_points_) 137 if (tci->num_touches > 0 && tci->num_touches > max_touch_points_)
141 max_touch_points_ = tci->num_touches; 138 max_touch_points_ = tci->num_touches;
142 } 139 }
143 } 140 }
144 } 141 }
145 #endif 142 #endif
146 pointer_device_lookup_[devinfo->deviceid] = true; 143 pointer_device_lookup_[devinfo->deviceid] = true;
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 261
265 void TouchFactory::SetPointerDeviceForTest( 262 void TouchFactory::SetPointerDeviceForTest(
266 const std::vector<unsigned int>& devices) { 263 const std::vector<unsigned int>& devices) {
267 pointer_device_lookup_.reset(); 264 pointer_device_lookup_.reset();
268 for (std::vector<unsigned int>::const_iterator iter = devices.begin(); 265 for (std::vector<unsigned int>::const_iterator iter = devices.begin();
269 iter != devices.end(); ++iter) { 266 iter != devices.end(); ++iter) {
270 pointer_device_lookup_[*iter] = true; 267 pointer_device_lookup_[*iter] = true;
271 } 268 }
272 } 269 }
273 270
274 void TouchFactory::CacheTouchscreenIds(Display* display, int device_id) {
275 XDevice* device = XOpenDevice(display, device_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 const char kDeviceProductIdString[] = "Device Product ID";
283 Atom device_product_id_atom =
284 XInternAtom(display, kDeviceProductIdString, false);
285
286 if (device_product_id_atom != None &&
287 XGetDeviceProperty(display, device, device_product_id_atom, 0, 2,
288 False, XA_INTEGER, &actual_type_return,
289 &actual_format_return, &nitems_return,
290 &bytes_after_return, &prop_return) == Success) {
291 if (actual_type_return == XA_INTEGER &&
292 actual_format_return == 32 &&
293 nitems_return == 2) {
294 // An actual_format_return of 32 implies that the returned data is an
295 // array of longs. See the description of |prop_return| in `man
296 // XGetDeviceProperty` for details.
297 long* ptr = reinterpret_cast<long*>(prop_return);
298
299 // Internal displays will have a vid and pid of 0. Ignore them.
300 // ptr[0] is the vid, and ptr[1] is the pid.
301 if (ptr[0] || ptr[1])
302 touchscreen_ids_.insert(std::make_pair(ptr[0], ptr[1]));
303 }
304 XFree(prop_return);
305 }
306
307 XCloseDevice(display, device);
308 }
309
310 } // namespace ui 271 } // namespace ui
OLDNEW
« no previous file with comments | « trunk/src/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