File: motion_event_android_native.h

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 (103 lines) | stat: -rw-r--r-- 4,009 bytes parent folder | download | duplicates (6)
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef UI_EVENTS_ANDROID_MOTION_EVENT_ANDROID_NATIVE_H_
#define UI_EVENTS_ANDROID_MOTION_EVENT_ANDROID_NATIVE_H_

#include <android/input.h>
#include <jni.h>
#include <stddef.h>
#include <stdint.h>

#include <memory>
#include <optional>

#include "base/android/scoped_input_event.h"
#include "base/android/scoped_java_ref.h"
#include "base/memory/raw_ptr.h"
#include "base/time/time.h"
#include "ui/events/android/motion_event_android.h"
#include "ui/events/events_export.h"
#include "ui/events/velocity_tracker/motion_event.h"
#include "ui/gfx/geometry/point_f.h"

namespace ui {

class EVENTS_EXPORT MotionEventAndroidNative : public MotionEventAndroid {
 public:
  ~MotionEventAndroidNative() override;

  // Disallow copy/assign.
  MotionEventAndroidNative(const MotionEventAndroidNative& e) = delete;
  void operator=(const MotionEventAndroidNative&) = delete;

  // Start ui::MotionEvent overrides
  int GetPointerId(size_t pointer_index) const override;
  float GetX(size_t pointer_index) const override;
  float GetY(size_t pointer_index) const override;
  float GetTouchMajor(size_t pointer_index) const override;
  float GetTouchMinor(size_t pointer_index) const override;
  float GetOrientation(size_t pointer_index) const override;
  float GetPressure(size_t pointer_index) const override;
  float GetTiltX(size_t pointer_index) const override;
  float GetTiltY(size_t pointer_index) const override;
  base::TimeTicks GetHistoricalEventTime(
      size_t historical_index) const override;
  float GetHistoricalTouchMajor(size_t pointer_index,
                                size_t historical_index) const override;
  float GetHistoricalX(size_t pointer_index,
                       size_t historical_index) const override;
  float GetHistoricalY(size_t pointer_index,
                       size_t historical_index) const override;
  ToolType GetToolType(size_t pointer_index) const override;
  // End ui::MotionEvent overrides

  // Start MotionEventAndroid overrides
  float GetXPix(size_t pointer_index) const override;
  float GetYPix(size_t pointer_index) const override;
  // End MotionEventAndroid overrides

  struct EventTimes {
    base::TimeTicks oldest;
    base::TimeTicks latest;
  };
  static std::unique_ptr<MotionEventAndroid> Create(
      base::android::ScopedInputEvent input_event,
      float pix_to_dip,
      float y_offset_pix,
      std::optional<EventTimes> event_times);

 private:
  MotionEventAndroidNative(base::android::ScopedInputEvent input_event,
                           float pix_to_dip,
                           float ticks_x,
                           float ticks_y,
                           float tick_multiplier,
                           base::TimeTicks oldest_event_time,
                           base::TimeTicks latest_event_time,
                           base::TimeTicks cached_down_time_ms,
                           int android_action,
                           int pointer_count,
                           int history_size,
                           int action_index,
                           int android_action_button,
                           int android_gesture_classification,
                           int android_button_state,
                           int meta_state,
                           int source,
                           float raw_offset_x_pixels,
                           float raw_offset_y_pixels,
                           bool for_touch_handle,
                           const Pointer* const pointer0,
                           const Pointer* const pointer1,
                           float y_offset_pix);

  const base::android::ScopedInputEvent native_event_;
  // Amount of value to offset Y axis values by to accommodate for top controls.
  float y_offset_pix_;
};

}  // namespace ui

#endif  // UI_EVENTS_ANDROID_MOTION_EVENT_ANDROID_NATIVE_H_