| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 "ppapi/c/pp_errors.h" | 5 #include "ppapi/c/pp_errors.h" |
| 6 #include "ppapi/thunk/thunk.h" | 6 #include "ppapi/thunk/thunk.h" |
| 7 #include "ppapi/thunk/enter.h" | 7 #include "ppapi/thunk/enter.h" |
| 8 #include "ppapi/thunk/ppb_input_event_api.h" | 8 #include "ppapi/thunk/ppb_input_event_api.h" |
| 9 #include "ppapi/thunk/ppb_instance_api.h" | 9 #include "ppapi/thunk/ppb_instance_api.h" |
| 10 #include "ppapi/thunk/resource_creation_api.h" | 10 #include "ppapi/thunk/resource_creation_api.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 &RequestFilteringInputEvents, | 73 &RequestFilteringInputEvents, |
| 74 &ClearInputEventRequest, | 74 &ClearInputEventRequest, |
| 75 &IsInputEvent, | 75 &IsInputEvent, |
| 76 &GetType, | 76 &GetType, |
| 77 &GetTimeStamp, | 77 &GetTimeStamp, |
| 78 &GetModifiers | 78 &GetModifiers |
| 79 }; | 79 }; |
| 80 | 80 |
| 81 // Mouse ----------------------------------------------------------------------- | 81 // Mouse ----------------------------------------------------------------------- |
| 82 | 82 |
| 83 PP_Resource CreateMouseInputEvent(PP_Instance instance, | 83 PP_Resource CreateMouseInputEvent1_0(PP_Instance instance, |
| 84 PP_InputEvent_Type type, | 84 PP_InputEvent_Type type, |
| 85 PP_TimeTicks time_stamp, | 85 PP_TimeTicks time_stamp, |
| 86 uint32_t modifiers, | 86 uint32_t modifiers, |
| 87 PP_InputEvent_MouseButton mouse_button, | 87 PP_InputEvent_MouseButton mouse_button, |
| 88 const PP_Point* mouse_position, | 88 const PP_Point* mouse_position, |
| 89 int32_t click_count) { | 89 int32_t click_count) { |
| 90 EnterFunction<ResourceCreationAPI> enter(instance, true); |
| 91 if (enter.failed()) |
| 92 return 0; |
| 93 |
| 94 PP_Point mouse_movement = PP_MakePoint(0, 0); |
| 95 return enter.functions()->CreateMouseInputEvent(instance, type, time_stamp, |
| 96 modifiers, mouse_button, |
| 97 mouse_position, click_count, |
| 98 &mouse_movement); |
| 99 } |
| 100 |
| 101 PP_Resource CreateMouseInputEvent1_1(PP_Instance instance, |
| 102 PP_InputEvent_Type type, |
| 103 PP_TimeTicks time_stamp, |
| 104 uint32_t modifiers, |
| 105 PP_InputEvent_MouseButton mouse_button, |
| 106 const PP_Point* mouse_position, |
| 107 int32_t click_count, |
| 108 const PP_Point* mouse_movement) { |
| 90 EnterFunction<ResourceCreationAPI> enter(instance, true); | 109 EnterFunction<ResourceCreationAPI> enter(instance, true); |
| 91 if (enter.failed()) | 110 if (enter.failed()) |
| 92 return 0; | 111 return 0; |
| 93 return enter.functions()->CreateMouseInputEvent(instance, type, time_stamp, | 112 return enter.functions()->CreateMouseInputEvent(instance, type, time_stamp, |
| 94 modifiers, mouse_button, | 113 modifiers, mouse_button, |
| 95 mouse_position, click_count); | 114 mouse_position, click_count, |
| 115 mouse_movement); |
| 96 } | 116 } |
| 97 | 117 |
| 98 PP_Bool IsMouseInputEvent(PP_Resource resource) { | 118 PP_Bool IsMouseInputEvent(PP_Resource resource) { |
| 99 if (!IsInputEvent(resource)) | 119 if (!IsInputEvent(resource)) |
| 100 return PP_FALSE; // Prevent warning log in GetType. | 120 return PP_FALSE; // Prevent warning log in GetType. |
| 101 PP_InputEvent_Type type = GetType(resource); | 121 PP_InputEvent_Type type = GetType(resource); |
| 102 return PP_FromBool(type == PP_INPUTEVENT_TYPE_MOUSEDOWN || | 122 return PP_FromBool(type == PP_INPUTEVENT_TYPE_MOUSEDOWN || |
| 103 type == PP_INPUTEVENT_TYPE_MOUSEUP || | 123 type == PP_INPUTEVENT_TYPE_MOUSEUP || |
| 104 type == PP_INPUTEVENT_TYPE_MOUSEMOVE || | 124 type == PP_INPUTEVENT_TYPE_MOUSEMOVE || |
| 105 type == PP_INPUTEVENT_TYPE_MOUSEENTER || | 125 type == PP_INPUTEVENT_TYPE_MOUSEENTER || |
| (...skipping 15 matching lines...) Expand all Loading... |
| 121 return enter.object()->GetMousePosition(); | 141 return enter.object()->GetMousePosition(); |
| 122 } | 142 } |
| 123 | 143 |
| 124 int32_t GetMouseClickCount(PP_Resource mouse_event) { | 144 int32_t GetMouseClickCount(PP_Resource mouse_event) { |
| 125 EnterInputEvent enter(mouse_event, true); | 145 EnterInputEvent enter(mouse_event, true); |
| 126 if (enter.failed()) | 146 if (enter.failed()) |
| 127 return 0; | 147 return 0; |
| 128 return enter.object()->GetMouseClickCount(); | 148 return enter.object()->GetMouseClickCount(); |
| 129 } | 149 } |
| 130 | 150 |
| 131 const PPB_MouseInputEvent g_ppb_mouse_input_event_thunk = { | 151 PP_Point GetMouseMovement(PP_Resource mouse_event) { |
| 132 &CreateMouseInputEvent, | 152 EnterInputEvent enter(mouse_event, true); |
| 153 if (enter.failed()) |
| 154 return PP_MakePoint(0, 0); |
| 155 return enter.object()->GetMouseMovement(); |
| 156 } |
| 157 |
| 158 const PPB_MouseInputEvent_1_0 g_ppb_mouse_input_event_1_0_thunk = { |
| 159 &CreateMouseInputEvent1_0, |
| 133 &IsMouseInputEvent, | 160 &IsMouseInputEvent, |
| 134 &GetMouseButton, | 161 &GetMouseButton, |
| 135 &GetMousePosition, | 162 &GetMousePosition, |
| 136 &GetMouseClickCount | 163 &GetMouseClickCount |
| 137 }; | 164 }; |
| 138 | 165 |
| 166 const PPB_MouseInputEvent g_ppb_mouse_input_event_1_1_thunk = { |
| 167 &CreateMouseInputEvent1_1, |
| 168 &IsMouseInputEvent, |
| 169 &GetMouseButton, |
| 170 &GetMousePosition, |
| 171 &GetMouseClickCount, |
| 172 &GetMouseMovement |
| 173 }; |
| 174 |
| 139 // Wheel ----------------------------------------------------------------------- | 175 // Wheel ----------------------------------------------------------------------- |
| 140 | 176 |
| 141 PP_Resource CreateWheelInputEvent(PP_Instance instance, | 177 PP_Resource CreateWheelInputEvent(PP_Instance instance, |
| 142 PP_TimeTicks time_stamp, | 178 PP_TimeTicks time_stamp, |
| 143 uint32_t modifiers, | 179 uint32_t modifiers, |
| 144 const PP_FloatPoint* wheel_delta, | 180 const PP_FloatPoint* wheel_delta, |
| 145 const PP_FloatPoint* wheel_ticks, | 181 const PP_FloatPoint* wheel_ticks, |
| 146 PP_Bool scroll_by_page) { | 182 PP_Bool scroll_by_page) { |
| 147 EnterFunction<ResourceCreationAPI> enter(instance, true); | 183 EnterFunction<ResourceCreationAPI> enter(instance, true); |
| 148 if (enter.failed()) | 184 if (enter.failed()) |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 &GetKeyCode, | 270 &GetKeyCode, |
| 235 &GetCharacterText | 271 &GetCharacterText |
| 236 }; | 272 }; |
| 237 | 273 |
| 238 } // namespace | 274 } // namespace |
| 239 | 275 |
| 240 const PPB_InputEvent* GetPPB_InputEvent_Thunk() { | 276 const PPB_InputEvent* GetPPB_InputEvent_Thunk() { |
| 241 return &g_ppb_input_event_thunk; | 277 return &g_ppb_input_event_thunk; |
| 242 } | 278 } |
| 243 | 279 |
| 244 const PPB_MouseInputEvent* GetPPB_MouseInputEvent_Thunk() { | 280 const PPB_MouseInputEvent_1_0* GetPPB_MouseInputEvent_1_0_Thunk() { |
| 245 return &g_ppb_mouse_input_event_thunk; | 281 return &g_ppb_mouse_input_event_1_0_thunk; |
| 282 } |
| 283 |
| 284 const PPB_MouseInputEvent* GetPPB_MouseInputEvent_1_1_Thunk() { |
| 285 return &g_ppb_mouse_input_event_1_1_thunk; |
| 246 } | 286 } |
| 247 | 287 |
| 248 const PPB_KeyboardInputEvent* GetPPB_KeyboardInputEvent_Thunk() { | 288 const PPB_KeyboardInputEvent* GetPPB_KeyboardInputEvent_Thunk() { |
| 249 return &g_ppb_keyboard_input_event_thunk; | 289 return &g_ppb_keyboard_input_event_thunk; |
| 250 } | 290 } |
| 251 | 291 |
| 252 const PPB_WheelInputEvent* GetPPB_WheelInputEvent_Thunk() { | 292 const PPB_WheelInputEvent* GetPPB_WheelInputEvent_Thunk() { |
| 253 return &g_ppb_wheel_input_event_thunk; | 293 return &g_ppb_wheel_input_event_thunk; |
| 254 } | 294 } |
| 255 | 295 |
| 256 } // namespace thunk | 296 } // namespace thunk |
| 257 } // namespace ppapi | 297 } // namespace ppapi |
| OLD | NEW |