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 2 or 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"
28 #include "mir/frontend/surface_id.h"
29 #include "mir/events/input_device_state.h"
30 #include "mir/events/contact_state.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
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 MIR_FOR_REMOVAL_IN_VERSION_1("use make_event with MirWindowAttribute instead");
52 // Window configure event
53 EventUPtr make_event(frontend::SurfaceId const& surface_id, MirWindowAttrib attribute, int value);
54 // Close surface event
55 EventUPtr make_event(frontend::SurfaceId const& surface_id);
56 // Keymap event
57 EventUPtr make_event(frontend::SurfaceId const& surface_id, MirInputDeviceId id, std::string const& model,
58  std::string const& layout, std::string const& variant, std::string const& options);
59 // Surface output event
61  frontend::SurfaceId const& surface_id,
62  int dpi,
63  float scale,
64  double refresh_rate,
65  MirFormFactor form_factor,
66  uint32_t id);
67 
69 EventUPtr make_event(frontend::SurfaceId const& surface_id, geometry::Rectangle placement);
70 
71 // Key event
72 EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
73  std::vector<uint8_t> const& cookie, MirKeyboardAction action, xkb_keysym_t key_code,
74  int scan_code, MirInputEventModifiers modifiers);
75 
76 void set_modifier(MirEvent& event, MirInputEventModifiers modifiers);
77 void set_cursor_position(MirEvent& event, mir::geometry::Point const& pos);
78 void set_cursor_position(MirEvent& event, float x, float y);
79 void set_button_state(MirEvent& event, MirPointerButtons button_state);
80 
81 // Deprecated version with uint64_t mac
82 EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
83  uint64_t mac, MirKeyboardAction action, xkb_keysym_t key_code,
84  int scan_code, MirInputEventModifiers modifiers) MIR_FOR_REMOVAL_IN_VERSION_1("unused");
85 
86 // Deprecated version without mac
87 EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
88  MirKeyboardAction action, xkb_keysym_t key_code,
89  int scan_code, MirInputEventModifiers modifiers) MIR_FOR_REMOVAL_IN_VERSION_1("unused");
90 
91 // Touch event
92 EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
93  std::vector<uint8_t> const& mac, MirInputEventModifiers modifiers);
94 
95 // Deprecated version with uint64_t mac
96 EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
97  uint64_t mac, MirInputEventModifiers modifiers) MIR_FOR_REMOVAL_IN_VERSION_1("unused");
98 
99 // Deprecated version without mac
100 EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
102 
103 void add_touch(MirEvent &event, MirTouchId touch_id, MirTouchAction action,
104  MirTouchTooltype tooltype, float x_axis_value, float y_axis_value,
105  float pressure_value, float touch_major_value, float touch_minor_value, float size_value);
106 
107 // Pointer event
108 // Deprecated version without relative axis
109 EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
110  uint64_t mac, MirInputEventModifiers modifiers, MirPointerAction action,
111  MirPointerButtons buttons_pressed,
112  float x_axis_value, float y_axis_value,
113  float hscroll_value, float vscroll_value) MIR_FOR_REMOVAL_IN_VERSION_1("unused");
114 
115 // Deprecated version without relative axis and mac
116 EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
117  MirInputEventModifiers modifiers, MirPointerAction action,
118  MirPointerButtons buttons_pressed,
119  float x_axis_value, float y_axis_value,
120  float hscroll_value, float vscroll_value) MIR_FOR_REMOVAL_IN_VERSION_1("unused");
121 
122 EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
123  std::vector<uint8_t> const& mac, MirInputEventModifiers modifiers, MirPointerAction action,
124  MirPointerButtons buttons_pressed,
125  float x_axis_value, float y_axis_value,
126  float hscroll_value, float vscroll_value,
127  float relative_x_value, float relative_y_value);
128 
129 // Deprecated version with uint64_t mac
130 EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
131  uint64_t mac, MirInputEventModifiers modifiers, MirPointerAction action,
132  MirPointerButtons buttons_pressed,
133  float x_axis_value, float y_axis_value,
134  float hscroll_value, float vscroll_value,
135  float relative_x_value, float relative_y_value) MIR_FOR_REMOVAL_IN_VERSION_1("unused");
136 
137 // Deprecated version without mac
138 EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
139  MirInputEventModifiers modifiers, MirPointerAction action,
140  MirPointerButtons buttons_pressed,
141  float x_axis_value, float y_axis_value,
142  float hscroll_value, float vscroll_value,
143  float relative_x_value, float relative_y_value) MIR_FOR_REMOVAL_IN_VERSION_1("unused");
144 
145 // Input configuration event
147  MirInputDeviceId id, std::chrono::nanoseconds time) MIR_FOR_REMOVAL_IN_VERSION_1("unused");
148 
149 EventUPtr make_event(std::chrono::nanoseconds timestamp,
150  MirPointerButtons pointer_buttons,
151  MirInputEventModifiers modifiers,
152  float x_axis_value,
153  float y_axis_value,
154  std::vector<InputDeviceState>&& device_states);
155 
156 EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
157  std::vector<uint8_t> const& mac, MirInputEventModifiers modifiers,
158  std::vector<ContactState> const& contacts);
159 
160 EventUPtr clone_event(MirEvent const& event);
161 void transform_positions(MirEvent& event, mir::geometry::Displacement const& movement);
162 void set_window_id(MirEvent& event, int window_id);
163 
164 EventUPtr make_start_drag_and_drop_event(frontend::SurfaceId const& surface_id, std::vector<uint8_t> const& handle);
165 void set_drag_and_drop_handle(MirEvent& event, std::vector<uint8_t> const& handle);
166 }
167 }
168 
169 #endif // MIR_EVENT_BUILDERS_H_
mir::events::set_modifier
void set_modifier(MirEvent &event, MirInputEventModifiers modifiers)
mir::events::add_touch
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)
point.h
MirInputEventModifiers
unsigned int MirInputEventModifiers
Definition: input_event.h:67
mir::events::make_event
EventUPtr make_event(frontend::SurfaceId const &surface_id, MirOrientation orientation)
mir::events::set_cursor_position
void set_cursor_position(MirEvent &event, mir::geometry::Point const &pos)
displacement.h
mir::events::set_button_state
void set_button_state(MirEvent &event, MirPointerButtons button_state)
MirEvent
struct MirEvent MirEvent
Definition: event.h:84
MirPromptSessionState
MirPromptSessionState
Definition: common.h:219
MirTouchTooltype
MirTouchTooltype
Identifiers for per-touch tool types.
Definition: touch_event.h:82
mir::events::set_window_id
void set_window_id(MirEvent &event, int window_id)
mir::geometry::Rectangle
Definition: rectangle.h:33
MIR_FOR_REMOVAL_IN_VERSION_1
#define MIR_FOR_REMOVAL_IN_VERSION_1(message)
Definition: deprecations.h:30
mir
Definition: splash_session.h:24
MirWindowAttrib
MirWindowAttrib
Attributes of a window that the client and server/shell may wish to get or set over the wire.
Definition: common.h:76
mir::events::transform_positions
void transform_positions(MirEvent &event, mir::geometry::Displacement const &movement)
MirFormFactor
MirFormFactor
Form factor associated with a physical output.
Definition: common.h:429
rectangle.h
MirInputConfigurationAction
MirInputConfigurationAction
MirInputConfigurationEvent indicates a configuration change in the input device subsystem....
Definition: input_configuration_event.h:44
MirPointerAction
MirPointerAction
Possible pointer actions.
Definition: pointer_event.h:40
MirInputDeviceId
int64_t MirInputDeviceId
Definition: mir_input_device_types.h:31
mir::events::set_drag_and_drop_handle
void set_drag_and_drop_handle(MirEvent &event, std::vector< uint8_t > const &handle)
mir::geometry::Displacement
Definition: displacement.h:33
MirOrientation
MirOrientation
Direction relative to the "natural" orientation of the display.
Definition: common.h:275
MirSurfaceAttrib
MirSurfaceAttrib
Attributes of a surface that the client and server/shell may wish to get or set over the wire.
Definition: common.h:55
MirKeyboardAction
MirKeyboardAction
Possible actions for changing key state.
Definition: keyboard_event.h:46
mir::EventUPtr
std::unique_ptr< MirEvent, void(*)(MirEvent *)> EventUPtr
Definition: event_builders.h:39
MirPointerButtons
unsigned int MirPointerButtons
Definition: pointer_event.h:88
event.h
mir::geometry::Point
Definition: point.h:30
mir::events::clone_event
EventUPtr clone_event(MirEvent const &event)
mir::events::make_start_drag_and_drop_event
EventUPtr make_start_drag_and_drop_event(frontend::SurfaceId const &surface_id, std::vector< uint8_t > const &handle)
MirTouchId
int32_t MirTouchId
An identifier for a touch-point.
Definition: touch_event.h:40
mir::geometry::Size
Definition: size.h:31
MirTouchAction
MirTouchAction
Possible per touch actions for state changing.
Definition: touch_event.h:45
size.h

Copyright © 2012-2022 Canonical Ltd.
Generated on Fri Dec 9 06:40:35 UTC 2022
This documentation is licensed under the GPL version 2 or 3.