gesture_configuration_cast.cc 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright 2018 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 "ui/events/event_switches.h"
  8. namespace ui {
  9. namespace {
  10. class GestureConfigurationCast : public GestureConfiguration {
  11. public:
  12. GestureConfigurationCast(const GestureConfigurationCast&) = delete;
  13. GestureConfigurationCast& operator=(const GestureConfigurationCast&) = delete;
  14. ~GestureConfigurationCast() override {
  15. }
  16. static GestureConfigurationCast* GetInstance() {
  17. return base::Singleton<GestureConfigurationCast>::get();
  18. }
  19. private:
  20. GestureConfigurationCast() : GestureConfiguration() {
  21. set_double_tap_enabled(false);
  22. set_double_tap_timeout_in_ms(double_tap_timeout_in_ms());
  23. set_gesture_begin_end_types_enabled(true);
  24. set_min_gesture_bounds_length(default_radius());
  25. set_min_pinch_update_span_delta(
  26. base::CommandLine::ForCurrentProcess()->HasSwitch(
  27. switches::kCompensateForUnstablePinchZoom)
  28. ? 5
  29. : 0);
  30. set_velocity_tracker_strategy(VelocityTracker::Strategy::LSQ2_RESTRICTED);
  31. set_span_slop(max_touch_move_in_pixels_for_click() * 2);
  32. set_swipe_enabled(true);
  33. set_two_finger_tap_enabled(true);
  34. set_fling_touchpad_tap_suppression_enabled(true);
  35. set_fling_touchscreen_tap_suppression_enabled(true);
  36. set_max_fling_velocity(5000.0f);
  37. }
  38. friend struct base::DefaultSingletonTraits<GestureConfigurationCast>;
  39. };
  40. } // namespace
  41. // Create a GestureConfigurationCast singleton instance when using Chromecast.
  42. GestureConfiguration* GestureConfiguration::GetPlatformSpecificInstance() {
  43. return GestureConfigurationCast::GetInstance();
  44. }
  45. } // namespace ui