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

Unified Diff: ui/events/devices/x11/touch_factory_x11.cc

Issue 1073573002: Ozone support for device special cases in keyboard event rewriting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix crash (thanks spang) 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/events/devices/x11/touch_factory_x11.cc
diff --git a/ui/events/devices/x11/touch_factory_x11.cc b/ui/events/devices/x11/touch_factory_x11.cc
index 40c56240d9a189ee1518e38a05fc4a54a75ada1a..a971b1033afc73a6d6ce22b8b835a98d554ed452 100644
--- a/ui/events/devices/x11/touch_factory_x11.cc
+++ b/ui/events/devices/x11/touch_factory_x11.cc
@@ -129,7 +129,7 @@ void TouchFactory::UpdateDeviceList(Display* display) {
reinterpret_cast<XITouchClassInfo*>(xiclassinfo);
// Only care direct touch device (such as touch screen) right now
if (tci->mode == XIDirectTouch)
- CacheTouchscreenIds(display, devinfo.deviceid);
+ CacheTouchscreenIds(devinfo.deviceid);
}
}
}
@@ -292,43 +292,19 @@ void TouchFactory::SetPointerDeviceForTest(
}
}
-void TouchFactory::CacheTouchscreenIds(Display* display, int device_id) {
- XDevice* device = XOpenDevice(display, device_id);
- if (!device)
+void TouchFactory::CacheTouchscreenIds(int device_id) {
+ if (!DeviceDataManager::HasInstance())
return;
-
- Atom actual_type_return;
- int actual_format_return;
- unsigned long nitems_return;
- unsigned long bytes_after_return;
- unsigned char *prop_return;
-
- const char kDeviceProductIdString[] = "Device Product ID";
- Atom device_product_id_atom =
- XInternAtom(display, kDeviceProductIdString, false);
-
- if (device_product_id_atom != None &&
- XGetDeviceProperty(display, device, device_product_id_atom, 0, 2,
- False, XA_INTEGER, &actual_type_return,
- &actual_format_return, &nitems_return,
- &bytes_after_return, &prop_return) == Success) {
- if (actual_type_return == XA_INTEGER &&
- actual_format_return == 32 &&
- nitems_return == 2) {
- // An actual_format_return of 32 implies that the returned data is an
- // array of longs. See the description of |prop_return| in `man
- // XGetDeviceProperty` for details.
- long* ptr = reinterpret_cast<long*>(prop_return);
-
- // Internal displays will have a vid and pid of 0. Ignore them.
- // ptr[0] is the vid, and ptr[1] is the pid.
- if (ptr[0] || ptr[1])
- touchscreen_ids_.insert(std::make_pair(ptr[0], ptr[1]));
- }
- XFree(prop_return);
- }
-
- XCloseDevice(display, device);
+ std::vector<TouchscreenDevice> touchscreens =
+ DeviceDataManager::GetInstance()->touchscreen_devices();
+ const auto it =
+ std::find_if(touchscreens.begin(), touchscreens.end(),
+ [device_id](const TouchscreenDevice& touchscreen) {
+ return touchscreen.id == device_id;
+ });
+ // Internal displays will have a vid and pid of 0. Ignore them.
+ if (it != touchscreens.end() && it->vendor_id && it->product_id)
+ touchscreen_ids_.insert(std::make_pair(it->vendor_id, it->product_id));
}
} // namespace ui
« 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