File: gesture_configuration_aura.cc

package info (click to toggle)
chromium 138.0.7204.183-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,908 kB
  • sloc: cpp: 34,937,088; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (80 lines) | stat: -rw-r--r-- 2,897 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ui/events/gesture_detection/gesture_configuration.h"

#include "base/command_line.h"
#include "base/memory/singleton.h"
#include "base/strings/string_number_conversions.h"
#include "ui/events/event_switches.h"

namespace ui {
namespace {

#if BUILDFLAG(IS_CHROMEOS)
constexpr bool kDoubleTapAuraSupport = true;
#else
constexpr bool kDoubleTapAuraSupport = false;
#endif  // BUILDFLAG(IS_CHROMEOS)

class GestureConfigurationAura : public GestureConfiguration {
 public:
  GestureConfigurationAura(const GestureConfigurationAura&) = delete;
  GestureConfigurationAura& operator=(const GestureConfigurationAura&) = delete;

  ~GestureConfigurationAura() override {
  }

  static GestureConfigurationAura* GetInstance() {
    return base::Singleton<GestureConfigurationAura>::get();
  }

 private:
  GestureConfigurationAura() : GestureConfiguration() {
#if BUILDFLAG(IS_CHROMEOS)
    // On ChromeOS, the touch slop value of 6 is derived from the android's
    // default(8), multiplied by base dpi ratio(0.75).  See crbug.com/1083120
    // for more details.
    set_max_touch_move_in_pixels_for_click(6);
    // The default stylus slop value of 10 is derived from the UMA data analysis
    // for making stylus clicks easier for users.  See crbug.com/1181872.
    set_max_stylus_move_in_pixels_for_click(10);
#endif
    double touch_slop_distance;
    base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
    if (command_line->HasSwitch(switches::kTouchSlopDistance) &&
        base::StringToDouble(
            command_line->GetSwitchValueASCII(switches::kTouchSlopDistance),
            &touch_slop_distance)) {
      set_max_touch_move_in_pixels_for_click(touch_slop_distance);
    }

    set_double_tap_enabled(kDoubleTapAuraSupport);
    set_double_tap_timeout_in_ms(double_tap_timeout_in_ms());
    set_gesture_begin_end_types_enabled(true);
    set_min_gesture_bounds_length(default_radius());
    set_min_pinch_update_span_delta(
        base::CommandLine::ForCurrentProcess()->HasSwitch(
            switches::kCompensateForUnstablePinchZoom)
            ? 5
            : 0);
    set_velocity_tracker_strategy(VelocityTracker::Strategy::LSQ2_RESTRICTED);
    set_span_slop(max_touch_move_in_pixels_for_click() * 2);
    set_swipe_enabled(true);
    set_two_finger_tap_enabled(true);
    set_fling_touchpad_tap_suppression_enabled(true);
    set_fling_touchscreen_tap_suppression_enabled(true);
  }

  friend struct base::DefaultSingletonTraits<GestureConfigurationAura>;
};

}  // namespace

// Create a GestureConfigurationAura singleton instance when using aura.
GestureConfiguration* GestureConfiguration::GetPlatformSpecificInstance() {
  return GestureConfigurationAura::GetInstance();
}

}  // namespace ui