Mir
event_builders.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2015 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU Lesser General Public License version 3,
6  * as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Author: Robert Carr <robert.carr@canonical.com>
17  */
18 
19 #ifndef MIR_EVENT_BUILDERS_H_
20 #define MIR_EVENT_BUILDERS_H_
21 
22 #include "mir_toolkit/event.h"
23 
24 #include "mir/geometry/size.h"
25 #include "mir/geometry/point.h"
26 #include "mir/geometry/rectangle.h"
31 
32 #include <memory>
33 #include <functional>
34 #include <chrono>
35 #include <vector>
36 
37 namespace mir
38 {
39  typedef std::unique_ptr<MirEvent, void(*)(MirEvent*)> EventUPtr;
40 
41 namespace events
42 {
43 // Surface orientation change event
44 EventUPtr make_event(frontend::SurfaceId const& surface_id, MirOrientation orientation);
45 // Prompt session state change event
46 EventUPtr make_event(MirPromptSessionState state);
47 // Surface resize event
48 EventUPtr make_event(frontend::SurfaceId const& surface_id, geometry::Size const& size);
49 // Surface configure event
50 EventUPtr make_event(frontend::SurfaceId const& surface_id, MirSurfaceAttrib attribute, int value);
51 // Close surface event
52 EventUPtr make_event(frontend::SurfaceId const& surface_id);
53 // Keymap event
54 EventUPtr make_event(frontend::SurfaceId const& surface_id, MirInputDeviceId id, std::string const& model,
55  std::string const& layout, std::string const& variant, std::string const& options);
56 // Surface output event
57 EventUPtr make_event(
58  frontend::SurfaceId const& surface_id,
59  int dpi,
60  float scale,
61  double refresh_rate,
62  MirFormFactor form_factor,
63  uint32_t id);
64 
66 EventUPtr make_event(frontend::SurfaceId const& surface_id, geometry::Rectangle placement);
67 
68 // Key event
69 EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
70  std::vector<uint8_t> const& cookie, MirKeyboardAction action, xkb_keysym_t key_code,
71  int scan_code, MirInputEventModifiers modifiers);
72 
73 void set_modifier(MirEvent& event, MirInputEventModifiers modifiers);
74 void set_cursor_position(MirEvent& event, mir::geometry::Point const& pos);
75 void set_cursor_position(MirEvent& event, float x, float y);
76 void set_button_state(MirEvent& event, MirPointerButtons button_state);
77 
78 // Deprecated version with uint64_t mac
79 EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
80  uint64_t mac, MirKeyboardAction action, xkb_keysym_t key_code,
81  int scan_code, MirInputEventModifiers modifiers) __attribute__ ((deprecated));
82 
83 // Deprecated version without mac
84 EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
85  MirKeyboardAction action, xkb_keysym_t key_code,
86  int scan_code, MirInputEventModifiers modifiers) __attribute__ ((deprecated));
87 
88 // Touch event
89 EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
90  std::vector<uint8_t> const& mac, MirInputEventModifiers modifiers);
91 
92 // Deprecated version with uint64_t mac
93 EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
94  uint64_t mac, MirInputEventModifiers modifiers) __attribute__ ((deprecated));
95 
96 // Deprecated version without mac
97 EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
98  MirInputEventModifiers modifiers) __attribute__ ((deprecated));
99 
100 void add_touch(MirEvent &event, MirTouchId touch_id, MirTouchAction action,
101  MirTouchTooltype tooltype, float x_axis_value, float y_axis_value,
102  float pressure_value, float touch_major_value, float touch_minor_value, float size_value);
103 
104 // Pointer event
105 // Deprecated version without relative axis
106 EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
107  uint64_t mac, MirInputEventModifiers modifiers, MirPointerAction action,
108  MirPointerButtons buttons_pressed,
109  float x_axis_value, float y_axis_value,
110  float hscroll_value, float vscroll_value) __attribute__ ((deprecated));
111 
112 // Deprecated version without relative axis and mac
113 EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
114  MirInputEventModifiers modifiers, MirPointerAction action,
115  MirPointerButtons buttons_pressed,
116  float x_axis_value, float y_axis_value,
117  float hscroll_value, float vscroll_value) __attribute__ ((deprecated));
118 
119 EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
120  std::vector<uint8_t> const& mac, MirInputEventModifiers modifiers, MirPointerAction action,
121  MirPointerButtons buttons_pressed,
122  float x_axis_value, float y_axis_value,
123  float hscroll_value, float vscroll_value,
124  float relative_x_value, float relative_y_value);
125 
126 // Deprecated version with uint64_t mac
127 EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
128  uint64_t mac, MirInputEventModifiers modifiers, MirPointerAction action,
129  MirPointerButtons buttons_pressed,
130  float x_axis_value, float y_axis_value,
131  float hscroll_value, float vscroll_value,
132  float relative_x_value, float relative_y_value) __attribute__ ((deprecated));
133 
134 // Deprecated version without mac
135 EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
136  MirInputEventModifiers modifiers, MirPointerAction action,
137  MirPointerButtons buttons_pressed,
138  float x_axis_value, float y_axis_value,
139  float hscroll_value, float vscroll_value,
140  float relative_x_value, float relative_y_value) __attribute__ ((deprecated));
141 
142 // Input configuration event
143 EventUPtr make_event(MirInputConfigurationAction action,
144  MirInputDeviceId id, std::chrono::nanoseconds time) __attribute__((deprecated));
145 
146 EventUPtr make_event(std::chrono::nanoseconds timestamp,
147  MirPointerButtons pointer_buttons,
148  MirInputEventModifiers modifiers,
149  float x_axis_value,
150  float y_axis_value,
151  std::vector<InputDeviceState>&& device_states);
152 
153 EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
154  std::vector<uint8_t> const& mac, MirInputEventModifiers modifiers,
155  std::vector<ContactState> const& contacts);
156 
157 EventUPtr clone_event(MirEvent const& event);
158 void transform_positions(MirEvent& event, mir::geometry::Displacement const& movement);
159 
160 }
161 }
162 
163 #endif // MIR_EVENT_BUILDERS_H_
Definition: size.h:30
Definition: as_render_target.h:27
void set_modifier(MirEvent &event, MirInputEventModifiers modifiers)
Definition: point.h:30
MirPromptSessionState
Definition: common.h:131
void add_touch(MirEvent &event, MirTouchId touch_id, MirTouchAction action, MirTouchTooltype tooltype, float x_axis_value, float y_axis_value, float pressure_value, float touch_major_value, float touch_minor_value, float size_value)
int32_t MirTouchId
An identifier for a touch-point.
Definition: touch_event.h:40
void set_button_state(MirEvent &event, MirPointerButtons button_state)
MirPointerAction
Possible pointer actions.
Definition: pointer_event.h:40
void set_cursor_position(MirEvent &event, mir::geometry::Point const &pos)
EventUPtr make_event(frontend::SurfaceId const &surface_id, MirOrientation orientation)
MirOrientation
Direction relative to the "natural" orientation of the display.
Definition: common.h:186
MirKeyboardAction
Possible actions for changing key state.
Definition: keyboard_event.h:46
unsigned int MirInputEventModifiers
Definition: input_event.h:68
int64_t MirInputDeviceId
Definition: input_event.h:35
void transform_positions(MirEvent &event, mir::geometry::Displacement const &movement)
std::unique_ptr< MirEvent, void(*)(MirEvent *)> EventUPtr
Definition: event_builders.h:39
struct MirEvent MirEvent
Definition: event.h:67
MirSurfaceAttrib
Attributes of a surface that the client and server/shell may wish to get or set over the wire...
Definition: common.h:34
MirTouchTooltype
Identifiers for per-touch tool types.
Definition: touch_event.h:82
MirFormFactor
Form factor associated with a physical output.
Definition: common.h:320
Definition: displacement.h:32
unsigned int MirPointerButtons
Definition: pointer_event.h:88
Definition: int_wrapper.h:27
EventUPtr clone_event(MirEvent const &event)
MirInputConfigurationAction
MirInputConfigurationEvent indicates a configuration change in the input device subsystem. Eventually it&#39;s usage will be required to properly interpret MirInputEvent, for example: If we receive a button down, and then a device reset, we should not expect to receive the button up.
Definition: input_configuration_event.h:43
Definition: rectangle.h:33
MirTouchAction
Possible per touch actions for state changing.
Definition: touch_event.h:45

Copyright © 2012-2016 Canonical Ltd.
Generated on Sat Dec 3 12:48:59 UTC 2016