summaryrefslogtreecommitdiffstats
path: root/ui/mojo/events/input_events.mojom
blob: 43b55e58ef540eb00ec5e95fb94ccdfcb9fc42db (plain)
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
104
105
106
107
108
109
110
111
112
113
114
115
116
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

module mojo;

import "ui/mojo/events/input_event_constants.mojom";
import "ui/mojo/events/input_key_codes.mojom";
import "ui/mojo/geometry/geometry.mojom";

struct KeyData {
  // The chromium event key code; these values are from the ui/ KeyCode enum,
  // which has the fun property of being neither consistently the Windows key
  // code, nor the X11 keycodes. (This value is consistent across platforms
  // for basic ASCII characters; it will differ for modifiers. We don't define
  // this as a mojo enum because mojom doesn't appear to have a platform
  // dependent preprocessor yet.)
  //
  // TODO(erg): Remove this, and declare Win32 keycodes correct by fiat. We can
  // not do this until we remove ui::Event usage from within mojo.
  int32 key_code;

  // Whether this is a character event, and the character value if it is. Note
  // that this is different than |text|, which holds a value even when there
  // isn't actually a character to insert. (For example, |text| will be set and
  // have a value on backspace, and |character| won't.)
  bool is_char;
  uint16 character;

  // The Win32 key code. Because of the web, this is the closest thing that we
  // have to a cross platform key state.
  KeyboardCode windows_key_code;

  // The platform specific key code.
  //
  // TODO(erg): This exists only for NPAPI support, pepper USB keyboard support
  // and IME on android support. Theoretically, we should be able to remove this
  // in the medium to long term.
  int32 native_key_code;

  // The text generated by this keystroke. Corresponds to
  // blink::WebKeyboardEvent::text.
  uint16 text;

  // Like |text|, but unmodified by concurrently held modifier keys (except
  // shift). Corresponds to blink::WebKeyboardEvent::unmodifiedText.
  uint16 unmodified_text;
};

struct LocationData {
  // |x| and |y| are in the coordinate system of the View.
  // Typically, this will be an integer-valued translation w.r.t.
  // the screen and in this case, |x| and |y| are in units of physical
  // pixels. However, some View embedders may apply arbitrary transformations
  // of a view w.r.t. the screen.
  float x;
  float y;
  // |screen_x| and |screen_y| are in screen coordinates in units of
  // physical pixels.
  float screen_x;
  float screen_y;
};

// TODO(rjkroege,sadrul): Add gesture representation.
struct PointerData {
  int32 pointer_id;
  PointerKind kind;
  LocationData location;
  // Some devices (e.g. pen, finger) can extend across multiple pixels
  // at once. |brush_data| provides additional data for this case and
  // is available when |kind| is PEN or TOUCH.
  BrushData? brush_data;
  // Only set for |WHEEL| events.
  WheelData? wheel_data;
};

// Information payload to support
// https://developer.mozilla.org/en-US/docs/Web/Events/wheel.
// TODO(rjkroege): Handle MacOS momentum scrolling.
struct WheelData {
  WheelMode mode;
  // |delta_x|, |delta_y|, |delta_z| can be in units of pixels, lines, pages
  // or control scaling as controlled by |mode|. Pixel scroll is physical
  // pixels in the coordinate system of the target View.
  float delta_x;
  float delta_y;
  float delta_z;
};

// Supplementary data to support pointers where the pointer can
// cover multiple pixels per http://www.w3.org/TR/pointerevents/
struct BrushData {
  // |width| and |height| are in CSS pixels in the coordinate system of
  // the target View.
  float width;
  float height;
  // |pressure| range is [0,1]. For devices like mice buttons where the
  // pressure is not available, it will be set to 0.5 if the button is down.
  float pressure;
  // |tilt_y| and |tilt_z| are in degrees.
  float tilt_y;
  float tilt_z;
};

struct Event {
  // TODO(sky): rename to type.
  EventType action;
  // TODO(sky): parts of this should move to PointerData.
  EventFlags flags;
  // Time in microseconds from when the platform was started.
  // This value accurately orders events w.r.t. to each other but
  // does not position them at an absolute time.
  int64 time_stamp;
  KeyData? key_data;
  PointerData? pointer_data;
};