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

Side by Side Diff: ui/events/devices/x11/touch_factory_x11.cc

Issue 2552343008: Add slave touch device to touch_device_lookup_ and touch_device_list_ (Closed)
Patch Set: sadrul's comments addressed Created 4 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
« 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/devices/x11/touch_factory_x11.h" 5 #include "ui/events/devices/x11/touch_factory_x11.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <X11/Xatom.h> 8 #include <X11/Xatom.h>
9 #include <X11/cursorfont.h> 9 #include <X11/cursorfont.h>
10 #include <X11/extensions/XInput.h> 10 #include <X11/extensions/XInput.h>
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 // not delivered to the client. So we select for slave devices instead. 91 // not delivered to the client. So we select for slave devices instead.
92 // If the touch device has 'GrabDevice' set and 'SendCoreEvents' unset (which 92 // If the touch device has 'GrabDevice' set and 'SendCoreEvents' unset (which
93 // is possible), then the device is detected as a floating device, and a 93 // is possible), then the device is detected as a floating device, and a
94 // floating device is not connected to a master device. So it is necessary to 94 // floating device is not connected to a master device. So it is necessary to
95 // also select on the floating devices. 95 // also select on the floating devices.
96 pointer_device_lookup_.reset(); 96 pointer_device_lookup_.reset();
97 const XIDeviceList& xi_dev_list = 97 const XIDeviceList& xi_dev_list =
98 DeviceListCacheX11::GetInstance()->GetXI2DeviceList(display); 98 DeviceListCacheX11::GetInstance()->GetXI2DeviceList(display);
99 for (int i = 0; i < xi_dev_list.count; i++) { 99 for (int i = 0; i < xi_dev_list.count; i++) {
100 const XIDeviceInfo& devinfo = xi_dev_list[i]; 100 const XIDeviceInfo& devinfo = xi_dev_list[i];
101 if (devinfo.use == XIFloatingSlave || devinfo.use == XIMasterPointer) { 101 if (devinfo.use == XIFloatingSlave || devinfo.use == XIMasterPointer ||
102 devinfo.use == XISlavePointer) {
102 for (int k = 0; k < devinfo.num_classes; ++k) { 103 for (int k = 0; k < devinfo.num_classes; ++k) {
103 XIAnyClassInfo* xiclassinfo = devinfo.classes[k]; 104 XIAnyClassInfo* xiclassinfo = devinfo.classes[k];
104 if (xiclassinfo->type == XITouchClass) { 105 if (xiclassinfo->type == XITouchClass) {
105 XITouchClassInfo* tci = 106 XITouchClassInfo* tci =
106 reinterpret_cast<XITouchClassInfo*>(xiclassinfo); 107 reinterpret_cast<XITouchClassInfo*>(xiclassinfo);
107 // Only care direct touch device (such as touch screen) right now 108 // Only care direct touch device (such as touch screen) right now
108 if (tci->mode == XIDirectTouch) { 109 if (tci->mode == XIDirectTouch) {
109 touch_device_lookup_[devinfo.deviceid] = true; 110 touch_device_lookup_[devinfo.deviceid] = true;
110 touch_device_list_[devinfo.deviceid] = true; 111 touch_device_list_[devinfo.deviceid] = true;
111 } 112 if (devinfo.use == XISlavePointer &&
112 } 113 IsValidDevice(devinfo.attachment)) {
113 }
114 pointer_device_lookup_[devinfo.deviceid] = true;
115 } else if (devinfo.use == XIMasterKeyboard) {
116 virtual_core_keyboard_device_ = devinfo.deviceid;
117 }
118
119 if (devinfo.use == XIFloatingSlave || devinfo.use == XISlavePointer) {
120 for (int k = 0; k < devinfo.num_classes; ++k) {
121 XIAnyClassInfo* xiclassinfo = devinfo.classes[k];
122 if (xiclassinfo->type == XITouchClass) {
123 XITouchClassInfo* tci =
124 reinterpret_cast<XITouchClassInfo*>(xiclassinfo);
125 // Only care direct touch device (such as touch screen) right now
126 if (tci->mode == XIDirectTouch) {
127 CacheTouchscreenIds(devinfo.deviceid);
128 if (devinfo.use == XISlavePointer) {
129 device_master_id_list_[devinfo.deviceid] = devinfo.attachment; 114 device_master_id_list_[devinfo.deviceid] = devinfo.attachment;
130 // If the slave device is direct touch device, we also set its 115 // If the slave device is direct touch device, we also set its
131 // master device to be touch device. 116 // master device to be touch device.
132 touch_device_lookup_[devinfo.attachment] = true; 117 touch_device_lookup_[devinfo.attachment] = true;
133 touch_device_list_[devinfo.attachment] = true; 118 touch_device_list_[devinfo.attachment] = true;
134 } 119 }
135 } 120 }
136 } 121 }
137 } 122 }
123 pointer_device_lookup_[devinfo.deviceid] = true;
chaopeng 2016/12/12 16:35:43 It looks like we should also set pointer_device_lo
sadrul 2016/12/12 18:56:11 Hm. Are we going to process each events twice afte
124 } else if (devinfo.use == XIMasterKeyboard) {
125 virtual_core_keyboard_device_ = devinfo.deviceid;
138 } 126 }
139 } 127 }
140 } 128 }
141 129
142 bool TouchFactory::ShouldProcessXI2Event(XEvent* xev) { 130 bool TouchFactory::ShouldProcessXI2Event(XEvent* xev) {
143 DCHECK_EQ(GenericEvent, xev->type); 131 DCHECK_EQ(GenericEvent, xev->type);
144 XIEvent* event = static_cast<XIEvent*>(xev->xcookie.data); 132 XIEvent* event = static_cast<XIEvent*>(xev->xcookie.data);
145 XIDeviceEvent* xiev = reinterpret_cast<XIDeviceEvent*>(event); 133 XIDeviceEvent* xiev = reinterpret_cast<XIDeviceEvent*>(event);
146 134
147 const bool is_touch_disabled = !touch_screens_enabled_; 135 const bool is_touch_disabled = !touch_screens_enabled_;
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 std::find_if(touchscreens.begin(), touchscreens.end(), 315 std::find_if(touchscreens.begin(), touchscreens.end(),
328 [device_id](const TouchscreenDevice& touchscreen) { 316 [device_id](const TouchscreenDevice& touchscreen) {
329 return touchscreen.id == device_id; 317 return touchscreen.id == device_id;
330 }); 318 });
331 // Internal displays will have a vid and pid of 0. Ignore them. 319 // Internal displays will have a vid and pid of 0. Ignore them.
332 if (it != touchscreens.end() && it->vendor_id && it->product_id) 320 if (it != touchscreens.end() && it->vendor_id && it->product_id)
333 touchscreen_ids_.insert(std::make_pair(it->vendor_id, it->product_id)); 321 touchscreen_ids_.insert(std::make_pair(it->vendor_id, it->product_id));
334 } 322 }
335 323
336 } // namespace ui 324 } // 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