Chromium Code Reviews| Index: ui/events/ozone/evdev/libgestures_glue/gesture_property_provider.cc |
| diff --git a/ui/events/ozone/evdev/libgestures_glue/gesture_property_provider.cc b/ui/events/ozone/evdev/libgestures_glue/gesture_property_provider.cc |
| index 766ffb25ea019179d493f621b96461821ad7d16c..8056539fc5eb750f93e1ac954014f806954a89fb 100644 |
| --- a/ui/events/ozone/evdev/libgestures_glue/gesture_property_provider.cc |
| +++ b/ui/events/ozone/evdev/libgestures_glue/gesture_property_provider.cc |
| @@ -431,30 +431,47 @@ const char* kFalse[] = {"off", "false", "no"}; |
| // Check if a device falls into one device type category. |
| bool IsDeviceOfType(const ui::GesturePropertyProvider::DevicePtr device, |
| - const ui::EventDeviceType type) { |
| + const ui::EventDeviceType type, |
| + const GesturesProp* device_mouse, |
|
spang
2015/02/04 17:47:10
device_mouse_property
Shecky Lin
2015/02/06 04:51:14
Done.
|
| + const GesturesProp* device_touchpad) { |
|
spang
2015/02/04 17:47:10
device_touchpad_property
Shecky Lin
2015/02/06 04:51:14
Done.
|
| + // Get the device type info from gesture properties if they are available. |
| + bool is_mouse = false, is_touchpad = false; |
| + if (device_mouse) |
| + is_mouse = device_mouse->GetBoolValue()[0]; |
|
spang
2015/02/04 17:47:10
else
is_mouse = (evdev_class == EvdevClassMouse
Shecky Lin
2015/02/06 04:51:14
Done.
|
| + if (device_touchpad) |
| + is_touchpad = device_touchpad->GetBoolValue()[0]; |
|
spang
2015/02/04 17:47:10
else
is_touchpad = (evdev_class == EvdevClassTou
Shecky Lin
2015/02/06 04:51:14
Done.
|
| + |
| + // If the device type properties are unavailable, fallback to the libevdev |
| + // device info. |
| EvdevClass evdev_class = device->info.evdev_class; |
| switch (type) { |
| case ui::DT_KEYBOARD: |
| return (evdev_class == EvdevClassKeyboard); |
| break; |
| case ui::DT_MOUSE: |
| + if (device_mouse) |
| + return is_mouse; |
| return (evdev_class == EvdevClassMouse || |
| evdev_class == EvdevClassMultitouchMouse); |
| break; |
| case ui::DT_TOUCHPAD: |
| - // Note that the behavior here is different from the inputcontrol script |
| - // which actually returns touchscreen devices as well. |
| + if (device_mouse && device_mouse) |
| + return (!is_mouse) && is_touchpad; |
| return (evdev_class == EvdevClassTouchpad); |
| break; |
| case ui::DT_TOUCHSCREEN: |
| return (evdev_class == EvdevClassTouchscreen); |
| break; |
| case ui::DT_MULTITOUCH: |
| + if (device_touchpad) |
| + return is_touchpad; |
| return (evdev_class == EvdevClassTouchpad || |
| evdev_class == EvdevClassTouchscreen || |
| evdev_class == EvdevClassMultitouchMouse); |
| break; |
| case ui::DT_MULTITOUCH_MOUSE: |
| + if (device_mouse && device_mouse) |
| + return is_mouse && is_touchpad; |
| return (evdev_class == EvdevClassMultitouchMouse); |
| break; |
| case ui::DT_ALL: |
| @@ -855,7 +872,7 @@ bool GesturePropertyProvider::GetDeviceIdsByType( |
| bool exists = false; |
| DeviceMap::const_iterator it = device_map_.begin(); |
| for (; it != device_map_.end(); ++it) { |
| - if (IsDeviceOfType(it->second, type)) { |
| + if (IsDeviceIdOfType(it->first, type)) { |
| exists = true; |
| if (device_ids) |
| device_ids->push_back(it->first); |
| @@ -869,7 +886,9 @@ bool GesturePropertyProvider::IsDeviceIdOfType(const DeviceId device_id, |
| DeviceMap::const_iterator it = device_map_.find(device_id); |
| if (it == device_map_.end()) |
| return false; |
| - return IsDeviceOfType(it->second, type); |
| + return IsDeviceOfType(it->second, type, |
| + GetProperty(device_id, "Device Mouse"), |
| + GetProperty(device_id, "Device Touchpad")); |
| } |
| GesturesProp* GesturePropertyProvider::GetProperty(const DeviceId device_id, |