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

Unified Diff: views/touchui/touch_factory.cc

Issue 7792094: touchui: support XInput2 MT (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Add gyp switch to support both XI2.0 and XI2.1. Correct the style issues also. Created 9 years, 3 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
« views/focus/accelerator_handler_touch.cc ('K') | « views/touchui/touch_factory.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: views/touchui/touch_factory.cc
diff --git a/views/touchui/touch_factory.cc b/views/touchui/touch_factory.cc
index 81dd41deb83ad7d7fb36c71f9d1969ebb4fd9437..4331044feb088eef1010c33dc1a73970a5e0b4f4 100644
--- a/views/touchui/touch_factory.cc
+++ b/views/touchui/touch_factory.cc
@@ -29,9 +29,6 @@ XIValuatorClassInfo* FindTPValuator(Display* display,
views::TouchFactory::TouchParam tp) {
// Lookup table for mapping TouchParam to Atom string used in X.
// A full set of Atom strings can be found at xserver-properties.h.
- // For Slot ID, See this chromeos revision: http://git.chromium.org/gitweb/?
- // p=chromiumos/overlays/chromiumos-overlay.git;
- // a=commit;h=9164d0a75e48c4867e4ef4ab51f743ae231c059a
static struct {
views::TouchFactory::TouchParam tp;
const char* atom;
@@ -40,7 +37,12 @@ XIValuatorClassInfo* FindTPValuator(Display* display,
{ views::TouchFactory::TP_TOUCH_MINOR, "Abs MT Touch Minor" },
{ views::TouchFactory::TP_ORIENTATION, "Abs MT Orientation" },
{ views::TouchFactory::TP_PRESSURE, "Abs MT Pressure" },
+#if !defined(USE_XI2_1)
+ // For Slot ID, See this chromeos revision: http://git.chromium.org/gitweb/?
+ // p=chromiumos/overlays/chromiumos-overlay.git;
+ // a=commit;h=9164d0a75e48c4867e4ef4ab51f743ae231c059a
{ views::TouchFactory::TP_SLOT_ID, "Abs MT Slot ID" },
+#endif
{ views::TouchFactory::TP_TRACKING_ID, "Abs MT Tracking ID" },
{ views::TouchFactory::TP_LAST_ENTRY, NULL },
};
@@ -126,9 +128,11 @@ TouchFactory::TouchFactory()
: is_cursor_visible_(true),
keep_mouse_cursor_(false),
cursor_timer_(),
+#if !defined(USE_XI2_1)
+ slots_used_(),
+#endif
pointer_device_lookup_(),
- touch_device_list_(),
- slots_used_() {
+ touch_device_list_() {
#if defined(TOUCH_UI)
if (!base::MessagePumpForUI::HasXInput2())
return;
@@ -190,6 +194,7 @@ void TouchFactory::UpdateDeviceList(Display* display) {
int count = 0;
touch_device_lookup_.reset();
touch_device_list_.clear();
+#if !defined(USE_XI2_1)
XDeviceInfo* devlist = XListInputDevices(display, &count);
for (int i = 0; i < count; i++) {
if (devlist[i].type) {
@@ -202,6 +207,7 @@ void TouchFactory::UpdateDeviceList(Display* display) {
}
if (devlist)
XFreeDeviceList(devlist);
+#endif
// Instead of asking X for the list of devices all the time, let's maintain a
// list of pointer devices we care about.
@@ -217,10 +223,26 @@ void TouchFactory::UpdateDeviceList(Display* display) {
// also select on the floating devices.
pointer_device_lookup_.reset();
XIDeviceInfo* devices = XIQueryDevice(display, XIAllDevices, &count);
- for (int i = 0; i < count; i++) {
- XIDeviceInfo* devinfo = devices + i;
- if (devinfo->use == XIFloatingSlave || devinfo->use == XISlavePointer) {
- pointer_device_lookup_[devinfo->deviceid] = true;
+ if (devices) {
+ for (int i = 0; i < count; i++) {
+ if (!devices[i].enabled)
+ continue;
+ XIDeviceInfo* devinfo = devices + i;
+#if defined(USE_XI2_1)
+ for (int k = 0; k < devinfo->num_classes; ++k) {
+ XIAnyClassInfo* xiclassinfo = devinfo->classes[k];
+ if (xiclassinfo->type == XITouchClass) {
+ XITouchClassInfo* tci = (XITouchClassInfo *)xiclassinfo;
+ // Only care direct touch device (such as touch screen) right now
+ if (tci->mode == XIDirectTouch) {
+ touch_device_lookup_[devinfo->deviceid] = true;
+ touch_device_list_.push_back(devinfo->deviceid);
+ }
+ }
+ }
+#endif
+ if (devinfo->use == XIFloatingSlave || devinfo->use == XISlavePointer)
+ pointer_device_lookup_[devinfo->deviceid] = true;
}
}
if (devices)
@@ -231,7 +253,16 @@ void TouchFactory::UpdateDeviceList(Display* display) {
bool TouchFactory::ShouldProcessXI2Event(XEvent* xev) {
DCHECK_EQ(GenericEvent, xev->type);
+#if defined(USE_XI2_1)
+ XIEvent* event = static_cast<XIEvent*>(xev->xcookie.data);
+ if (event->evtype != XI_TouchBegin &&
+ event->evtype != XI_TouchUpdate &&
+ event->evtype != XI_TouchEnd)
+ return true;
+ XIDeviceEvent* xiev = reinterpret_cast<XIDeviceEvent*>(event);
+ return touch_device_lookup_[xiev->sourceid];
+#else
XGenericEventCookie* cookie = &xev->xcookie;
if (cookie->evtype != XI_ButtonPress &&
cookie->evtype != XI_ButtonRelease &&
@@ -240,6 +271,7 @@ bool TouchFactory::ShouldProcessXI2Event(XEvent* xev) {
XIDeviceEvent* xiev = static_cast<XIDeviceEvent*>(cookie->data);
return pointer_device_lookup_[xiev->deviceid];
+#endif
}
void TouchFactory::SetupXI2ForXWindow(Window window) {
@@ -255,9 +287,15 @@ void TouchFactory::SetupXI2ForXWindow(Window window) {
unsigned char mask[XIMaskLen(XI_LASTEVENT)];
memset(mask, 0, sizeof(mask));
+#if defined(USE_XI2_1)
+ XISetMask(mask, XI_TouchBegin);
+ XISetMask(mask, XI_TouchUpdate);
+ XISetMask(mask, XI_TouchEnd);
+#else
sadrul 2011/09/07 14:56:37 I think it'd be a good idea to select for XI_Butto
ningxin.hu 2011/09/08 08:24:50 Yes. It is really a good idea. I am working on thi
XISetMask(mask, XI_ButtonPress);
XISetMask(mask, XI_ButtonRelease);
XISetMask(mask, XI_Motion);
+#endif
XIEventMask evmask;
evmask.deviceid = XIAllDevices;
@@ -286,6 +324,7 @@ bool TouchFactory::IsTouchDevice(unsigned deviceid) const {
touch_device_lookup_[deviceid] : false;
}
+#if !defined(USE_XI2_1)
bool TouchFactory::IsSlotUsed(int slot) const {
CHECK_LT(slot, kMaxTouchPoints);
return slots_used_[slot];
@@ -295,6 +334,7 @@ void TouchFactory::SetSlotUsed(int slot, bool used) {
CHECK_LT(slot, kMaxTouchPoints);
slots_used_[slot] = used;
}
+#endif
bool TouchFactory::GrabTouchDevices(Display* display, ::Window window) {
#if defined(TOUCH_UI)
@@ -307,9 +347,15 @@ bool TouchFactory::GrabTouchDevices(Display* display, ::Window window) {
bool success = true;
memset(mask, 0, sizeof(mask));
+#if defined(USE_XI2_1)
+ XISetMask(mask, XI_TouchBegin);
+ XISetMask(mask, XI_TouchUpdate);
+ XISetMask(mask, XI_TouchEnd);
+#else
sadrul 2011/09/07 14:56:37 ditto
ningxin.hu 2011/09/08 08:24:50 Will select touch and mouse events for XI2.1
XISetMask(mask, XI_ButtonPress);
XISetMask(mask, XI_ButtonRelease);
XISetMask(mask, XI_Motion);
+#endif
XIEventMask evmask;
evmask.mask_len = sizeof(mask);
@@ -415,6 +461,12 @@ bool TouchFactory::ExtractTouchParam(const XEvent& xev,
return true;
}
+ // With XInput 2.1, Tracking ID could be provided in the detail field
+ if (tp == TP_TRACKING_ID) {
+ *value = xiev->detail;
+ return true;
+ }
+
return false;
}
« views/focus/accelerator_handler_touch.cc ('K') | « views/touchui/touch_factory.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698