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"
27 
28 #include <memory>
29 #include <functional>
30 #include <chrono>
31 #include <vector>
32 
33 namespace mir
34 {
35  typedef std::unique_ptr<MirEvent, void(*)(MirEvent*)> EventUPtr;
36 
37 namespace events
38 {
39 // Surface orientation change event
40 EventUPtr make_event(frontend::SurfaceId const& surface_id, MirOrientation orientation);
41 // Prompt session state change event
42 EventUPtr make_event(MirPromptSessionState state);
43 // Surface resize event
44 EventUPtr make_event(frontend::SurfaceId const& surface_id, geometry::Size const& size);
45 // Surface configure event
46 EventUPtr make_event(frontend::SurfaceId const& surface_id, MirSurfaceAttrib attribute, int value);
47 // Close surface event
48 EventUPtr make_event(frontend::SurfaceId const& surface_id);
49 // Keymap event
50 EventUPtr make_event(frontend::SurfaceId const& surface_id, MirInputDeviceId id, std::string const& model,
51  std::string const& layout, std::string const& variant, std::string const& options);
52 // Surface output event
53 EventUPtr make_event(
54  frontend::SurfaceId const& surface_id,
55  int dpi,
56  float scale,
57  MirFormFactor form_factor,
58  uint32_t id);
59 
60 // Key event
61 EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
62  std::vector<uint8_t> const& cookie, MirKeyboardAction action, xkb_keysym_t key_code,
63  int scan_code, MirInputEventModifiers modifiers);
64 
65 void set_modifier(MirEvent& event, MirInputEventModifiers modifiers);
66 void set_cursor_position(MirEvent& event, mir::geometry::Point const& pos);
67 void set_button_state(MirEvent& event, MirPointerButtons button_state);
68 
69 // Deprecated version with uint64_t mac
70 EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
71  uint64_t mac, MirKeyboardAction action, xkb_keysym_t key_code,
72  int scan_code, MirInputEventModifiers modifiers) __attribute__ ((deprecated));
73 
74 // Deprecated version without mac
75 EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
76  MirKeyboardAction action, xkb_keysym_t key_code,
77  int scan_code, MirInputEventModifiers modifiers) __attribute__ ((deprecated));
78 
79 // Touch event
80 EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
81  std::vector<uint8_t> const& mac, MirInputEventModifiers modifiers);
82 
83 // Deprecated version with uint64_t mac
84 EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
85  uint64_t mac, MirInputEventModifiers modifiers) __attribute__ ((deprecated));
86 
87 // Deprecated version without mac
88 EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
89  MirInputEventModifiers modifiers) __attribute__ ((deprecated));
90 
91 void add_touch(MirEvent &event, MirTouchId touch_id, MirTouchAction action,
92  MirTouchTooltype tooltype, float x_axis_value, float y_axis_value,
93  float pressure_value, float touch_major_value, float touch_minor_value, float size_value);
94 
95 // Pointer event
96 // Deprecated version without relative axis
97 EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
98  uint64_t mac, MirInputEventModifiers modifiers, MirPointerAction action,
99  MirPointerButtons buttons_pressed,
100  float x_axis_value, float y_axis_value,
101  float hscroll_value, float vscroll_value) __attribute__ ((deprecated));
102 
103 // Deprecated version without relative axis and mac
104 EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
105  MirInputEventModifiers modifiers, MirPointerAction action,
106  MirPointerButtons buttons_pressed,
107  float x_axis_value, float y_axis_value,
108  float hscroll_value, float vscroll_value) __attribute__ ((deprecated));
109 
110 EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
111  std::vector<uint8_t> const& mac, MirInputEventModifiers modifiers, MirPointerAction action,
112  MirPointerButtons buttons_pressed,
113  float x_axis_value, float y_axis_value,
114  float hscroll_value, float vscroll_value,
115  float relative_x_value, float relative_y_value);
116 
117 // Deprecated version with uint64_t mac
118 EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
119  uint64_t mac, MirInputEventModifiers modifiers, MirPointerAction action,
120  MirPointerButtons buttons_pressed,
121  float x_axis_value, float y_axis_value,
122  float hscroll_value, float vscroll_value,
123  float relative_x_value, float relative_y_value) __attribute__ ((deprecated));
124 
125 // Deprecated version without mac
126 EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
127  MirInputEventModifiers modifiers, MirPointerAction action,
128  MirPointerButtons buttons_pressed,
129  float x_axis_value, float y_axis_value,
130  float hscroll_value, float vscroll_value,
131  float relative_x_value, float relative_y_value) __attribute__ ((deprecated));
132 
133 // Input configuration event
134 EventUPtr make_event(MirInputConfigurationAction action,
135  MirInputDeviceId id, std::chrono::nanoseconds time);
136 }
137 }
138 
139 #endif // MIR_EVENT_BUILDERS_H_
Definition: size.h:30
All things Mir.
Definition: atomic_callback.h:25
void set_modifier(MirEvent &event, MirInputEventModifiers modifiers)
Definition: event_builders.cpp:181
Definition: point.h:30
MirPromptSessionState
Definition: common.h:109
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)
Definition: event_builders.cpp:269
int __attribute__((constructor)) init_google_protobuf()
Definition: google_protobuf_guard.cpp:21
int32_t MirTouchId
An identifier for a touch-point.
Definition: touch_event.h:40
void set_button_state(MirEvent &event, MirPointerButtons button_state)
Definition: event_builders.cpp:213
MirPointerAction
Possible pointer actions.
Definition: pointer_event.h:40
void set_cursor_position(MirEvent &event, mir::geometry::Point const &pos)
Definition: event_builders.cpp:202
EventUPtr make_event(frontend::SurfaceId const &surface_id, MirOrientation orientation)
MirOrientation
Direction relative to the "natural" orientation of the display.
Definition: common.h:164
MirKeyboardAction
Possible actions for changing key state.
Definition: keyboard_event.h:46
unsigned int MirInputEventModifiers
Definition: input_event.h:66
int64_t MirInputDeviceId
Definition: input_event.h:35
std::unique_ptr< MirEvent, void(*)(MirEvent *)> EventUPtr
Definition: event_builders.h:35
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:78
MirFormFactor
Form factor associated with a physical output.
Definition: common.h:197
unsigned int MirPointerButtons
Definition: pointer_event.h:85
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: event_private.h:181
MirTouchAction
Possible per touch actions for state changing.
Definition: touch_event.h:45
int const size
Definition: make_socket_rpc_channel.cpp:51

Copyright © 2012-2015 Canonical Ltd.
Generated on Wed Mar 30 00:29:56 UTC 2016