Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(177)

Side by Side Diff: trunk/src/mojo/services/native_viewport/native_viewport_service.cc

Issue 304323005: Revert 273723 "Wire input events through the ViewManagerClient i..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/native_viewport/native_viewport_service.h" 5 #include "mojo/services/native_viewport/native_viewport_service.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "mojo/public/interfaces/service_provider/service_provider.mojom.h" 10 #include "mojo/public/interfaces/service_provider/service_provider.mojom.h"
11 #include "mojo/services/gles2/command_buffer_impl.h" 11 #include "mojo/services/gles2/command_buffer_impl.h"
12 #include "mojo/services/native_viewport/native_viewport.h" 12 #include "mojo/services/native_viewport/native_viewport.h"
13 #include "mojo/services/native_viewport/native_viewport.mojom.h" 13 #include "mojo/services/native_viewport/native_viewport.mojom.h"
14 #include "mojo/services/public/cpp/geometry/geometry_type_converters.h" 14 #include "mojo/services/public/cpp/geometry/geometry_type_converters.h"
15 #include "mojo/services/public/cpp/input_events/input_events_type_converters.h"
16 #include "ui/events/event.h" 15 #include "ui/events/event.h"
17 16
18 namespace mojo { 17 namespace mojo {
19 namespace services { 18 namespace services {
20 namespace { 19 namespace {
21 20
22 bool IsRateLimitedEventType(ui::Event* event) { 21 bool IsRateLimitedEventType(ui::Event* event) {
23 return event->type() == ui::ET_MOUSE_MOVED || 22 return event->type() == ui::ET_MOUSE_MOVED ||
24 event->type() == ui::ET_MOUSE_DRAGGED || 23 event->type() == ui::ET_MOUSE_DRAGGED ||
25 event->type() == ui::ET_TOUCH_MOVED; 24 event->type() == ui::ET_TOUCH_MOVED;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 case ui::ET_TOUCH_RELEASED: 105 case ui::ET_TOUCH_RELEASED:
107 native_viewport_->ReleaseCapture(); 106 native_viewport_->ReleaseCapture();
108 break; 107 break;
109 default: 108 default:
110 break; 109 break;
111 } 110 }
112 111
113 if (waiting_for_event_ack_ && IsRateLimitedEventType(ui_event)) 112 if (waiting_for_event_ack_ && IsRateLimitedEventType(ui_event))
114 return false; 113 return false;
115 114
116 client()->OnEvent( 115 EventPtr event(Event::New());
117 TypeConverter<EventPtr, ui::Event>::ConvertFrom(*ui_event), 116 event->action = ui_event->type();
118 base::Bind(&NativeViewportImpl::AckEvent, 117 event->flags = ui_event->flags();
119 base::Unretained(this))); 118 event->time_stamp = ui_event->time_stamp().ToInternalValue();
119
120 if (ui_event->IsMouseEvent() || ui_event->IsTouchEvent()) {
121 ui::LocatedEvent* located_event =
122 static_cast<ui::LocatedEvent*>(ui_event);
123 event->location = Point::New();
124 event->location->x = located_event->location().x();
125 event->location->y = located_event->location().y();
126 }
127
128 if (ui_event->IsTouchEvent()) {
129 ui::TouchEvent* touch_event = static_cast<ui::TouchEvent*>(ui_event);
130 event->touch_data = TouchData::New();
131 event->touch_data->pointer_id = touch_event->touch_id();
132 } else if (ui_event->IsKeyEvent()) {
133 ui::KeyEvent* key_event = static_cast<ui::KeyEvent*>(ui_event);
134 event->key_data = KeyData::New();
135 event->key_data->key_code = key_event->key_code();
136 event->key_data->is_char = key_event->is_char();
137 }
138
139 client()->OnEvent(event.Pass(),
140 base::Bind(&NativeViewportImpl::AckEvent,
141 base::Unretained(this)));
120 waiting_for_event_ack_ = true; 142 waiting_for_event_ack_ = true;
121 return false; 143 return false;
122 } 144 }
123 145
124 virtual void OnAcceleratedWidgetAvailable( 146 virtual void OnAcceleratedWidgetAvailable(
125 gfx::AcceleratedWidget widget) OVERRIDE { 147 gfx::AcceleratedWidget widget) OVERRIDE {
126 widget_ = widget; 148 widget_ = widget;
127 CreateCommandBufferIfNeeded(); 149 CreateCommandBufferIfNeeded();
128 } 150 }
129 151
(...skipping 23 matching lines...) Expand all
153 175
154 MOJO_NATIVE_VIEWPORT_EXPORT mojo::Application* 176 MOJO_NATIVE_VIEWPORT_EXPORT mojo::Application*
155 CreateNativeViewportService( 177 CreateNativeViewportService(
156 mojo::shell::Context* context, 178 mojo::shell::Context* context,
157 mojo::ScopedMessagePipeHandle service_provider_handle) { 179 mojo::ScopedMessagePipeHandle service_provider_handle) {
158 mojo::Application* app = new mojo::Application( 180 mojo::Application* app = new mojo::Application(
159 service_provider_handle.Pass()); 181 service_provider_handle.Pass());
160 app->AddService<mojo::services::NativeViewportImpl>(context); 182 app->AddService<mojo::services::NativeViewportImpl>(context);
161 return app; 183 return app;
162 } 184 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698