blob: 1a297506ce21ea2a117dae81d22f4a5d0a36ddbb [file] [log] [blame]
[email protected]493d14212011-07-07 15:38:481// 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]9a578392011-12-07 18:59:275#ifndef PPAPI_SHARED_IMPL_PPB_INPUT_EVENT_SHARED_H_
6#define PPAPI_SHARED_IMPL_PPB_INPUT_EVENT_SHARED_H_
[email protected]493d14212011-07-07 15:38:487
8#include <string>
[email protected]2daba2f32011-09-29 04:23:099#include <vector>
[email protected]493d14212011-07-07 15:38:4810
[email protected]ff71e642011-08-25 04:45:5811#include "base/basictypes.h"
[email protected]493d14212011-07-07 15:38:4812#include "base/compiler_specific.h"
[email protected]ff71e642011-08-25 04:45:5813#include "ppapi/shared_impl/resource.h"
[email protected]493d14212011-07-07 15:38:4814#include "ppapi/thunk/ppb_input_event_api.h"
15
16namespace 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]f0a04c42011-08-26 22:43:2021struct PPAPI_SHARED_EXPORT InputEventData {
[email protected]493d14212011-07-07 15:38:4822 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]80473262011-08-31 17:15:1836 PP_Point mouse_movement;
[email protected]493d14212011-07-07 15:38:4837
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]2daba2f32011-09-29 04:23:0945
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]493d14212011-07-07 15:38:4850};
51
52// This simple class implements the PPB_InputEvent_API in terms of the
53// shared InputEventData structure
[email protected]9a578392011-12-07 18:59:2754class PPAPI_SHARED_EXPORT PPB_InputEvent_Shared
[email protected]f0a04c42011-08-26 22:43:2055 : public Resource,
56 public thunk::PPB_InputEvent_API {
[email protected]493d14212011-07-07 15:38:4857 public:
[email protected]ff71e642011-08-25 04:45:5858 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]9a578392011-12-07 18:59:2763 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]ff71e642011-08-25 04:45:5869
70 // Resource overrides.
71 virtual PPB_InputEvent_API* AsPPB_InputEvent_API() OVERRIDE;
[email protected]493d14212011-07-07 15:38:4872
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]80473262011-08-31 17:15:1881 virtual PP_Point GetMouseMovement() OVERRIDE;
[email protected]493d14212011-07-07 15:38:4882 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]2daba2f32011-09-29 04:23:0987 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]493d14212011-07-07 15:38:4891
[email protected]493d14212011-07-07 15:38:4892 private:
93 InputEventData data_;
[email protected]ff71e642011-08-25 04:45:5894
[email protected]9a578392011-12-07 18:59:2795 DISALLOW_IMPLICIT_CONSTRUCTORS(PPB_InputEvent_Shared);
[email protected]493d14212011-07-07 15:38:4896};
97
98} // namespace ppapi
99
[email protected]9a578392011-12-07 18:59:27100#endif // PPAPI_SHARED_IMPL_PPB_INPUT_EVENT_SHARED_H_