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

Side by Side Diff: ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_input_event.cc

Issue 7715021: Add movement information to PPB_MouseInputEvent. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 3 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 (c) 2011 The Native Client Authors. All rights reserved. 1 // Copyright (c) 2011 The Native Client Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can 2 // Use of this source code is governed by a BSD-style license that can
3 // be found in the LICENSE file. 3 // be found in the LICENSE file.
4 4
5 #include "native_client/src/shared/ppapi_proxy/plugin_ppb_input_event.h" 5 #include "native_client/src/shared/ppapi_proxy/plugin_ppb_input_event.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include "native_client/src/include/nacl_scoped_ptr.h" 10 #include "native_client/src/include/nacl_scoped_ptr.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 PP_TimeTicks GetTimeStamp(PP_Resource event) { 123 PP_TimeTicks GetTimeStamp(PP_Resource event) {
124 IMPLEMENT_RESOURCE_THUNK(GetTimeStamp, event, 0.0); 124 IMPLEMENT_RESOURCE_THUNK(GetTimeStamp, event, 0.0);
125 } 125 }
126 126
127 uint32_t GetModifiers(PP_Resource event) { 127 uint32_t GetModifiers(PP_Resource event) {
128 IMPLEMENT_RESOURCE_THUNK(GetModifiers, event, 0); 128 IMPLEMENT_RESOURCE_THUNK(GetModifiers, event, 0);
129 } 129 }
130 130
131 // Mouse ----------------------------------------------------------------------- 131 // Mouse -----------------------------------------------------------------------
132 132
133 PP_Resource CreateMouseInputEvent(PP_Instance instance, 133 PP_Resource CreateMouseInputEvent1_1(PP_Instance instance,
134 PP_InputEvent_Type type, 134 PP_InputEvent_Type type,
135 PP_TimeTicks time_stamp, 135 PP_TimeTicks time_stamp,
136 uint32_t modifiers, 136 uint32_t modifiers,
137 PP_InputEvent_MouseButton mouse_button, 137 PP_InputEvent_MouseButton mouse_button,
138 const PP_Point* mouse_position, 138 const PP_Point* mouse_position,
139 int32_t click_count) { 139 int32_t click_count,
140 const PP_Point* mouse_movement) {
140 DebugPrintf("PPB_InputEvent::CreateMouseInputEvent: instance=" 141 DebugPrintf("PPB_InputEvent::CreateMouseInputEvent: instance="
141 "%"NACL_PRIu32", type=%d, time_stamp=%lf, modifiers=" 142 "%"NACL_PRIu32", type=%d, time_stamp=%lf, modifiers="
142 "%"NACL_PRIu32", mouse_button=%d, x=%"NACL_PRId32", y=" 143 "%"NACL_PRIu32", mouse_button=%d, x=%"NACL_PRId32", y="
143 "%"NACL_PRId32", click_count=%d\n", 144 "%"NACL_PRId32", click_count=%d, movement_x="
145 "%"NACL_PRId32", movement_y=%"NACL_PRId32"\n",
144 instance, type, time_stamp, modifiers, mouse_button, 146 instance, type, time_stamp, modifiers, mouse_button,
145 mouse_position->x, mouse_position->y, click_count); 147 mouse_position->x, mouse_position->y, click_count,
148 mouse_movement->x, mouse_movement->y);
146 PP_Resource resource_id = kInvalidResourceId; 149 PP_Resource resource_id = kInvalidResourceId;
147 NaClSrpcError srpc_result = 150 NaClSrpcError srpc_result =
148 PpbInputEventRpcClient::PPB_InputEvent_CreateMouseInputEvent( 151 PpbInputEventRpcClient::PPB_InputEvent_CreateMouseInputEvent(
149 GetMainSrpcChannel(), 152 GetMainSrpcChannel(),
150 instance, 153 instance,
151 static_cast<int32_t>(type), 154 static_cast<int32_t>(type),
152 time_stamp, 155 time_stamp,
153 static_cast<int32_t>(modifiers), 156 static_cast<int32_t>(modifiers),
154 static_cast<int32_t>(mouse_button), 157 static_cast<int32_t>(mouse_button),
155 mouse_position->x, 158 mouse_position->x,
156 mouse_position->y, 159 mouse_position->y,
157 click_count, 160 click_count,
161 mouse_movement->x,
162 mouse_movement->y,
158 &resource_id); 163 &resource_id);
159 if (srpc_result == NACL_SRPC_RESULT_OK) 164 if (srpc_result == NACL_SRPC_RESULT_OK)
160 return resource_id; 165 return resource_id;
161 return kInvalidResourceId; 166 return kInvalidResourceId;
162 } 167 }
163 168
169 PP_Resource CreateMouseInputEvent1_0(PP_Instance instance,
170 PP_InputEvent_Type type,
171 PP_TimeTicks time_stamp,
172 uint32_t modifiers,
173 PP_InputEvent_MouseButton mouse_button,
174 const PP_Point* mouse_position,
175 int32_t click_count) {
176 PP_Point mouse_movement = PP_MakePoint(0, 0);
177 return CreateMouseInputEvent1_1(instance, type, time_stamp, modifiers,
178 mouse_button, mouse_position, click_count,
179 &mouse_movement);
180
181 }
182
164 PP_Bool IsMouseInputEvent(PP_Resource resource) { 183 PP_Bool IsMouseInputEvent(PP_Resource resource) {
165 if (!IsInputEvent(resource)) 184 if (!IsInputEvent(resource))
166 return PP_FALSE; 185 return PP_FALSE;
167 PP_InputEvent_Type type = GetType(resource); 186 PP_InputEvent_Type type = GetType(resource);
168 return PP_FromBool(type == PP_INPUTEVENT_TYPE_MOUSEDOWN || 187 return PP_FromBool(type == PP_INPUTEVENT_TYPE_MOUSEDOWN ||
169 type == PP_INPUTEVENT_TYPE_MOUSEUP || 188 type == PP_INPUTEVENT_TYPE_MOUSEUP ||
170 type == PP_INPUTEVENT_TYPE_MOUSEMOVE || 189 type == PP_INPUTEVENT_TYPE_MOUSEMOVE ||
171 type == PP_INPUTEVENT_TYPE_MOUSEENTER || 190 type == PP_INPUTEVENT_TYPE_MOUSEENTER ||
172 type == PP_INPUTEVENT_TYPE_MOUSELEAVE || 191 type == PP_INPUTEVENT_TYPE_MOUSELEAVE ||
173 type == PP_INPUTEVENT_TYPE_CONTEXTMENU); 192 type == PP_INPUTEVENT_TYPE_CONTEXTMENU);
174 } 193 }
175 194
176 PP_InputEvent_MouseButton GetMouseButton(PP_Resource mouse_event) { 195 PP_InputEvent_MouseButton GetMouseButton(PP_Resource mouse_event) {
177 IMPLEMENT_RESOURCE_THUNK(GetMouseButton, mouse_event, 196 IMPLEMENT_RESOURCE_THUNK(GetMouseButton, mouse_event,
178 PP_INPUTEVENT_MOUSEBUTTON_NONE); 197 PP_INPUTEVENT_MOUSEBUTTON_NONE);
179 } 198 }
180 199
181 PP_Point GetMousePosition(PP_Resource mouse_event) { 200 PP_Point GetMousePosition(PP_Resource mouse_event) {
182 IMPLEMENT_RESOURCE_THUNK(GetMousePosition, mouse_event, PP_MakePoint(0, 0)); 201 IMPLEMENT_RESOURCE_THUNK(GetMousePosition, mouse_event, PP_MakePoint(0, 0));
183 } 202 }
184 203
185 int32_t GetMouseClickCount(PP_Resource mouse_event) { 204 int32_t GetMouseClickCount(PP_Resource mouse_event) {
186 IMPLEMENT_RESOURCE_THUNK(GetMouseClickCount, mouse_event, 0); 205 IMPLEMENT_RESOURCE_THUNK(GetMouseClickCount, mouse_event, 0);
187 } 206 }
188 207
208 PP_Point GetMouseMovement(PP_Resource mouse_event) {
209 IMPLEMENT_RESOURCE_THUNK(GetMouseMovement, mouse_event, PP_MakePoint(0, 0));
210 }
211
189 // Wheel ----------------------------------------------------------------------- 212 // Wheel -----------------------------------------------------------------------
190 213
191 PP_Resource CreateWheelInputEvent(PP_Instance instance, 214 PP_Resource CreateWheelInputEvent(PP_Instance instance,
192 PP_TimeTicks time_stamp, 215 PP_TimeTicks time_stamp,
193 uint32_t modifiers, 216 uint32_t modifiers,
194 const PP_FloatPoint* wheel_delta, 217 const PP_FloatPoint* wheel_delta,
195 const PP_FloatPoint* wheel_ticks, 218 const PP_FloatPoint* wheel_ticks,
196 PP_Bool scroll_by_page) { 219 PP_Bool scroll_by_page) {
197 DebugPrintf("PPB_InputEvent::CreateWheelInputEvent: instance=" 220 DebugPrintf("PPB_InputEvent::CreateWheelInputEvent: instance="
198 "%"NACL_PRIu32", time_stamp=%lf, modifiers=" 221 "%"NACL_PRIu32", time_stamp=%lf, modifiers="
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 ClearInputEventRequest, 322 ClearInputEventRequest,
300 IsInputEvent, 323 IsInputEvent,
301 ::GetType, 324 ::GetType,
302 ::GetTimeStamp, 325 ::GetTimeStamp,
303 ::GetModifiers 326 ::GetModifiers
304 }; 327 };
305 return &input_event_interface; 328 return &input_event_interface;
306 } 329 }
307 330
308 // static 331 // static
309 const PPB_MouseInputEvent* PluginInputEvent::GetMouseInterface() { 332 const PPB_MouseInputEvent_1_0* PluginInputEvent::GetMouseInterface1_0() {
310 static const PPB_MouseInputEvent mouse_input_event_interface = { 333 static const PPB_MouseInputEvent_1_0 mouse_input_event_interface = {
311 CreateMouseInputEvent, 334 CreateMouseInputEvent1_0,
312 IsMouseInputEvent, 335 IsMouseInputEvent,
313 ::GetMouseButton, 336 ::GetMouseButton,
314 ::GetMousePosition, 337 ::GetMousePosition,
315 ::GetMouseClickCount 338 ::GetMouseClickCount
316 }; 339 };
317 return &mouse_input_event_interface; 340 return &mouse_input_event_interface;
318 } 341 }
319 342
320 // static 343 // static
344 const PPB_MouseInputEvent* PluginInputEvent::GetMouseInterface1_1() {
345 static const PPB_MouseInputEvent mouse_input_event_interface = {
346 CreateMouseInputEvent1_1,
347 IsMouseInputEvent,
348 ::GetMouseButton,
349 ::GetMousePosition,
350 ::GetMouseClickCount,
351 ::GetMouseMovement
352 };
353 return &mouse_input_event_interface;
354 }
355
356 // static
321 const PPB_WheelInputEvent* PluginInputEvent::GetWheelInterface() { 357 const PPB_WheelInputEvent* PluginInputEvent::GetWheelInterface() {
322 static const PPB_WheelInputEvent wheel_input_event_interface = { 358 static const PPB_WheelInputEvent wheel_input_event_interface = {
323 CreateWheelInputEvent, 359 CreateWheelInputEvent,
324 IsWheelInputEvent, 360 IsWheelInputEvent,
325 ::GetWheelDelta, 361 ::GetWheelDelta,
326 ::GetWheelTicks, 362 ::GetWheelTicks,
327 ::GetWheelScrollByPage 363 ::GetWheelScrollByPage
328 }; 364 };
329 return &wheel_input_event_interface; 365 return &wheel_input_event_interface;
330 } 366 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 } 408 }
373 409
374 PP_Point PluginInputEvent::GetMousePosition() const { 410 PP_Point PluginInputEvent::GetMousePosition() const {
375 return input_event_data_.mouse_position; 411 return input_event_data_.mouse_position;
376 } 412 }
377 413
378 int32_t PluginInputEvent::GetMouseClickCount() const { 414 int32_t PluginInputEvent::GetMouseClickCount() const {
379 return input_event_data_.mouse_click_count; 415 return input_event_data_.mouse_click_count;
380 } 416 }
381 417
418 PP_Point PluginInputEvent::GetMouseMovement() const {
419 return input_event_data_.mouse_movement;
420 }
421
382 PP_FloatPoint PluginInputEvent::GetWheelDelta() const { 422 PP_FloatPoint PluginInputEvent::GetWheelDelta() const {
383 return input_event_data_.wheel_delta; 423 return input_event_data_.wheel_delta;
384 } 424 }
385 425
386 PP_FloatPoint PluginInputEvent::GetWheelTicks() const { 426 PP_FloatPoint PluginInputEvent::GetWheelTicks() const {
387 return input_event_data_.wheel_ticks; 427 return input_event_data_.wheel_ticks;
388 } 428 }
389 429
390 PP_Bool PluginInputEvent::GetWheelScrollByPage() const { 430 PP_Bool PluginInputEvent::GetWheelScrollByPage() const {
391 return input_event_data_.wheel_scroll_by_page; 431 return input_event_data_.wheel_scroll_by_page;
392 } 432 }
393 433
394 uint32_t PluginInputEvent::GetKeyCode() const { 434 uint32_t PluginInputEvent::GetKeyCode() const {
395 return input_event_data_.key_code; 435 return input_event_data_.key_code;
396 } 436 }
397 437
398 PP_Var PluginInputEvent::GetCharacterText() const { 438 PP_Var PluginInputEvent::GetCharacterText() const {
399 PPBVarInterface()->AddRef(character_text_); 439 PPBVarInterface()->AddRef(character_text_);
400 return character_text_; 440 return character_text_;
401 } 441 }
402 442
403 } // namespace ppapi_proxy 443 } // namespace ppapi_proxy
404 444
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698