OLD | NEW |
| (Empty) |
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 | |
5 #ifndef PPAPI_SHARED_IMPL_PPB_INPUT_EVENT_SHARED_H_ | |
6 #define PPAPI_SHARED_IMPL_PPB_INPUT_EVENT_SHARED_H_ | |
7 | |
8 #include <string> | |
9 #include <vector> | |
10 | |
11 #include "base/basictypes.h" | |
12 #include "base/compiler_specific.h" | |
13 #include "ppapi/shared_impl/resource.h" | |
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 | |
21 struct PPAPI_SHARED_EXPORT InputEventData { | |
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; | |
36 PP_Point mouse_movement; | |
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; | |
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; | |
50 }; | |
51 | |
52 // This simple class implements the PPB_InputEvent_API in terms of the | |
53 // shared InputEventData structure | |
54 class PPAPI_SHARED_EXPORT PPB_InputEvent_Shared | |
55 : public Resource, | |
56 public thunk::PPB_InputEvent_API { | |
57 public: | |
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. | |
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); | |
69 | |
70 // Resource overrides. | |
71 virtual PPB_InputEvent_API* AsPPB_InputEvent_API() OVERRIDE; | |
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; | |
81 virtual PP_Point GetMouseMovement() OVERRIDE; | |
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; | |
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; | |
91 | |
92 private: | |
93 InputEventData data_; | |
94 | |
95 DISALLOW_IMPLICIT_CONSTRUCTORS(PPB_InputEvent_Shared); | |
96 }; | |
97 | |
98 } // namespace ppapi | |
99 | |
100 #endif // PPAPI_SHARED_IMPL_PPB_INPUT_EVENT_SHARED_H_ | |
OLD | NEW |