---
# System prepended metadata

title: Event in Chromium
tags: [Chromium-Graphics, elkurin-daily-note]

---

# Event in Chromium

[Event](https://source.chromium.org/chromium/chromium/src/+/main:ui/events/event.h;l=51;drc=31fb07c05718d671d96c227855bfe97af9e3fb20) represents an input event in Chromium.  
Let's see the types of Events.

## LocatedEvent
[LocatedEvent](https://source.chromium.org/chromium/chromium/src/+/main:ui/events/event.h;l=345;drc=31fb07c05718d671d96c227855bfe97af9e3fb20) is an event type which is based on the location information.  
For example, the mouse event has a cursor position. Touchscreen events also have a position where the user touches.  
This information is stored as [location_](https://source.chromium.org/chromium/chromium/src/+/main:ui/events/event.h;l=423;drc=31fb07c05718d671d96c227855bfe97af9e3fb20).  
`location_` is a position relative to the target window in the target window coordinate space. TO check the location on root window coordinates, you can refer to `root_location_`. This is against a screen for client, or against display.

There multiple types using location information.  
Such events extends LocatedEvent to implement the details.  
Followings are the examples.

### MouseEvent
[MouseEvent](https://source.chromium.org/chromium/chromium/src/+/main:ui/events/event.h;l=433;drc=31fb07c05718d671d96c227855bfe97af9e3fb20) is one of the LocatedEvent.  
This event is dispatched by mouse but also by touchpad.

Mouse has [several buttons](https://source.chromium.org/chromium/chromium/src/+/main:ui/events/event_constants.h;l=41-45;drc=31fb07c05718d671d96c227855bfe97af9e3fb20).  
Here's the list of the mouse button input that Chromium handles.
```cpp=
constexpr EventFlags EF_LEFT_MOUSE_BUTTON = 1 << 11;
constexpr EventFlags EF_MIDDLE_MOUSE_BUTTON = 1 << 12;
constexpr EventFlags EF_RIGHT_MOUSE_BUTTON = 1 << 13;
constexpr EventFlags EF_BACK_MOUSE_BUTTON = 1 << 14;
constexpr EventFlags EF_FORWARD_MOUSE_BUTTON = 1 << 15;
```

It does contain not only the location, but also [`movement_`](https://source.chromium.org/chromium/chromium/src/+/main:ui/events/event.h;l=590;drc=31fb07c05718d671d96c227855bfe97af9e3fb20) and flags.  

`movement_` is gfx::Vector2dF. It's raw mouse movement value reported from mouse hardware.  

[Flags](https://source.chromium.org/chromium/chromium/src/+/main:ui/events/event_constants.h;l=75-99;drc=31fb07c05718d671d96c227855bfe97af9e3fb20) can carry the information such as the click count (EF_IS_DOUBLE_CLICK, TD_IS_TRIPLE_CLICK).  
Or EF_CURSOR_HIDE is set when the cursor is just hidden.

There are some special mouse events:
- [MouseWheelEvent](https://source.chromium.org/chromium/chromium/src/+/main:ui/events/event.h;l=601;drc=31fb07c05718d671d96c227855bfe97af9e3fb20): Carries `offset_` and `tick_120ths_`.
- [ScrollEvent](https://source.chromium.org/chromium/chromium/src/+/main:ui/events/event.h;l=977;drc=31fb07c05718d671d96c227855bfe97af9e3fb20): Carries `offset_`, `finger_count_`...  ScrollEvent behaves differently depending on how many fingers are used to scroll.

### TouchEvent
[TouchEvent](https://source.chromium.org/chromium/chromium/src/+/main:ui/events/event.h;l=657;drc=31fb07c05718d671d96c227855bfe97af9e3fb20) is an event with finger touch on the screen or Pen (stylus).  
TouchEvent is a bit similar to MouseEvent.  
[PointerDetails](https://source.chromium.org/chromium/chromium/src/+/main:ui/events/pointer_details.h;l=29;drc=31fb07c05718d671d96c227855bfe97af9e3fb20) is used to describe the details for example how it is touched (twist, tangential_pressure).

### GestureEvent
[GestureEvent](https://source.chromium.org/chromium/chromium/src/+/main:ui/events/event.h;l=1056;drc=31fb07c05718d671d96c227855bfe97af9e3fb20) contains a `details_` whose type is [GestureEventDetails](https://source.chromium.org/chromium/chromium/src/+/main:ui/events/gesture_event_details.h;l=22;drc=31fb07c05718d671d96c227855bfe97af9e3fb20).  
GestureEvent holds a movement gesture like two fingers swipe.  
The device using this input is touchpad or touchscreen. It's described in [GestureDeviceType](https://source.chromium.org/chromium/chromium/src/+/main:ui/events/event_constants.h;l=210;drc=31fb07c05718d671d96c227855bfe97af9e3fb20).

[Details](https://source.chromium.org/chromium/chromium/src/+/main:ui/events/gesture_event_details.h;l=227;drc=31fb07c05718d671d96c227855bfe97af9e3fb20) is a union of gestures, scroll_begin, scroll_update, scale, fling_velocity, first_finger_enclosing_rectangle, swip, tap_count or tap_down_count.

## KeyEvent
[KeyEvent](https://source.chromium.org/chromium/chromium/src/+/main:ui/events/event.h;l=787;drc=31fb07c05718d671d96c227855bfe97af9e3fb20), on the other hand, does not have a location information.  
Let's dig into the KeyEvent in the future.

## CancelModeEvent
[CancelModeEvent](https://source.chromium.org/chromium/chromium/src/+/main:ui/events/event.h;l=336;drc=31fb07c05718d671d96c227855bfe97af9e3fb20) is an event to cancel everything.  
Sent by the system to indicate any modal type operations should stop.