| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "mojo/services/view_manager/root_node_manager.h" | 5 #include "mojo/services/view_manager/root_node_manager.h" |
| 6 #include "mojo/services/view_manager/window_tree_host_impl.h" | 6 #include "mojo/services/view_manager/window_tree_host_impl.h" |
| 7 #include "mojo/public/c/gles2/gles2.h" | 7 #include "mojo/public/c/gles2/gles2.h" |
| 8 #include "mojo/services/public/cpp/geometry/geometry_type_converters.h" | 8 #include "mojo/services/public/cpp/geometry/geometry_type_converters.h" |
| 9 #include "mojo/services/public/cpp/input_events/input_events_type_converters.h" |
| 9 #include "mojo/services/view_manager/context_factory_impl.h" | 10 #include "mojo/services/view_manager/context_factory_impl.h" |
| 10 #include "ui/aura/env.h" | 11 #include "ui/aura/env.h" |
| 11 #include "ui/aura/layout_manager.h" | 12 #include "ui/aura/layout_manager.h" |
| 12 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
| 13 #include "ui/aura/window_event_dispatcher.h" | 14 #include "ui/aura/window_event_dispatcher.h" |
| 14 #include "ui/compositor/compositor.h" | 15 #include "ui/compositor/compositor.h" |
| 15 #include "ui/events/event.h" | 16 #include "ui/events/event.h" |
| 16 #include "ui/events/event_constants.h" | 17 #include "ui/events/event_constants.h" |
| 17 #include "ui/gfx/geometry/insets.h" | 18 #include "ui/gfx/geometry/insets.h" |
| 18 #include "ui/gfx/geometry/rect.h" | 19 #include "ui/gfx/geometry/rect.h" |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 | 179 |
| 179 void WindowTreeHostImpl::OnDestroyed(const mojo::Callback<void()>& callback) { | 180 void WindowTreeHostImpl::OnDestroyed(const mojo::Callback<void()>& callback) { |
| 180 DestroyCompositor(); | 181 DestroyCompositor(); |
| 181 native_viewport_closed_callback_.Run(); | 182 native_viewport_closed_callback_.Run(); |
| 182 // TODO(beng): quit the message loop once we are on our own thread. | 183 // TODO(beng): quit the message loop once we are on our own thread. |
| 183 callback.Run(); | 184 callback.Run(); |
| 184 } | 185 } |
| 185 | 186 |
| 186 void WindowTreeHostImpl::OnEvent(EventPtr event, | 187 void WindowTreeHostImpl::OnEvent(EventPtr event, |
| 187 const mojo::Callback<void()>& callback) { | 188 const mojo::Callback<void()>& callback) { |
| 188 switch (event->action) { | 189 scoped_ptr<ui::Event> ui_event = |
| 189 case ui::ET_MOUSE_PRESSED: | 190 TypeConverter<EventPtr, scoped_ptr<ui::Event> >::ConvertTo(event); |
| 190 case ui::ET_MOUSE_DRAGGED: | 191 if (ui_event) |
| 191 case ui::ET_MOUSE_RELEASED: | 192 SendEventToProcessor(ui_event.get()); |
| 192 case ui::ET_MOUSE_MOVED: | |
| 193 case ui::ET_MOUSE_ENTERED: | |
| 194 case ui::ET_MOUSE_EXITED: { | |
| 195 gfx::Point location(event->location->x, event->location->y); | |
| 196 ui::MouseEvent ev(static_cast<ui::EventType>(event->action), location, | |
| 197 location, event->flags, 0); | |
| 198 SendEventToProcessor(&ev); | |
| 199 break; | |
| 200 } | |
| 201 case ui::ET_MOUSEWHEEL: { | |
| 202 gfx::Vector2d offset(event->wheel_data->x_offset, | |
| 203 event->wheel_data->y_offset); | |
| 204 gfx::Point location(event->location->x, event->location->y); | |
| 205 ui::MouseWheelEvent ev(offset, location, location, event->flags, 0); | |
| 206 SendEventToProcessor(&ev); | |
| 207 break; | |
| 208 } | |
| 209 case ui::ET_KEY_PRESSED: | |
| 210 case ui::ET_KEY_RELEASED: { | |
| 211 ui::KeyEvent ev( | |
| 212 static_cast<ui::EventType>(event->action), | |
| 213 static_cast<ui::KeyboardCode>(event->key_data->key_code), | |
| 214 event->flags, event->key_data->is_char); | |
| 215 SendEventToProcessor(&ev); | |
| 216 break; | |
| 217 } | |
| 218 // TODO(beng): touch, etc. | |
| 219 } | |
| 220 callback.Run(); | 193 callback.Run(); |
| 221 }; | 194 }; |
| 222 | 195 |
| 223 } // namespace service | 196 } // namespace service |
| 224 } // namespace view_manager | 197 } // namespace view_manager |
| 225 } // namespace mojo | 198 } // namespace mojo |
| OLD | NEW |