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"
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
37namespace mir
38{
39 typedef std::unique_ptr<MirEvent, void(*)(MirEvent*)> EventUPtr;
40
41namespace events
42{
43// Surface orientation change event
44EventUPtr make_event(frontend::SurfaceId const& surface_id, MirOrientation orientation);
45// Prompt session state change event
47// Surface resize event
48EventUPtr make_event(frontend::SurfaceId const& surface_id, geometry::Size const& size);
49// Surface configure event
50EventUPtr make_event(frontend::SurfaceId const& surface_id, MirSurfaceAttrib attribute, int value)
51MIR_FOR_REMOVAL_IN_VERSION_1("use make_event with MirWindowAttribute instead");
52// Window configure event
53EventUPtr make_event(frontend::SurfaceId const& surface_id, MirWindowAttrib attribute, int value);
54// Close surface event
55EventUPtr make_event(frontend::SurfaceId const& surface_id);
56// Keymap event
57EventUPtr 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
69EventUPtr make_event(frontend::SurfaceId const& surface_id, geometry::Rectangle placement);
70
71// Key event
72EventUPtr 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
78void set_cursor_position(MirEvent& event, float x, float y);
79void set_button_state(MirEvent& event, MirPointerButtons button_state);
80
81// Deprecated version with uint64_t mac
82EventUPtr 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
87EventUPtr 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
92EventUPtr 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
96EventUPtr 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
100EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
102
103void 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
109EventUPtr 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
116EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
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
122EventUPtr 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
130EventUPtr 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
138EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
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
149EventUPtr 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
156EventUPtr 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
162void set_window_id(MirEvent& event, int window_id);
163
164EventUPtr make_start_drag_and_drop_event(frontend::SurfaceId const& surface_id, std::vector<uint8_t> const& handle);
165void set_drag_and_drop_handle(MirEvent& event, std::vector<uint8_t> const& handle);
166}
167}
168
169#endif // MIR_EVENT_BUILDERS_H_
#define MIR_FOR_REMOVAL_IN_VERSION_1(message)
Definition: deprecations.h:30
MirFormFactor
Form factor associated with a physical output.
Definition: common.h:429
MirPointerAction
Possible pointer actions.
Definition: pointer_event.h:40
MirOrientation
Direction relative to the "natural" orientation of the display.
Definition: common.h:275
unsigned int MirPointerButtons
Definition: pointer_event.h:88
int32_t MirTouchId
An identifier for a touch-point.
Definition: touch_event.h:40
int64_t MirInputDeviceId
Definition: mir_input_device_types.h:31
MirKeyboardAction
Possible actions for changing key state.
Definition: keyboard_event.h:46
MirWindowAttrib
Attributes of a window that the client and server/shell may wish to get or set over the wire.
Definition: common.h:77
MirInputConfigurationAction
MirInputConfigurationEvent indicates a configuration change in the input device subsystem....
Definition: input_configuration_event.h:45
struct MirEvent MirEvent
Definition: event.h:84
MirSurfaceAttrib
Attributes of a surface that the client and server/shell may wish to get or set over the wire.
Definition: common.h:56
MirPromptSessionState
Definition: common.h:220
MirTouchTooltype
Identifiers for per-touch tool types.
Definition: touch_event.h:82
MirTouchAction
Possible per touch actions for state changing.
Definition: touch_event.h:45
unsigned int MirInputEventModifiers
Definition: input_event.h:67
void set_modifier(MirEvent &event, MirInputEventModifiers modifiers)
void set_button_state(MirEvent &event, MirPointerButtons button_state)
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)
void set_window_id(MirEvent &event, int window_id)
void set_cursor_position(MirEvent &event, mir::geometry::Point const &pos)
EventUPtr make_start_drag_and_drop_event(frontend::SurfaceId const &surface_id, std::vector< uint8_t > const &handle)
EventUPtr make_event(frontend::SurfaceId const &surface_id, MirOrientation orientation)
void set_drag_and_drop_handle(MirEvent &event, std::vector< uint8_t > const &handle)
void transform_positions(MirEvent &event, mir::geometry::Displacement const &movement)
EventUPtr clone_event(MirEvent const &event)
Definition: splash_session.h:24
std::unique_ptr< MirEvent, void(*)(MirEvent *)> EventUPtr
Definition: event_builders.h:39
Definition: displacement.h:34
Definition: point.h:31
Definition: rectangle.h:34
Definition: size.h:32

Copyright © 2012-2022 Canonical Ltd.
Generated on Wed Dec 28 21:01:08 UTC 2022
This documentation is licensed under the GPL version 2 or 3.