chromium/content/common/input/input_injector.mojom

// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

module content.mojom;

import "ui/gfx/geometry/mojom/geometry.mojom";
import "ui/events/mojom/scroll_granularity.mojom";
import "mojo/public/mojom/base/time.mojom";

// Describes which type of input events synthetic gesture objects should
// generate. When specifying DEFAULT_INPUT the platform will be queried for
// the preferred input event type.
enum GestureSourceType {
  kDefaultInput,
  kTouchInput,
  kMouseInput,
  kTouchpadInput = kMouseInput,
  kPenInput,
  kGestureSourceTypeMax = kPenInput,
};

enum PointerActionType {
  kNotInitialized,
  kPress,
  kMove,
  kRelease,
  kCancel,
  kLeave,
  kIdle,
};

enum SyntheticButton {
  kNoButton,
  kLeft,
  kMiddle,
  kRight,
  kBack,
  kForward,
};

enum InputEventPattern {
  kDefaultPattern,
  kOnePerVsync,
  kTwoPerVsync,
  kEveryOtherVsync,
};

// The smooth drag gesture parameters sent by the renderer to the browser, that
// are needed to queue the synthetic smooth drag gesture.
struct SyntheticSmoothDrag {
  GestureSourceType gesture_source_type;
  gfx.mojom.PointF start_point;
  array<gfx.mojom.Vector2dF> distances;
  float speed_in_pixels_s;
  float vsync_offset_ms;
  InputEventPattern input_event_pattern;
};

// The smooth drag gesture parameters sent by the renderer to the browser, that
// are needed to queue the synthetic smooth drag gesture.
struct SyntheticSmoothScroll {
  GestureSourceType gesture_source_type;
  gfx.mojom.PointF anchor;
  array<gfx.mojom.Vector2dF> distances;
  bool prevent_fling;
  float speed_in_pixels_s;
  float fling_velocity_x;
  float fling_velocity_y;
  ui.mojom.ScrollGranularity granularity;
  int32 modifiers;
  float vsync_offset_ms;
  InputEventPattern input_event_pattern;
};

// The pinth parameters sent by the renderer to the browser, that are needed to
// queue the synthetic pinch.
struct SyntheticPinch {
  float scale_factor;
  gfx.mojom.PointF anchor;
  float relative_pointer_speed_in_pixels_s;
  float vsync_offset_ms;
  InputEventPattern input_event_pattern;
};

// The tap parameters sent by the renderer to the browser, that are needed to
// queue the synthetic tap.
struct SyntheticTap {
  GestureSourceType gesture_source_type;
  gfx.mojom.PointF position;
  float duration_ms;
};

// It contains all the parameters to create the synthetic events of touch,
// mouse and pen inputs in SyntheticPointerAction::ForwardInputEvents function.
struct SyntheticPointerActionParams {
  PointerActionType pointer_action_type;
  gfx.mojom.PointF position;
  uint32 pointer_id;
  SyntheticButton button;
  int32 key_modifiers;
  float width;
  float height;
  float rotation_angle;
  float force;
  float tangential_pressure;
  int32 tilt_x;
  int32 tilt_y;
  mojo_base.mojom.TimeTicks timestamp;
  mojo_base.mojom.TimeDelta duration;
};

struct SyntheticPointerAction {
  GestureSourceType gesture_source_type;
  array<array<SyntheticPointerActionParams>> params;
};

// Host interface representing the ability to inject input
// from a less priviledged application. Available when
// --enable-gpu-benchmarking command line flag is provided.
interface InputInjector {
  QueueSyntheticSmoothDrag(SyntheticSmoothDrag drag) => ();
  QueueSyntheticSmoothScroll(SyntheticSmoothScroll scroll) => ();
  QueueSyntheticPinch(SyntheticPinch pinch) => ();
  QueueSyntheticTap(SyntheticTap tap) => ();
  QueueSyntheticPointerAction(SyntheticPointerAction pointer_action) => ();
};