gesture_configuration_aura.cc 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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
  3. // found in the LICENSE file.
  4. #include "ui/events/gesture_detection/gesture_configuration.h"
  5. #include "base/command_line.h"
  6. #include "base/memory/singleton.h"
  7. #include "base/strings/string_number_conversions.h"
  8. #include "build/chromeos_buildflags.h"
  9. #include "ui/events/event_switches.h"
  10. namespace ui {
  11. namespace {
  12. #if BUILDFLAG(IS_CHROMEOS_ASH)
  13. constexpr bool kDoubleTapAuraSupport = true;
  14. #else
  15. constexpr bool kDoubleTapAuraSupport = false;
  16. #endif // BUILDFLAG(IS_CHROMEOS_ASH)
  17. class GestureConfigurationAura : public GestureConfiguration {
  18. public:
  19. GestureConfigurationAura(const GestureConfigurationAura&) = delete;
  20. GestureConfigurationAura& operator=(const GestureConfigurationAura&) = delete;
  21. ~GestureConfigurationAura() override {
  22. }
  23. static GestureConfigurationAura* GetInstance() {
  24. return base::Singleton<GestureConfigurationAura>::get();
  25. }
  26. private:
  27. GestureConfigurationAura() : GestureConfiguration() {
  28. #if BUILDFLAG(IS_CHROMEOS)
  29. // On ChromeOS, use 6 which is derived from the android's default(8),
  30. // multiplied by base dpi ratio(0.75). See crbug.com/1083120 for more
  31. // details.
  32. set_max_touch_move_in_pixels_for_click(6);
  33. #endif
  34. double touch_slop_distance;
  35. base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
  36. if (command_line->HasSwitch(switches::kTouchSlopDistance) &&
  37. base::StringToDouble(
  38. command_line->GetSwitchValueASCII(switches::kTouchSlopDistance),
  39. &touch_slop_distance)) {
  40. set_max_touch_move_in_pixels_for_click(touch_slop_distance);
  41. }
  42. set_double_tap_enabled(kDoubleTapAuraSupport);
  43. set_double_tap_timeout_in_ms(double_tap_timeout_in_ms());
  44. set_gesture_begin_end_types_enabled(true);
  45. set_min_gesture_bounds_length(default_radius());
  46. set_min_pinch_update_span_delta(
  47. base::CommandLine::ForCurrentProcess()->HasSwitch(
  48. switches::kCompensateForUnstablePinchZoom)
  49. ? 5
  50. : 0);
  51. set_velocity_tracker_strategy(VelocityTracker::Strategy::LSQ2_RESTRICTED);
  52. set_span_slop(max_touch_move_in_pixels_for_click() * 2);
  53. set_swipe_enabled(true);
  54. set_two_finger_tap_enabled(true);
  55. set_fling_touchpad_tap_suppression_enabled(true);
  56. set_fling_touchscreen_tap_suppression_enabled(true);
  57. }
  58. friend struct base::DefaultSingletonTraits<GestureConfigurationAura>;
  59. };
  60. } // namespace
  61. // Create a GestureConfigurationAura singleton instance when using aura.
  62. GestureConfiguration* GestureConfiguration::GetPlatformSpecificInstance() {
  63. return GestureConfigurationAura::GetInstance();
  64. }
  65. } // namespace ui