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

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 comment addressed. Created 3 years, 9 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
« 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) {
sadrul 2017/03/10 20:28:57 Perhaps we could change this to early-continue too
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)
110 continue;
111
112 int master_id = devinfo.use == XISlavePointer ? devinfo.attachment
113 : devinfo.deviceid;
114
115 if (!IsValidDevice(master_id)
116 continue;
117
118 touch_device_lookup_[master_id] = true;
119 touch_device_list_[master_id] = true;
120
121 if (devinfo.use != XIMasterPointer)
122 CacheTouchscreenIds(devinfo.deviceid);
123
124 if (devinfo.use == XISlavePointer) {
125 device_master_id_list_[devinfo.deviceid] = master_id;
109 touch_device_lookup_[devinfo.deviceid] = true; 126 touch_device_lookup_[devinfo.deviceid] = true;
110 touch_device_list_[devinfo.deviceid] = true; 127 touch_device_list_[devinfo.deviceid] = false;
111 } 128 }
112 } 129 }
113 } 130 }
114 pointer_device_lookup_[devinfo.deviceid] = true; 131 pointer_device_lookup_[devinfo.deviceid] =
132 (devinfo.use != XISlavePointer);
115 } else if (devinfo.use == XIMasterKeyboard) { 133 } else if (devinfo.use == XIMasterKeyboard) {
116 virtual_core_keyboard_device_ = devinfo.deviceid; 134 virtual_core_keyboard_device_ = devinfo.deviceid;
117 } 135 }
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;
130 // If the slave device is direct touch device, we also set its
131 // master device to be touch device.
132 touch_device_lookup_[devinfo.attachment] = true;
133 touch_device_list_[devinfo.attachment] = true;
134 }
135 }
136 }
137 }
138 }
139 } 136 }
140 } 137 }
141 138
142 bool TouchFactory::ShouldProcessXI2Event(XEvent* xev) { 139 bool TouchFactory::ShouldProcessXI2Event(XEvent* xev) {
143 DCHECK_EQ(GenericEvent, xev->type); 140 DCHECK_EQ(GenericEvent, xev->type);
144 XIEvent* event = static_cast<XIEvent*>(xev->xcookie.data); 141 XIEvent* event = static_cast<XIEvent*>(xev->xcookie.data);
145 XIDeviceEvent* xiev = reinterpret_cast<XIDeviceEvent*>(event); 142 XIDeviceEvent* xiev = reinterpret_cast<XIDeviceEvent*>(event);
146 143
147 const bool is_touch_disabled = !touch_screens_enabled_; 144 const bool is_touch_disabled = !touch_screens_enabled_;
148 145
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 std::find_if(touchscreens.begin(), touchscreens.end(), 324 std::find_if(touchscreens.begin(), touchscreens.end(),
328 [device_id](const TouchscreenDevice& touchscreen) { 325 [device_id](const TouchscreenDevice& touchscreen) {
329 return touchscreen.id == device_id; 326 return touchscreen.id == device_id;
330 }); 327 });
331 // Internal displays will have a vid and pid of 0. Ignore them. 328 // Internal displays will have a vid and pid of 0. Ignore them.
332 if (it != touchscreens.end() && it->vendor_id && it->product_id) 329 if (it != touchscreens.end() && it->vendor_id && it->product_id)
333 touchscreen_ids_.insert(std::make_pair(it->vendor_id, it->product_id)); 330 touchscreen_ids_.insert(std::make_pair(it->vendor_id, it->product_id));
334 } 331 }
335 332
336 } // namespace ui 333 } // 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