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

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: add slave touch screen to list and lookup 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 118
119 if (devinfo.use == XIFloatingSlave || devinfo.use == XISlavePointer) { 119 if (devinfo.use == XIFloatingSlave || devinfo.use == XISlavePointer) {
120 for (int k = 0; k < devinfo.num_classes; ++k) { 120 for (int k = 0; k < devinfo.num_classes; ++k) {
121 XIAnyClassInfo* xiclassinfo = devinfo.classes[k]; 121 XIAnyClassInfo* xiclassinfo = devinfo.classes[k];
122 if (xiclassinfo->type == XITouchClass) { 122 if (xiclassinfo->type == XITouchClass) {
123 XITouchClassInfo* tci = 123 XITouchClassInfo* tci =
124 reinterpret_cast<XITouchClassInfo*>(xiclassinfo); 124 reinterpret_cast<XITouchClassInfo*>(xiclassinfo);
125 // Only care direct touch device (such as touch screen) right now 125 // Only care direct touch device (such as touch screen) right now
126 if (tci->mode == XIDirectTouch) { 126 if (tci->mode == XIDirectTouch) {
127 CacheTouchscreenIds(devinfo.deviceid); 127 CacheTouchscreenIds(devinfo.deviceid);
128 touch_device_lookup_[devinfo.deviceid] = true;
129 touch_device_list_[devinfo.deviceid] = false;
sadrul 2016/12/12 16:02:06 I think this is getting fairly confusing. Can you
128 if (devinfo.use == XISlavePointer) { 130 if (devinfo.use == XISlavePointer) {
129 device_master_id_list_[devinfo.deviceid] = devinfo.attachment; 131 device_master_id_list_[devinfo.deviceid] = devinfo.attachment;
130 // If the slave device is direct touch device, we also set its 132 // If the slave device is direct touch device, we also set its
131 // master device to be touch device. 133 // master device to be touch device.
132 touch_device_lookup_[devinfo.attachment] = true; 134 touch_device_lookup_[devinfo.attachment] = true;
sadrul 2016/12/12 16:02:06 Oh hrm. We should really verify that |devinfo.atta
133 touch_device_list_[devinfo.attachment] = true; 135 touch_device_list_[devinfo.attachment] = true;
134 } 136 }
135 } 137 }
136 } 138 }
137 } 139 }
138 } 140 }
139 } 141 }
140 } 142 }
141 143
142 bool TouchFactory::ShouldProcessXI2Event(XEvent* xev) { 144 bool TouchFactory::ShouldProcessXI2Event(XEvent* xev) {
143 DCHECK_EQ(GenericEvent, xev->type); 145 DCHECK_EQ(GenericEvent, xev->type);
144 XIEvent* event = static_cast<XIEvent*>(xev->xcookie.data); 146 XIEvent* event = static_cast<XIEvent*>(xev->xcookie.data);
145 XIDeviceEvent* xiev = reinterpret_cast<XIDeviceEvent*>(event); 147 XIDeviceEvent* xiev = reinterpret_cast<XIDeviceEvent*>(event);
146 148
147 const bool is_touch_disabled = !touch_screens_enabled_; 149 const bool is_touch_disabled = !touch_screens_enabled_;
148 150
149 if (event->evtype == XI_TouchBegin || 151 if (event->evtype == XI_TouchBegin ||
150 event->evtype == XI_TouchUpdate || 152 event->evtype == XI_TouchUpdate ||
151 event->evtype == XI_TouchEnd) { 153 event->evtype == XI_TouchEnd) {
154 // TODO(chaopeng) we need to add deviceid to touch_device_lookup_ if this
155 // assertion failed.
156 DCHECK(touch_device_lookup_[xiev->deviceid]);
152 // Since SetupXI2ForXWindow() selects events from all devices, for a 157 // Since SetupXI2ForXWindow() selects events from all devices, for a
153 // touchscreen attached to a master pointer device, X11 sends two 158 // touchscreen attached to a master pointer device, X11 sends two
154 // events for each touch: one from the slave (deviceid == the id of 159 // events for each touch: one from the slave (deviceid == the id of
155 // the touchscreen device), and one from the master (deviceid == the 160 // the touchscreen device), and one from the master (deviceid == the
156 // id of the master pointer device). Instead of processing both 161 // id of the master pointer device). Instead of processing both
157 // events, discard the event that comes from the slave, and only 162 // events, discard the event that comes from the slave, and only
158 // allow processing the event coming from the master. 163 // allow processing the event coming from the master.
159 // For a 'floating' touchscreen device, X11 sends only one event for 164 // For a 'floating' touchscreen device, X11 sends only one event for
160 // each touch, with both deviceid and sourceid set to the id of the 165 // each touch, with both deviceid and sourceid set to the id of the
161 // touchscreen device. 166 // touchscreen device.
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 std::find_if(touchscreens.begin(), touchscreens.end(), 332 std::find_if(touchscreens.begin(), touchscreens.end(),
328 [device_id](const TouchscreenDevice& touchscreen) { 333 [device_id](const TouchscreenDevice& touchscreen) {
329 return touchscreen.id == device_id; 334 return touchscreen.id == device_id;
330 }); 335 });
331 // Internal displays will have a vid and pid of 0. Ignore them. 336 // Internal displays will have a vid and pid of 0. Ignore them.
332 if (it != touchscreens.end() && it->vendor_id && it->product_id) 337 if (it != touchscreens.end() && it->vendor_id && it->product_id)
333 touchscreen_ids_.insert(std::make_pair(it->vendor_id, it->product_id)); 338 touchscreen_ids_.insert(std::make_pair(it->vendor_id, it->product_id));
334 } 339 }
335 340
336 } // namespace ui 341 } // 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