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

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

Issue 1102673002: Revert of Ozone support for device special cases in keyboard event rewriting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 | « ui/events/devices/x11/touch_factory_x11.h ('k') | ui/events/event.cc » ('j') | 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 <X11/Xatom.h> 7 #include <X11/Xatom.h>
8 #include <X11/cursorfont.h> 8 #include <X11/cursorfont.h>
9 #include <X11/extensions/XInput.h> 9 #include <X11/extensions/XInput.h>
10 #include <X11/extensions/XInput2.h> 10 #include <X11/extensions/XInput2.h>
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 } 122 }
123 123
124 if (devinfo.use == XIFloatingSlave || devinfo.use == XISlavePointer) { 124 if (devinfo.use == XIFloatingSlave || devinfo.use == XISlavePointer) {
125 for (int k = 0; k < devinfo.num_classes; ++k) { 125 for (int k = 0; k < devinfo.num_classes; ++k) {
126 XIAnyClassInfo* xiclassinfo = devinfo.classes[k]; 126 XIAnyClassInfo* xiclassinfo = devinfo.classes[k];
127 if (xiclassinfo->type == XITouchClass) { 127 if (xiclassinfo->type == XITouchClass) {
128 XITouchClassInfo* tci = 128 XITouchClassInfo* tci =
129 reinterpret_cast<XITouchClassInfo*>(xiclassinfo); 129 reinterpret_cast<XITouchClassInfo*>(xiclassinfo);
130 // Only care direct touch device (such as touch screen) right now 130 // Only care direct touch device (such as touch screen) right now
131 if (tci->mode == XIDirectTouch) 131 if (tci->mode == XIDirectTouch)
132 CacheTouchscreenIds(devinfo.deviceid); 132 CacheTouchscreenIds(display, devinfo.deviceid);
133 } 133 }
134 } 134 }
135 } 135 }
136 } 136 }
137 } 137 }
138 138
139 bool TouchFactory::ShouldProcessXI2Event(XEvent* xev) { 139 bool TouchFactory::ShouldProcessXI2Event(XEvent* xev) {
140 DCHECK_EQ(GenericEvent, xev->type); 140 DCHECK_EQ(GenericEvent, xev->type);
141 XIEvent* event = static_cast<XIEvent*>(xev->xcookie.data); 141 XIEvent* event = static_cast<XIEvent*>(xev->xcookie.data);
142 XIDeviceEvent* xiev = reinterpret_cast<XIDeviceEvent*>(event); 142 XIDeviceEvent* xiev = reinterpret_cast<XIDeviceEvent*>(event);
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 285
286 void TouchFactory::SetPointerDeviceForTest( 286 void TouchFactory::SetPointerDeviceForTest(
287 const std::vector<int>& devices) { 287 const std::vector<int>& devices) {
288 pointer_device_lookup_.reset(); 288 pointer_device_lookup_.reset();
289 for (std::vector<int>::const_iterator iter = devices.begin(); 289 for (std::vector<int>::const_iterator iter = devices.begin();
290 iter != devices.end(); ++iter) { 290 iter != devices.end(); ++iter) {
291 pointer_device_lookup_[*iter] = true; 291 pointer_device_lookup_[*iter] = true;
292 } 292 }
293 } 293 }
294 294
295 void TouchFactory::CacheTouchscreenIds(int device_id) { 295 void TouchFactory::CacheTouchscreenIds(Display* display, int device_id) {
296 if (!DeviceDataManager::HasInstance()) 296 XDevice* device = XOpenDevice(display, device_id);
297 if (!device)
297 return; 298 return;
298 std::vector<TouchscreenDevice> touchscreens = 299
299 DeviceDataManager::GetInstance()->touchscreen_devices(); 300 Atom actual_type_return;
300 const auto it = 301 int actual_format_return;
301 std::find_if(touchscreens.begin(), touchscreens.end(), 302 unsigned long nitems_return;
302 [device_id](const TouchscreenDevice& touchscreen) { 303 unsigned long bytes_after_return;
303 return touchscreen.id == device_id; 304 unsigned char *prop_return;
304 }); 305
305 // Internal displays will have a vid and pid of 0. Ignore them. 306 const char kDeviceProductIdString[] = "Device Product ID";
306 if (it != touchscreens.end() && it->vendor_id && it->product_id) 307 Atom device_product_id_atom =
307 touchscreen_ids_.insert(std::make_pair(it->vendor_id, it->product_id)); 308 XInternAtom(display, kDeviceProductIdString, false);
309
310 if (device_product_id_atom != None &&
311 XGetDeviceProperty(display, device, device_product_id_atom, 0, 2,
312 False, XA_INTEGER, &actual_type_return,
313 &actual_format_return, &nitems_return,
314 &bytes_after_return, &prop_return) == Success) {
315 if (actual_type_return == XA_INTEGER &&
316 actual_format_return == 32 &&
317 nitems_return == 2) {
318 // An actual_format_return of 32 implies that the returned data is an
319 // array of longs. See the description of |prop_return| in `man
320 // XGetDeviceProperty` for details.
321 long* ptr = reinterpret_cast<long*>(prop_return);
322
323 // Internal displays will have a vid and pid of 0. Ignore them.
324 // ptr[0] is the vid, and ptr[1] is the pid.
325 if (ptr[0] || ptr[1])
326 touchscreen_ids_.insert(std::make_pair(ptr[0], ptr[1]));
327 }
328 XFree(prop_return);
329 }
330
331 XCloseDevice(display, device);
308 } 332 }
309 333
310 } // namespace ui 334 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/devices/x11/touch_factory_x11.h ('k') | ui/events/event.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698