diff options
author | sheckylin@chromium.org <sheckylin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-05 15:00:14 +0000 |
---|---|---|
committer | sheckylin@chromium.org <sheckylin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-05 15:00:14 +0000 |
commit | 33f0eccc6c8fa1616e19fbceeac51c7aed67c9e5 (patch) | |
tree | 3e3c88cc99e675dd55f98bdb95fdc17a6db80307 /ui/base/touch | |
parent | 681739f982a5e4fb720959a5ffb44980253106dc (diff) | |
download | chromium_src-33f0eccc6c8fa1616e19fbceeac51c7aed67c9e5.zip chromium_src-33f0eccc6c8fa1616e19fbceeac51c7aed67c9e5.tar.gz chromium_src-33f0eccc6c8fa1616e19fbceeac51c7aed67c9e5.tar.bz2 |
Handling cursor visibility changing events for ChromeOS
The CL does 5 things:
1. A handler in RootWindowHost that will be called whenever cursor
visibility is changed.
2. An utility function in RootWindowHostLinux that can be used to
set XInput device properties.
3. Use 1) and 2) to temporarily pause trackpad tap-to-click feature
when the cursor is hidden.
4. Add a cache class that caches X input device lists to minimize
round-trip time to X server for device list queries.
5. Refactor around the places where XListInputDevices/XIQueryDevice
queries are used.
Contributed by sheckylin@chromium.org
BUG=chromium:156697,chrome-os-partner:14085
TEST=Tested on link. "Tap paused" was successfully set when visibility
changed.
Change-Id: Ia5c62f821c80efc973e3b1ce54a467b674b466a4
Review URL: https://chromiumcodereview.appspot.com/11316074
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@171223 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/base/touch')
-rw-r--r-- | ui/base/touch/touch_factory.cc | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/ui/base/touch/touch_factory.cc b/ui/base/touch/touch_factory.cc index 14c5b96..ed8b3f0 100644 --- a/ui/base/touch/touch_factory.cc +++ b/ui/base/touch/touch_factory.cc @@ -18,6 +18,7 @@ #include "base/string_number_conversions.h" #include "base/string_split.h" #include "ui/base/ui_base_switches.h" +#include "ui/base/x/device_list_cache_x.h" #include "ui/base/x/x11_util.h" namespace { @@ -108,7 +109,6 @@ void TouchFactory::SetTouchDeviceListFromCommandLine() { void TouchFactory::UpdateDeviceList(Display* display) { // Detect touch devices. - int count = 0; touch_device_available_ = false; touch_device_lookup_.reset(); touch_device_list_.clear(); @@ -120,19 +120,18 @@ void TouchFactory::UpdateDeviceList(Display* display) { // If XInput2 is not supported, this will return null (with count of -1) so // we assume there cannot be any touch devices. // With XI2.1 or older, we allow only single touch devices. - XDeviceInfo* devlist = XListInputDevices(display, &count); - for (int i = 0; i < count; i++) { - if (devlist[i].type) { - XScopedString devtype(XGetAtomName(display, devlist[i].type)); + XDeviceList dev_list = + DeviceListCacheX::GetInstance()->GetXDeviceList(display); + for (int i = 0; i < dev_list.count; i++) { + if (dev_list[i].type) { + XScopedString devtype(XGetAtomName(display, dev_list[i].type)); if (devtype.string() && !strcmp(devtype.string(), XI_TOUCHSCREEN)) { - touch_device_lookup_[devlist[i].id] = true; - touch_device_list_[devlist[i].id] = false; + touch_device_lookup_[dev_list[i].id] = true; + touch_device_list_[dev_list[i].id] = false; touch_device_available_ = true; } } } - if (devlist) - XFreeDeviceList(devlist); #endif // Instead of asking X for the list of devices all the time, let's maintain a @@ -148,9 +147,10 @@ void TouchFactory::UpdateDeviceList(Display* display) { // floating device is not connected to a master device. So it is necessary to // 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; + XIDeviceList xi_dev_list = + DeviceListCacheX::GetInstance()->GetXI2DeviceList(display); + for (int i = 0; i < xi_dev_list.count; i++) { + XIDeviceInfo* devinfo = xi_dev_list.devices + i; if (devinfo->use == XIFloatingSlave || devinfo->use == XIMasterPointer) { #if defined(USE_XI2_MT) for (int k = 0; k < devinfo->num_classes; ++k) { @@ -170,8 +170,6 @@ void TouchFactory::UpdateDeviceList(Display* display) { pointer_device_lookup_[devinfo->deviceid] = true; } } - if (devices) - XIFreeDeviceInfo(devices); } bool TouchFactory::ShouldProcessXI2Event(XEvent* xev) { |