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

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

Issue 49383011: Build fix linux aura without USE_XI2_MT. (Closed) Base URL: https://git.chromium.org/chromium/src.git@ime
Patch Set: Clean up for-loop Created 7 years, 1 month 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
« no previous file with comments | « no previous file | 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/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>
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 84
85 #if !defined(USE_XI2_MT) 85 #if !defined(USE_XI2_MT)
86 // NOTE: The new API for retrieving the list of devices (XIQueryDevice) does 86 // NOTE: The new API for retrieving the list of devices (XIQueryDevice) does
87 // not provide enough information to detect a touch device. As a result, the 87 // not provide enough information to detect a touch device. As a result, the
88 // old version of query function (XListInputDevices) is used instead. 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 89 // If XInput2 is not supported, this will return null (with count of -1) so
90 // we assume there cannot be any touch devices. 90 // we assume there cannot be any touch devices.
91 // With XI2.1 or older, we allow only single touch devices. 91 // With XI2.1 or older, we allow only single touch devices.
92 XDeviceList dev_list = 92 XDeviceList dev_list =
93 DeviceListCacheX::GetInstance()->GetXDeviceList(display); 93 DeviceListCacheX::GetInstance()->GetXDeviceList(display);
94 for (int i = 0; i < dev_list.count; i++) { 94 Atom xi_touchscreen = XInternAtom(display, XI_TOUCHSCREEN, false);
95 if (dev_list[i].type) { 95 char* devtype = XGetAtomName(display, xi_touchscreen);
96 XScopedString devtype(XGetAtomName(display, dev_list[i].type)); 96 if (devtype) {
dshwang 2013/10/31 15:47:26 Do you think thin if-statement is needed? I want t
sadrul 2013/10/31 15:49:21 Yes. Remove devtype. It's not necessary here.
97 if (devtype.string() && !strcmp(devtype.string(), XI_TOUCHSCREEN)) { 97 for (int i = 0; i < dev_list.count; i++) {
98 if (dev_list[i].type == xi_touchscreen) {
98 touch_device_lookup_[dev_list[i].id] = true; 99 touch_device_lookup_[dev_list[i].id] = true;
99 touch_device_list_[dev_list[i].id] = false; 100 touch_device_list_[dev_list[i].id] = false;
100 touch_device_available_ = true; 101 touch_device_available_ = true;
101 } 102 }
102 } 103 }
103 } 104 }
105 XFree(devtype);
104 #endif 106 #endif
105 107
106 // Instead of asking X for the list of devices all the time, let's maintain a 108 // Instead of asking X for the list of devices all the time, let's maintain a
107 // list of pointer devices we care about. 109 // list of pointer devices we care about.
108 // It should not be necessary to select for slave devices. XInput2 provides 110 // It should not be necessary to select for slave devices. XInput2 provides
109 // enough information to the event callback to decide which slave device 111 // enough information to the event callback to decide which slave device
110 // triggered the event, thus decide whether the 'pointer event' is a 112 // triggered the event, thus decide whether the 'pointer event' is a
111 // 'mouse event' or a 'touch event'. 113 // 'mouse event' or a 'touch event'.
112 // However, on some desktops, some events from a master pointer are 114 // However, on some desktops, some events from a master pointer are
113 // not delivered to the client. So we select for slave devices instead. 115 // not delivered to the client. So we select for slave devices instead.
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 iter != devices.end(); ++iter) { 247 iter != devices.end(); ++iter) {
246 DCHECK(*iter < touch_device_lookup_.size()); 248 DCHECK(*iter < touch_device_lookup_.size());
247 touch_device_lookup_[*iter] = true; 249 touch_device_lookup_[*iter] = true;
248 touch_device_list_[*iter] = true; 250 touch_device_list_[*iter] = true;
249 } 251 }
250 touch_device_available_ = true; 252 touch_device_available_ = true;
251 touch_events_disabled_ = false; 253 touch_events_disabled_ = false;
252 } 254 }
253 255
254 } // namespace ui 256 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698