Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2011 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 | |
| 5 #ifndef WAYLAND_EVENT_H_ | |
|
Evan Martin
2011/07/22 18:21:22
UI_WAYLAND_EVENTS_WAYLAND_EVENT_H_
(here and every
| |
| 6 #define WAYLAND_EVENT_H_ | |
| 7 | |
| 8 #include <linux/input.h> | |
| 9 #include <stdint.h> | |
| 10 | |
| 11 /* | |
| 12 We define a WaylandEvent as a union of all types of events that Wayland will | |
| 13 send. | |
|
Evan Martin
2011/07/22 18:21:22
Is this at the protocol level? Or is it wrapping
| |
| 14 | |
| 15 The following fields are common for most event types and their use is similar: | |
| 16 - time: | |
| 17 The time of the event. This should be monotonically increasing. | |
|
Evan Martin
2011/07/22 18:21:22
What are the units? (Is this defined in some other
| |
| 18 - state: | |
| 19 The value of the button event as given by evdev. This is 0 if button | |
| 20 isn't pressed. | |
| 21 - modifiers: | |
| 22 Stores all the keyboard modifiers (Ctrl, Alt, Shift, ...) currently | |
| 23 active. The modifiers are values as defined by xkbcommon. | |
| 24 */ | |
| 25 | |
| 26 /* Types of events Wayland will send */ | |
| 27 typedef enum { | |
| 28 WAYLAND_BUTTON, | |
| 29 WAYLAND_KEY, | |
| 30 WAYLAND_MOTION, | |
| 31 WAYLAND_POINTER_FOCUS, | |
| 32 WAYLAND_KEYBOARD_FOCUS, | |
| 33 WAYLAND_GEOMETRY_CHANGE, | |
| 34 } WaylandEventType; | |
| 35 | |
| 36 /* These are the mouse events expected. The event type Wayland sends is an | |
| 37 evdev event. The following is the correct mapping from evdev to expected | |
| 38 events type. | |
| 39 */ | |
| 40 enum WaylandEventButtonType { | |
| 41 LEFT_BUTTON = BTN_LEFT, | |
| 42 MIDDLE_BUTTON = BTN_RIGHT, | |
| 43 RIGHT_BUTTON = BTN_MIDDLE, | |
| 44 SCROLL_UP = BTN_SIDE, | |
| 45 SCROLL_DOWN = BTN_EXTRA, | |
| 46 }; | |
| 47 | |
| 48 struct WaylandEventButton { | |
| 49 WaylandEventType type; | |
| 50 uint32_t time; | |
| 51 /* WaylandEventButtonType defines some of the values button can take */ | |
|
Evan Martin
2011/07/22 18:21:22
C++-style comments, please. Sorry to nag.
| |
| 52 uint32_t button; | |
| 53 uint32_t state; | |
| 54 uint32_t modifiers; | |
| 55 int32_t x; | |
| 56 int32_t y; | |
| 57 }; | |
| 58 | |
| 59 struct WaylandEventKey { | |
| 60 WaylandEventType type; | |
| 61 uint32_t time; | |
| 62 /* The raw key value that evdev returns. */ | |
| 63 uint32_t key; | |
| 64 /* The key symbol returned by processing the raw key using the xkbcommon | |
| 65 library. | |
| 66 */ | |
| 67 uint32_t sym; | |
| 68 uint32_t state; | |
| 69 uint32_t modifiers; | |
| 70 }; | |
| 71 | |
| 72 /* Triggered when there is a motion event. The motion event is triggered | |
| 73 only if there is a window under focus. | |
| 74 */ | |
| 75 struct WaylandEventMotion { | |
| 76 WaylandEventType type; | |
| 77 uint32_t time; | |
| 78 uint32_t modifiers; | |
| 79 int32_t x; | |
| 80 int32_t y; | |
| 81 }; | |
| 82 | |
| 83 /* Triggered when a window enters/exits pointer focus. The state tells us | |
| 84 if the window lost focus (state == 0) or gained focus (state != 0). | |
| 85 */ | |
| 86 struct WaylandEventPointerFocus { | |
| 87 WaylandEventType type; | |
| 88 uint32_t time; | |
| 89 uint32_t state; | |
| 90 int32_t x; | |
| 91 int32_t y; | |
| 92 }; | |
| 93 | |
| 94 /* Triggered when a window enters/exits keyboard focus. The state tells us | |
| 95 if the window lost focus (state == 0) or gained focus (state != 0). | |
| 96 */ | |
| 97 struct WaylandEventKeyboardFocus { | |
| 98 WaylandEventType type; | |
| 99 uint32_t time; | |
| 100 uint32_t state; | |
| 101 uint32_t modifiers; | |
| 102 }; | |
| 103 | |
| 104 /* Event triggered when a window's geometry changes. The event contains the | |
| 105 position and dimensions of the window. | |
| 106 */ | |
| 107 struct WaylandEventGeometryChange { | |
| 108 WaylandEventType type; | |
| 109 uint32_t time; | |
| 110 int32_t x; | |
| 111 int32_t y; | |
| 112 int32_t width; | |
| 113 int32_t height; | |
| 114 }; | |
| 115 | |
| 116 union _WaylandEvent { | |
| 117 WaylandEventType type; | |
| 118 WaylandEventButton button; | |
| 119 WaylandEventKey key; | |
| 120 WaylandEventMotion motion; | |
| 121 WaylandEventPointerFocus pointer_focus; | |
| 122 WaylandEventKeyboardFocus keyboard_focus; | |
| 123 WaylandEventGeometryChange geometry_change; | |
| 124 }; | |
| 125 | |
| 126 typedef _WaylandEvent WaylandEvent; | |
| 127 | |
| 128 #endif | |
| OLD | NEW |