[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 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 | ||||
3 | // found in the LICENSE file. | ||||
4 | |||||
[email protected] | 9a57839 | 2011-12-07 18:59:27 | [diff] [blame] | 5 | #ifndef PPAPI_SHARED_IMPL_PPB_INPUT_EVENT_SHARED_H_ |
6 | #define PPAPI_SHARED_IMPL_PPB_INPUT_EVENT_SHARED_H_ | ||||
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 7 | |
8 | #include <string> | ||||
[email protected] | 2daba2f3 | 2011-09-29 04:23:09 | [diff] [blame] | 9 | #include <vector> |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 10 | |
[email protected] | ff71e64 | 2011-08-25 04:45:58 | [diff] [blame] | 11 | #include "base/basictypes.h" |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 12 | #include "base/compiler_specific.h" |
[email protected] | ff71e64 | 2011-08-25 04:45:58 | [diff] [blame] | 13 | #include "ppapi/shared_impl/resource.h" |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 14 | #include "ppapi/thunk/ppb_input_event_api.h" |
15 | |||||
16 | namespace ppapi { | ||||
17 | |||||
18 | // IF YOU ADD STUFF TO THIS CLASS | ||||
19 | // ============================== | ||||
20 | // Be sure to add it to the STRUCT_TRAITS at the top of ppapi_messages.h | ||||
[email protected] | f0a04c4 | 2011-08-26 22:43:20 | [diff] [blame] | 21 | struct PPAPI_SHARED_EXPORT InputEventData { |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 22 | InputEventData(); |
23 | ~InputEventData(); | ||||
24 | |||||
25 | // Internal-only value. Set to true when this input event is filtered, that | ||||
26 | // is, should be delivered synchronously. This is used by the proxy. | ||||
27 | bool is_filtered; | ||||
28 | |||||
29 | PP_InputEvent_Type event_type; | ||||
30 | PP_TimeTicks event_time_stamp; | ||||
31 | uint32_t event_modifiers; | ||||
32 | |||||
33 | PP_InputEvent_MouseButton mouse_button; | ||||
34 | PP_Point mouse_position; | ||||
35 | int32_t mouse_click_count; | ||||
[email protected] | 8047326 | 2011-08-31 17:15:18 | [diff] [blame] | 36 | PP_Point mouse_movement; |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 37 | |
38 | PP_FloatPoint wheel_delta; | ||||
39 | PP_FloatPoint wheel_ticks; | ||||
40 | bool wheel_scroll_by_page; | ||||
41 | |||||
42 | uint32_t key_code; | ||||
43 | |||||
44 | std::string character_text; | ||||
[email protected] | 2daba2f3 | 2011-09-29 04:23:09 | [diff] [blame] | 45 | |
46 | std::vector<uint32_t> composition_segment_offsets; | ||||
47 | int32_t composition_target_segment; | ||||
48 | uint32_t composition_selection_start; | ||||
49 | uint32_t composition_selection_end; | ||||
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 50 | }; |
51 | |||||
52 | // This simple class implements the PPB_InputEvent_API in terms of the | ||||
53 | // shared InputEventData structure | ||||
[email protected] | 9a57839 | 2011-12-07 18:59:27 | [diff] [blame] | 54 | class PPAPI_SHARED_EXPORT PPB_InputEvent_Shared |
[email protected] | f0a04c4 | 2011-08-26 22:43:20 | [diff] [blame] | 55 | : public Resource, |
56 | public thunk::PPB_InputEvent_API { | ||||
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 57 | public: |
[email protected] | ff71e64 | 2011-08-25 04:45:58 | [diff] [blame] | 58 | struct InitAsImpl {}; |
59 | struct InitAsProxy {}; | ||||
60 | |||||
61 | // The dummy arguments control which version of Resource's constructor is | ||||
62 | // called for this base class. | ||||
[email protected] | 9a57839 | 2011-12-07 18:59:27 | [diff] [blame] | 63 | PPB_InputEvent_Shared(const InitAsImpl&, |
64 | PP_Instance instance, | ||||
65 | const InputEventData& data); | ||||
66 | PPB_InputEvent_Shared(const InitAsProxy&, | ||||
67 | PP_Instance instance, | ||||
68 | const InputEventData& data); | ||||
[email protected] | ff71e64 | 2011-08-25 04:45:58 | [diff] [blame] | 69 | |
70 | // Resource overrides. | ||||
71 | virtual PPB_InputEvent_API* AsPPB_InputEvent_API() OVERRIDE; | ||||
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 72 | |
73 | // PPB_InputEvent_API implementation. | ||||
74 | virtual const InputEventData& GetInputEventData() const OVERRIDE; | ||||
75 | virtual PP_InputEvent_Type GetType() OVERRIDE; | ||||
76 | virtual PP_TimeTicks GetTimeStamp() OVERRIDE; | ||||
77 | virtual uint32_t GetModifiers() OVERRIDE; | ||||
78 | virtual PP_InputEvent_MouseButton GetMouseButton() OVERRIDE; | ||||
79 | virtual PP_Point GetMousePosition() OVERRIDE; | ||||
80 | virtual int32_t GetMouseClickCount() OVERRIDE; | ||||
[email protected] | 8047326 | 2011-08-31 17:15:18 | [diff] [blame] | 81 | virtual PP_Point GetMouseMovement() OVERRIDE; |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 82 | virtual PP_FloatPoint GetWheelDelta() OVERRIDE; |
83 | virtual PP_FloatPoint GetWheelTicks() OVERRIDE; | ||||
84 | virtual PP_Bool GetWheelScrollByPage() OVERRIDE; | ||||
85 | virtual uint32_t GetKeyCode() OVERRIDE; | ||||
86 | virtual PP_Var GetCharacterText() OVERRIDE; | ||||
[email protected] | 2daba2f3 | 2011-09-29 04:23:09 | [diff] [blame] | 87 | virtual uint32_t GetIMESegmentNumber() OVERRIDE; |
88 | virtual uint32_t GetIMESegmentOffset(uint32_t index) OVERRIDE; | ||||
89 | virtual int32_t GetIMETargetSegment() OVERRIDE; | ||||
90 | virtual void GetIMESelection(uint32_t* start, uint32_t* end) OVERRIDE; | ||||
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 91 | |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 92 | private: |
93 | InputEventData data_; | ||||
[email protected] | ff71e64 | 2011-08-25 04:45:58 | [diff] [blame] | 94 | |
[email protected] | 9a57839 | 2011-12-07 18:59:27 | [diff] [blame] | 95 | DISALLOW_IMPLICIT_CONSTRUCTORS(PPB_InputEvent_Shared); |
[email protected] | 493d1421 | 2011-07-07 15:38:48 | [diff] [blame] | 96 | }; |
97 | |||||
98 | } // namespace ppapi | ||||
99 | |||||
[email protected] | 9a57839 | 2011-12-07 18:59:27 | [diff] [blame] | 100 | #endif // PPAPI_SHARED_IMPL_PPB_INPUT_EVENT_SHARED_H_ |