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

Side by Side Diff: ui/events/ozone/evdev/libgestures_glue/gesture_property_provider.cc

Issue 902543002: Honor device type properties in gesture_property_provider (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed nits Created 5 years, 10 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/events/ozone/evdev/libgestures_glue/gesture_property_provider.h" 5 #include "ui/events/ozone/evdev/libgestures_glue/gesture_property_provider.h"
6 6
7 #include <gestures/gestures.h> 7 #include <gestures/gestures.h>
8 #include <libevdev/libevdev.h> 8 #include <libevdev/libevdev.h>
9 9
10 #include <fnmatch.h> 10 #include <fnmatch.h>
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 "MatchIsKeyboard", 424 "MatchIsKeyboard",
425 "MatchIsJoystick", 425 "MatchIsJoystick",
426 "MatchIsTablet"}; 426 "MatchIsTablet"};
427 427
428 // Special keywords for boolean values. 428 // Special keywords for boolean values.
429 const char* kTrue[] = {"on", "true", "yes"}; 429 const char* kTrue[] = {"on", "true", "yes"};
430 const char* kFalse[] = {"off", "false", "no"}; 430 const char* kFalse[] = {"off", "false", "no"};
431 431
432 // Check if a device falls into one device type category. 432 // Check if a device falls into one device type category.
433 bool IsDeviceOfType(const ui::GesturePropertyProvider::DevicePtr device, 433 bool IsDeviceOfType(const ui::GesturePropertyProvider::DevicePtr device,
434 const ui::EventDeviceType type) { 434 const ui::EventDeviceType type,
435 const GesturesProp* device_mouse_property,
436 const GesturesProp* device_touchpad_property) {
437 // Get the device type info from gesture properties if they are available.
438 // Otherwise, fallback to the libevdev device info.
439 bool is_mouse = false, is_touchpad = false;
435 EvdevClass evdev_class = device->info.evdev_class; 440 EvdevClass evdev_class = device->info.evdev_class;
441 if (device_mouse_property) {
442 is_mouse = device_mouse_property->GetBoolValue()[0];
443 } else {
444 is_mouse = (evdev_class == EvdevClassMouse ||
445 evdev_class == EvdevClassMultitouchMouse);
446 }
447 if (device_touchpad_property) {
448 is_touchpad = device_touchpad_property->GetBoolValue()[0];
449 } else {
450 is_touchpad = (evdev_class == EvdevClassTouchpad ||
451 evdev_class == EvdevClassTouchscreen ||
452 evdev_class == EvdevClassMultitouchMouse);
453 }
454
436 switch (type) { 455 switch (type) {
437 case ui::DT_KEYBOARD: 456 case ui::DT_KEYBOARD:
438 return (evdev_class == EvdevClassKeyboard); 457 return (evdev_class == EvdevClassKeyboard);
439 break; 458 break;
440 case ui::DT_MOUSE: 459 case ui::DT_MOUSE:
441 return (evdev_class == EvdevClassMouse || 460 return is_mouse;
442 evdev_class == EvdevClassMultitouchMouse);
443 break; 461 break;
444 case ui::DT_TOUCHPAD: 462 case ui::DT_TOUCHPAD:
445 // Note that the behavior here is different from the inputcontrol script 463 return (!is_mouse) && is_touchpad;
446 // which actually returns touchscreen devices as well.
447 return (evdev_class == EvdevClassTouchpad);
448 break; 464 break;
449 case ui::DT_TOUCHSCREEN: 465 case ui::DT_TOUCHSCREEN:
450 return (evdev_class == EvdevClassTouchscreen); 466 return (evdev_class == EvdevClassTouchscreen);
451 break; 467 break;
452 case ui::DT_MULTITOUCH: 468 case ui::DT_MULTITOUCH:
453 return (evdev_class == EvdevClassTouchpad || 469 return is_touchpad;
454 evdev_class == EvdevClassTouchscreen ||
455 evdev_class == EvdevClassMultitouchMouse);
456 break; 470 break;
457 case ui::DT_MULTITOUCH_MOUSE: 471 case ui::DT_MULTITOUCH_MOUSE:
458 return (evdev_class == EvdevClassMultitouchMouse); 472 return is_mouse && is_touchpad;
459 break; 473 break;
460 case ui::DT_ALL: 474 case ui::DT_ALL:
461 return true; 475 return true;
462 break; 476 break;
463 default: 477 default:
464 break; 478 break;
465 } 479 }
466 return false; 480 return false;
467 } 481 }
468 482
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 862
849 GesturePropertyProvider::~GesturePropertyProvider() { 863 GesturePropertyProvider::~GesturePropertyProvider() {
850 } 864 }
851 865
852 bool GesturePropertyProvider::GetDeviceIdsByType( 866 bool GesturePropertyProvider::GetDeviceIdsByType(
853 const EventDeviceType type, 867 const EventDeviceType type,
854 std::vector<DeviceId>* device_ids) { 868 std::vector<DeviceId>* device_ids) {
855 bool exists = false; 869 bool exists = false;
856 DeviceMap::const_iterator it = device_map_.begin(); 870 DeviceMap::const_iterator it = device_map_.begin();
857 for (; it != device_map_.end(); ++it) { 871 for (; it != device_map_.end(); ++it) {
858 if (IsDeviceOfType(it->second, type)) { 872 if (IsDeviceIdOfType(it->first, type)) {
859 exists = true; 873 exists = true;
860 if (device_ids) 874 if (device_ids)
861 device_ids->push_back(it->first); 875 device_ids->push_back(it->first);
862 } 876 }
863 } 877 }
864 return exists; 878 return exists;
865 } 879 }
866 880
867 bool GesturePropertyProvider::IsDeviceIdOfType(const DeviceId device_id, 881 bool GesturePropertyProvider::IsDeviceIdOfType(const DeviceId device_id,
868 const EventDeviceType type) { 882 const EventDeviceType type) {
869 DeviceMap::const_iterator it = device_map_.find(device_id); 883 DeviceMap::const_iterator it = device_map_.find(device_id);
870 if (it == device_map_.end()) 884 if (it == device_map_.end())
871 return false; 885 return false;
872 return IsDeviceOfType(it->second, type); 886 return IsDeviceOfType(it->second, type,
887 GetProperty(device_id, "Device Mouse"),
888 GetProperty(device_id, "Device Touchpad"));
873 } 889 }
874 890
875 GesturesProp* GesturePropertyProvider::GetProperty(const DeviceId device_id, 891 GesturesProp* GesturePropertyProvider::GetProperty(const DeviceId device_id,
876 const std::string& name) { 892 const std::string& name) {
877 return FindProperty(device_id, name); 893 return FindProperty(device_id, name);
878 } 894 }
879 895
880 std::vector<std::string> GesturePropertyProvider::GetPropertyNamesById( 896 std::vector<std::string> GesturePropertyProvider::GetPropertyNamesById(
881 const DeviceId device_id) { 897 const DeviceId device_id) {
882 internal::GestureDevicePropertyData* device_data = 898 internal::GestureDevicePropertyData* device_data =
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
1524 const GesturesPropProvider kGesturePropProvider = { 1540 const GesturesPropProvider kGesturePropProvider = {
1525 GesturesPropFunctionsWrapper::CreateInt, 1541 GesturesPropFunctionsWrapper::CreateInt,
1526 GesturesPropFunctionsWrapper::CreateShort, 1542 GesturesPropFunctionsWrapper::CreateShort,
1527 GesturesPropFunctionsWrapper::CreateBool, 1543 GesturesPropFunctionsWrapper::CreateBool,
1528 GesturesPropFunctionsWrapper::CreateString, 1544 GesturesPropFunctionsWrapper::CreateString,
1529 GesturesPropFunctionsWrapper::CreateReal, 1545 GesturesPropFunctionsWrapper::CreateReal,
1530 GesturesPropFunctionsWrapper::RegisterHandlers, 1546 GesturesPropFunctionsWrapper::RegisterHandlers,
1531 GesturesPropFunctionsWrapper::Free}; 1547 GesturesPropFunctionsWrapper::Free};
1532 1548
1533 } // namespace ui 1549 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698