| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2013 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 #include "ui/events/ozone/events_ozone.h" | |
| 6 | |
| 7 #include "ui/events/event.h" | |
| 8 #include "ui/events/event_constants.h" | |
| 9 #include "ui/events/event_utils.h" | |
| 10 | |
| 11 namespace ui { | |
| 12 | |
| 13 void UpdateDeviceList() { NOTIMPLEMENTED(); } | |
| 14 | |
| 15 base::TimeDelta EventTimeFromNative(const base::NativeEvent& native_event) { | |
| 16 const ui::Event* event = static_cast<const ui::Event*>(native_event); | |
| 17 return event->time_stamp(); | |
| 18 } | |
| 19 | |
| 20 int EventFlagsFromNative(const base::NativeEvent& native_event) { | |
| 21 const ui::Event* event = static_cast<const ui::Event*>(native_event); | |
| 22 return event->flags(); | |
| 23 } | |
| 24 | |
| 25 EventType EventTypeFromNative(const base::NativeEvent& native_event) { | |
| 26 const ui::Event* event = static_cast<const ui::Event*>(native_event); | |
| 27 return event->type(); | |
| 28 } | |
| 29 | |
| 30 gfx::Point EventSystemLocationFromNative( | |
| 31 const base::NativeEvent& native_event) { | |
| 32 const ui::LocatedEvent* e = | |
| 33 static_cast<const ui::LocatedEvent*>(native_event); | |
| 34 DCHECK(e->IsMouseEvent() || e->IsTouchEvent() || e->IsGestureEvent() || | |
| 35 e->IsScrollEvent()); | |
| 36 return e->location(); | |
| 37 } | |
| 38 | |
| 39 gfx::Point EventLocationFromNative(const base::NativeEvent& native_event) { | |
| 40 return EventSystemLocationFromNative(native_event); | |
| 41 } | |
| 42 | |
| 43 int GetChangedMouseButtonFlagsFromNative( | |
| 44 const base::NativeEvent& native_event) { | |
| 45 const ui::MouseEvent* event = | |
| 46 static_cast<const ui::MouseEvent*>(native_event); | |
| 47 DCHECK(event->IsMouseEvent() || event->IsScrollEvent()); | |
| 48 return event->changed_button_flags(); | |
| 49 } | |
| 50 | |
| 51 KeyboardCode KeyboardCodeFromNative(const base::NativeEvent& native_event) { | |
| 52 const ui::KeyEvent* event = static_cast<const ui::KeyEvent*>(native_event); | |
| 53 DCHECK(event->IsKeyEvent()); | |
| 54 return event->key_code(); | |
| 55 } | |
| 56 | |
| 57 const char* CodeFromNative(const base::NativeEvent& native_event) { | |
| 58 const ui::KeyEvent* event = static_cast<const ui::KeyEvent*>(native_event); | |
| 59 DCHECK(event->IsKeyEvent()); | |
| 60 return event->code().c_str(); | |
| 61 } | |
| 62 | |
| 63 uint32 PlatformKeycodeFromNative(const base::NativeEvent& native_event) { | |
| 64 const ui::KeyEvent* event = static_cast<const ui::KeyEvent*>(native_event); | |
| 65 DCHECK(event->IsKeyEvent()); | |
| 66 return event->platform_keycode(); | |
| 67 } | |
| 68 | |
| 69 bool IsCharFromNative(const base::NativeEvent& native_event) { | |
| 70 const ui::KeyEvent* event = static_cast<const ui::KeyEvent*>(native_event); | |
| 71 DCHECK(event->IsKeyEvent()); | |
| 72 return event->is_char(); | |
| 73 } | |
| 74 | |
| 75 gfx::Vector2d GetMouseWheelOffset(const base::NativeEvent& native_event) { | |
| 76 const ui::MouseWheelEvent* event = | |
| 77 static_cast<const ui::MouseWheelEvent*>(native_event); | |
| 78 DCHECK(event->type() == ET_MOUSEWHEEL); | |
| 79 return event->offset(); | |
| 80 } | |
| 81 | |
| 82 base::NativeEvent CopyNativeEvent(const base::NativeEvent& event) { | |
| 83 return NULL; | |
| 84 } | |
| 85 | |
| 86 void ReleaseCopiedNativeEvent(const base::NativeEvent& event) { | |
| 87 } | |
| 88 | |
| 89 void IncrementTouchIdRefCount(const base::NativeEvent& event) { | |
| 90 } | |
| 91 | |
| 92 void ClearTouchIdIfReleased(const base::NativeEvent& xev) { | |
| 93 } | |
| 94 | |
| 95 int GetTouchId(const base::NativeEvent& native_event) { | |
| 96 const ui::TouchEvent* event = | |
| 97 static_cast<const ui::TouchEvent*>(native_event); | |
| 98 DCHECK(event->IsTouchEvent()); | |
| 99 return event->touch_id(); | |
| 100 } | |
| 101 | |
| 102 float GetTouchRadiusX(const base::NativeEvent& native_event) { | |
| 103 const ui::TouchEvent* event = | |
| 104 static_cast<const ui::TouchEvent*>(native_event); | |
| 105 DCHECK(event->IsTouchEvent()); | |
| 106 return event->radius_x(); | |
| 107 } | |
| 108 | |
| 109 float GetTouchRadiusY(const base::NativeEvent& native_event) { | |
| 110 const ui::TouchEvent* event = | |
| 111 static_cast<const ui::TouchEvent*>(native_event); | |
| 112 DCHECK(event->IsTouchEvent()); | |
| 113 return event->radius_y(); | |
| 114 } | |
| 115 | |
| 116 float GetTouchAngle(const base::NativeEvent& native_event) { | |
| 117 const ui::TouchEvent* event = | |
| 118 static_cast<const ui::TouchEvent*>(native_event); | |
| 119 DCHECK(event->IsTouchEvent()); | |
| 120 return event->rotation_angle(); | |
| 121 } | |
| 122 | |
| 123 float GetTouchForce(const base::NativeEvent& native_event) { | |
| 124 const ui::TouchEvent* event = | |
| 125 static_cast<const ui::TouchEvent*>(native_event); | |
| 126 DCHECK(event->IsTouchEvent()); | |
| 127 return event->force(); | |
| 128 } | |
| 129 | |
| 130 bool GetScrollOffsets(const base::NativeEvent& native_event, | |
| 131 float* x_offset, | |
| 132 float* y_offset, | |
| 133 float* x_offset_ordinal, | |
| 134 float* y_offset_ordinal, | |
| 135 int* finger_count) { | |
| 136 const ui::ScrollEvent* event = | |
| 137 static_cast<const ui::ScrollEvent*>(native_event); | |
| 138 DCHECK(event->IsScrollEvent()); | |
| 139 if (x_offset) | |
| 140 *x_offset = event->x_offset(); | |
| 141 if (y_offset) | |
| 142 *y_offset = event->y_offset(); | |
| 143 if (x_offset_ordinal) | |
| 144 *x_offset_ordinal = event->x_offset_ordinal(); | |
| 145 if (y_offset_ordinal) | |
| 146 *y_offset_ordinal = event->y_offset_ordinal(); | |
| 147 if (finger_count) | |
| 148 *finger_count = event->finger_count(); | |
| 149 | |
| 150 return true; | |
| 151 } | |
| 152 | |
| 153 bool GetFlingData(const base::NativeEvent& native_event, | |
| 154 float* vx, | |
| 155 float* vy, | |
| 156 float* vx_ordinal, | |
| 157 float* vy_ordinal, | |
| 158 bool* is_cancel) { | |
| 159 const ui::ScrollEvent* event = | |
| 160 static_cast<const ui::ScrollEvent*>(native_event); | |
| 161 DCHECK(event->IsScrollEvent()); | |
| 162 if (vx) | |
| 163 *vx = event->x_offset(); | |
| 164 if (vy) | |
| 165 *vy = event->y_offset(); | |
| 166 if (vx_ordinal) | |
| 167 *vx_ordinal = event->x_offset_ordinal(); | |
| 168 if (vy_ordinal) | |
| 169 *vy_ordinal = event->y_offset_ordinal(); | |
| 170 if (is_cancel) | |
| 171 *is_cancel = event->type() == ET_SCROLL_FLING_CANCEL; | |
| 172 | |
| 173 return true; | |
| 174 } | |
| 175 | |
| 176 int GetModifiersFromKeyState() { | |
| 177 NOTIMPLEMENTED(); | |
| 178 return 0; | |
| 179 } | |
| 180 | |
| 181 void DispatchEventFromNativeUiEvent(const base::NativeEvent& native_event, | |
| 182 base::Callback<void(ui::Event*)> callback) { | |
| 183 const ui::Event* native_ui_event = static_cast<ui::Event*>(native_event); | |
| 184 if (native_ui_event->IsKeyEvent()) { | |
| 185 ui::KeyEvent key_event(native_event); | |
| 186 callback.Run(&key_event); | |
| 187 } else if (native_ui_event->IsMouseEvent()) { | |
| 188 ui::MouseEvent mouse_event(native_event); | |
| 189 callback.Run(&mouse_event); | |
| 190 } else if (native_ui_event->IsTouchEvent()) { | |
| 191 ui::TouchEvent touch_event(native_event); | |
| 192 callback.Run(&touch_event); | |
| 193 } else if (native_ui_event->IsScrollEvent()) { | |
| 194 ui::ScrollEvent scroll_event(native_event); | |
| 195 callback.Run(&scroll_event); | |
| 196 } else { | |
| 197 NOTREACHED(); | |
| 198 } | |
| 199 } | |
| 200 | |
| 201 } // namespace ui | |
| OLD | NEW |