summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-23 17:49:02 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-23 17:49:02 +0000
commit60e102b8c352484ab9535d2d4be244ef24ac74d5 (patch)
treea3d42b8556e874c6a0e6f33be31efe828428938d /views
parent474440d78a17a4bad94e36e14078f3640b37fd92 (diff)
downloadchromium_src-60e102b8c352484ab9535d2d4be244ef24ac74d5.zip
chromium_src-60e102b8c352484ab9535d2d4be244ef24ac74d5.tar.gz
chromium_src-60e102b8c352484ab9535d2d4be244ef24ac74d5.tar.bz2
touch: Detect touch device, and listen for events on floating devices.
BUG=none TEST=none Review URL: http://codereview.chromium.org/6724025 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@79148 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r--views/touchui/touch_factory.cc17
1 files changed, 17 insertions, 0 deletions
diff --git a/views/touchui/touch_factory.cc b/views/touchui/touch_factory.cc
index 99c2ec5..66cdf6b 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() {