Mir
keymap_event.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2016 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  * Authored by: Brandon Schaefer <brandon.schaefer@canonical.com>
17  */
18 
19 #ifndef MIR_COMMON_KEYMAP_EVENT_H_
20 #define MIR_COMMON_KEYMAP_EVENT_H_
21 
22 #include <xkbcommon/xkbcommon.h>
23 #include <limits>
24 
25 #include "mir/events/event.h"
26 
28 {
30 
31  int surface_id() const;
32  void set_surface_id(int id);
33 
36 
37  char const* buffer() const;
38  /* FIXME We takes over ownership of the buffer pointer, but we should not be.
39  Either user a unique_ptr here later (when we dont depend on is_trivially_copyable)
40  or copy it into a vector or do a deep copy.
41  */
42  void set_buffer(char const* buffer);
43  void free_buffer();
44 
45  size_t size() const;
46  void set_size(size_t size);
47 
48  /* FIXME Need to handle the special case of Keymap events due to char const* buffer */
49  static mir::EventUPtr deserialize(std::string const& bytes);
50  static std::string serialize(MirEvent const* event);
51  MirEvent* clone() const;
52 
53 private:
54  int surface_id_{-1};
55  MirInputDeviceId device_id_{std::numeric_limits<MirInputDeviceId>::max()};
56  char const* buffer_{nullptr};
57  size_t size_{0};
58 };
59 
60 #endif /* MIR_COMMON_KEYMAP_EVENT_H_ */
void free_buffer()
Definition: keymap_event.cpp:151
Definition: keymap_event.h:27
void set_buffer(char const *buffer)
Definition: keymap_event.cpp:146
char const * buffer() const
Definition: keymap_event.cpp:141
MirKeymapEvent()
Definition: keymap_event.cpp:42
void set_surface_id(int id)
Definition: keymap_event.cpp:126
int64_t MirInputDeviceId
Definition: input_event.h:35
std::unique_ptr< MirEvent, void(*)(MirEvent *)> EventUPtr
Definition: seat.h:32
size_t size() const
Definition: keymap_event.cpp:156
MirEvent * clone() const
Definition: keymap_event.cpp:47
int surface_id() const
Definition: keymap_event.cpp:121
static std::string serialize(MirEvent const *event)
Definition: keymap_event.cpp:103
static mir::EventUPtr deserialize(std::string const &bytes)
Definition: keymap_event.cpp:61
void set_size(size_t size)
Definition: keymap_event.cpp:161
void set_device_id(MirInputDeviceId id)
Definition: keymap_event.cpp:136
MirInputDeviceId device_id() const
Definition: keymap_event.cpp:131
Definition: event.h:30

Copyright © 2012-2015 Canonical Ltd.
Generated on Thu Sep 8 14:50:19 UTC 2016