event.mojom 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. module ui.mojom;
  5. import "mojo/public/mojom/base/time.mojom";
  6. import "ui/events/mojom/event_constants.mojom";
  7. import "ui/events/mojom/keyboard_codes.mojom";
  8. import "ui/gfx/geometry/mojom/geometry.mojom";
  9. import "ui/latency/mojom/latency_info.mojom";
  10. // The values here correspond to the values defined in ui::KeyEvent.
  11. struct KeyData {
  12. // The VKEY value of the key.
  13. int32 key_code;
  14. // The ui::DomCode value.
  15. uint32 dom_code;
  16. // The ui::DomKey value.
  17. int32 dom_key;
  18. // True if this is a character event, false if this is a keystroke event.
  19. bool is_char;
  20. };
  21. struct LocationData {
  22. // |relative_location| is in the coordinate system of the target and in DIPs.
  23. gfx.mojom.PointF relative_location;
  24. // |root_location| is relative to the client's root and in dips.
  25. gfx.mojom.PointF root_location;
  26. };
  27. // Data to support gesture events.
  28. // TODO(crbug.com/767087): Expand GestureEvent and GestureEventDetails support.
  29. struct GestureData {
  30. LocationData location;
  31. GestureDeviceType device_type;
  32. // The scale of pinch update events.
  33. float scale;
  34. };
  35. // Data to support scroll events.
  36. struct ScrollData {
  37. LocationData location;
  38. // Potential accelerated offsets.
  39. float x_offset;
  40. float y_offset;
  41. // Unaccelerated offsets.
  42. float x_offset_ordinal;
  43. float y_offset_ordinal;
  44. // Number of fingers on the pad.
  45. int32 finger_count;
  46. // For non-fling events, provides momentum information (e.g. for the case
  47. // where the device provides continuous event updates during a fling).
  48. EventMomentumPhase momentum_phase;
  49. // Provides phase information if device can provide.
  50. ScrollEventPhase scroll_event_phase;
  51. };
  52. // This mirrors the C++ class of the same name, see it for details.
  53. struct PointerDetails {
  54. EventPointerType pointer_type;
  55. float radius_x;
  56. float radius_y;
  57. float force;
  58. float tilt_x;
  59. float tilt_y;
  60. float tangential_pressure;
  61. float twist;
  62. int32 id;
  63. int32 offset_x;
  64. int32 offset_y;
  65. };
  66. struct MouseData {
  67. int32 changed_button_flags;
  68. LocationData location;
  69. PointerDetails pointer_details;
  70. // Only used for mouse wheel.
  71. gfx.mojom.Vector2d wheel_offset;
  72. gfx.mojom.Vector2d tick_120ths;
  73. };
  74. // This is used for TouchEvents.
  75. struct TouchData {
  76. bool may_cause_scrolling;
  77. bool hovering;
  78. LocationData location;
  79. PointerDetails pointer_details;
  80. };
  81. struct Event {
  82. // TODO(sky): rename to type.
  83. EventType action;
  84. // A bitfield of kEventFlag* and kMouseEventFlag* values in
  85. // input_event_constants.mojom.
  86. int32 flags;
  87. // This value accurately orders events w.r.t. to each other but does not
  88. // position them at an absolute time since the TimeTicks origin is only
  89. // guaranteed to be fixed during one instance of the application.
  90. mojo_base.mojom.TimeTicks time_stamp;
  91. LatencyInfo latency;
  92. KeyData? key_data;
  93. GestureData? gesture_data;
  94. ScrollData? scroll_data;
  95. TouchData? touch_data;
  96. MouseData? mouse_data;
  97. map<string, array<uint8>>? properties;
  98. };