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

Unified Diff: views/touchui/touch_factory.cc

Issue 6724025: touch: Detect touch device, and listen for events on floating devices. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 9 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 | « base/message_pump_glib_x.cc ('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 99c2ec5ae224018d57df81a6327116d5d548e2c3..66cdf6b3b135d95c7eafbffdecd25832ecd8924b 100644
--- a/views/touchui/touch_factory.cc
+++ b/views/touchui/touch_factory.cc
@@ -5,7 +5,9 @@
#include "views/touchui/touch_factory.h"
#include <X11/cursorfont.h>
+#include <X11/extensions/XInput.h>
#include <X11/extensions/XInput2.h>
+#include <X11/extensions/XIproto.h>
#include "base/compiler_specific.h"
#include "base/logging.h"
@@ -36,6 +38,21 @@ TouchFactory::TouchFactory()
arrow_cursor_ = XCreateFontCursor(display, XC_arrow);
SetCursorVisible(false, false);
+
+ // 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.
+ int count = 0;
+ XDeviceInfo* devlist = XListInputDevices(display, &count);
+ for (int i = 0; i < count; i++) {
+ 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);
+ }
+ }
+ XFreeDeviceList(devlist);
}
TouchFactory::~TouchFactory() {
« no previous file with comments | « base/message_pump_glib_x.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698