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 // Window configure event
50 EventUPtr make_event(frontend::SurfaceId const& surface_id, MirWindowAttrib 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
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 
75 void set_cursor_position(MirEvent& event, float x, float y);
76 void set_button_state(MirEvent& event, MirPointerButtons button_state);
77 
78 // Touch event
79 EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
80  std::vector<uint8_t> const& mac, MirInputEventModifiers modifiers);
81 
82 void add_touch(MirEvent &event, MirTouchId touch_id, MirTouchAction action,
83  MirTouchTooltype tooltype, float x_axis_value, float y_axis_value,
84  float pressure_value, float touch_major_value, float touch_minor_value, float size_value);
85 
86 // Pointer event
87 EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
88  std::vector<uint8_t> const& mac, MirInputEventModifiers modifiers, MirPointerAction action,
89  MirPointerButtons buttons_pressed,
90  float x_axis_value, float y_axis_value,
91  float hscroll_value, float vscroll_value,
92  float relative_x_value, float relative_y_value);
93 
94 // Input configuration event
95 EventUPtr make_event(std::chrono::nanoseconds timestamp,
96  MirPointerButtons pointer_buttons,
97  MirInputEventModifiers modifiers,
98  float x_axis_value,
99  float y_axis_value,
100  std::vector<InputDeviceState>&& device_states);
101 
102 EventUPtr make_event(MirInputDeviceId device_id, std::chrono::nanoseconds timestamp,
103  std::vector<uint8_t> const& mac, MirInputEventModifiers modifiers,
104  std::vector<ContactState> const& contacts);
105 
108 void scale_positions(MirEvent& event, float scale);
109 void set_window_id(MirEvent& event, int window_id);
110 
111 EventUPtr make_start_drag_and_drop_event(frontend::SurfaceId const& surface_id, std::vector<uint8_t> const& handle);
112 void set_drag_and_drop_handle(MirEvent& event, std::vector<uint8_t> const& handle);
113 }
114 }
115 
116 #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: enums.h:88
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:50
MirPromptSessionState
MirPromptSessionState
Definition: common.h:154
MirTouchTooltype
MirTouchTooltype
Identifiers for per-touch tool types.
Definition: enums.h:145
mir::events::set_window_id
void set_window_id(MirEvent &event, int window_id)
mir::geometry::Rectangle
Definition: rectangle.h:34
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:56
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:363
rectangle.h
MirPointerAction
MirPointerAction
Possible pointer actions.
Definition: enums.h:160
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:32
MirOrientation
MirOrientation
Direction relative to the "natural" orientation of the display.
Definition: common.h:209
MirKeyboardAction
MirKeyboardAction
Possible actions for changing key state.
Definition: enums.h:93
mir::EventUPtr
std::unique_ptr< MirEvent, void(*)(MirEvent *)> EventUPtr
Definition: event_builders.h:39
MirPointerButtons
unsigned int MirPointerButtons
Definition: enums.h:208
mir::events::scale_positions
void scale_positions(MirEvent &event, float scale)
event.h
mir::geometry::Point
Definition: point.h:32
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:32
MirTouchAction
MirTouchAction
Possible per touch actions for state changing.
Definition: enums.h:108
size.h

Copyright © 2012-2021 Canonical Ltd.
Generated on Thu Jun 24 19:55:23 UTC 2021
This documentation is licensed under the GPL version 2 or 3.