Index: views/touchui/touch_factory.cc |
diff --git a/views/touchui/touch_factory.cc b/views/touchui/touch_factory.cc |
index 658022891e8d0f3c67bf9d1ffc9e778b6a8581bb..003793070fdbbf008a94e3624f13b8e814217661 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; |
@@ -39,9 +36,10 @@ XIValuatorClassInfo* FindTPValuator(Display* display, |
{ views::TouchFactory::TP_TOUCH_MAJOR, "Abs MT Touch Major" }, |
{ views::TouchFactory::TP_TOUCH_MINOR, "Abs MT Touch Minor" }, |
{ views::TouchFactory::TP_ORIENTATION, "Abs MT Orientation" }, |
- { views::TouchFactory::TP_PRESSURE, "Abs MT Pressure" }, |
- { views::TouchFactory::TP_SLOT_ID, "Abs MT Slot ID" }, |
+ { views::TouchFactory::TP_POSITION_X, "Abs MT Position X" }, |
+ { views::TouchFactory::TP_POSITION_Y, "Abs MT Position Y" }, |
{ views::TouchFactory::TP_TRACKING_ID, "Abs MT Tracking ID" }, |
+ { views::TouchFactory::TP_PRESSURE, "Abs MT Pressure" }, |
{ views::TouchFactory::TP_LAST_ENTRY, NULL }, |
}; |
@@ -127,8 +125,7 @@ TouchFactory::TouchFactory() |
keep_mouse_cursor_(false), |
cursor_timer_(), |
pointer_device_lookup_(), |
- touch_device_list_(), |
- slots_used_() { |
+ touch_device_list_() { |
#if defined(TOUCH_UI) |
if (!base::MessagePumpForUI::HasXInput2()) |
return; |
@@ -182,26 +179,9 @@ TouchFactory::~TouchFactory() { |
void TouchFactory::UpdateDeviceList(Display* display) { |
// Detect touch devices. |
- // NOTE: The new API for retrieving the list of devices (XIQueryDevice) does |
- // not provide enough information to detect a touch device. As a result, the |
- // old version of query function (XListInputDevices) is used instead. |
- // If XInput2 is not supported, this will return null (with count of -1) so |
- // we assume there cannot be any touch devices. |
int count = 0; |
touch_device_lookup_.reset(); |
touch_device_list_.clear(); |
- XDeviceInfo* devlist = XListInputDevices(display, &count); |
- for (int i = 0; i < count; i++) { |
- if (devlist[i].type) { |
- const char* devtype = XGetAtomName(display, devlist[i].type); |
- if (devtype && !strcmp(devtype, XI_TOUCHSCREEN)) { |
- touch_device_lookup_[devlist[i].id] = true; |
- touch_device_list_.push_back(devlist[i].id); |
- } |
- } |
- } |
- if (devlist) |
- XFreeDeviceList(devlist); |
// 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 +197,27 @@ 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; |
+ for (int k = 0; k < devices[i].num_classes; ++k) { |
+ XIAnyClassInfo *xiclassinfo = devices[i].classes[k]; |
+ if (xiclassinfo->type == XITouchClass) { |
+ XITouchClassInfo *tci = (XITouchClassInfo *)xiclassinfo; |
sadrul
2011/09/06 14:35:21
'* ' instead of ' *' (here and other places).
|
+ // Only care direct touch device (such as touch screen) right now |
+ if (tci->mode == XIDirectTouch) |
+ { |
sadrul
2011/09/06 14:35:21
Brace goes at the end of the previous line.
|
+ touch_device_lookup_[devinfo->deviceid] = true; |
+ touch_device_list_.push_back(devinfo->deviceid); |
+ } |
+ } |
+ } |
+ if (devinfo->use == XIFloatingSlave || devinfo->use == XISlavePointer) { |
+ pointer_device_lookup_[devinfo->deviceid] = true; |
+ } |
sadrul
2011/09/06 14:35:21
No braces necessary here
|
} |
} |
if (devices) |
@@ -232,14 +229,15 @@ void TouchFactory::UpdateDeviceList(Display* display) { |
bool TouchFactory::ShouldProcessXI2Event(XEvent* xev) { |
DCHECK_EQ(GenericEvent, xev->type); |
- XGenericEventCookie* cookie = &xev->xcookie; |
- if (cookie->evtype != XI_ButtonPress && |
- cookie->evtype != XI_ButtonRelease && |
- cookie->evtype != XI_Motion) |
+ 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 = static_cast<XIDeviceEvent*>(cookie->data); |
- return pointer_device_lookup_[xiev->deviceid]; |
+ XIDeviceEvent* xiev = reinterpret_cast<XIDeviceEvent*>(event); |
+ return touch_device_lookup_[xiev->sourceid]; |
} |
void TouchFactory::SetupXI2ForXWindow(Window window) { |
@@ -255,9 +253,9 @@ void TouchFactory::SetupXI2ForXWindow(Window window) { |
unsigned char mask[XIMaskLen(XI_LASTEVENT)]; |
memset(mask, 0, sizeof(mask)); |
- XISetMask(mask, XI_ButtonPress); |
- XISetMask(mask, XI_ButtonRelease); |
- XISetMask(mask, XI_Motion); |
+ XISetMask(mask, XI_TouchBegin); |
+ XISetMask(mask, XI_TouchUpdate); |
+ XISetMask(mask, XI_TouchEnd); |
XIEventMask evmask; |
evmask.deviceid = XIAllDevices; |
@@ -286,16 +284,6 @@ bool TouchFactory::IsTouchDevice(unsigned deviceid) const { |
touch_device_lookup_[deviceid] : false; |
} |
-bool TouchFactory::IsSlotUsed(int slot) const { |
- CHECK_LT(slot, kMaxTouchPoints); |
- return slots_used_[slot]; |
-} |
- |
-void TouchFactory::SetSlotUsed(int slot, bool used) { |
- CHECK_LT(slot, kMaxTouchPoints); |
- slots_used_[slot] = used; |
-} |
- |
bool TouchFactory::GrabTouchDevices(Display* display, ::Window window) { |
#if defined(TOUCH_UI) |
if (!base::MessagePumpForUI::HasXInput2() || |
@@ -307,9 +295,9 @@ bool TouchFactory::GrabTouchDevices(Display* display, ::Window window) { |
bool success = true; |
memset(mask, 0, sizeof(mask)); |
- XISetMask(mask, XI_ButtonPress); |
- XISetMask(mask, XI_ButtonRelease); |
- XISetMask(mask, XI_Motion); |
+ XISetMask(mask, XI_TouchBegin); |
+ XISetMask(mask, XI_TouchUpdate); |
+ XISetMask(mask, XI_TouchEnd); |
XIEventMask evmask; |
evmask.mask_len = sizeof(mask); |
@@ -414,6 +402,12 @@ bool TouchFactory::ExtractTouchParam(const XEvent& xev, |
return true; |
} |
+ if (tp == TP_TRACKING_ID) |
+ { |
sadrul
2011/09/06 14:35:21
brace in the previous line
|
+ *value = xiev->detail; |
+ return true; |
+ } |
+ |
return false; |
} |