Mir

Merge lp:~mir-team/mir/add-more-event-getters into lp:mir

Proposed by Robert Carr
Status: Merged
Approved by: Robert Carr
Approved revision: no longer in the source branch.
Merged at revision: 2182
Proposed branch: lp:~mir-team/mir/add-more-event-getters
Merge into: lp:mir
Prerequisite: lp:~mir-team/mir/introduce-mir-event-2.0
Diff against target: 1720 lines (+990/-331)
24 files modified
client-ABI-sha1sums (+11/-5)
common-ABI-sha1sums (+12/-6)
examples/fingerpaint.c (+1/-1)
include/common/mir/log.h (+14/-1)
include/common/mir_toolkit/client_types.h (+1/-1)
include/common/mir_toolkit/event.h (+24/-0)
include/common/mir_toolkit/events/event.h (+85/-211)
include/common/mir_toolkit/events/event_deprecated.h (+255/-0)
include/common/mir_toolkit/events/input/input_event.h (+40/-13)
include/common/mir_toolkit/events/input/key_input_event.h (+1/-25)
include/common/mir_toolkit/events/input/touch_input_event.h (+8/-0)
include/common/mir_toolkit/events/orientation_event.h (+45/-0)
include/common/mir_toolkit/events/prompt_session_event.h (+45/-0)
include/common/mir_toolkit/events/resize_event.h (+53/-0)
include/common/mir_toolkit/events/surface_event.h (+53/-0)
platform-ABI-sha1sums (+12/-6)
server-ABI-sha1sums (+12/-6)
src/client/mirclient.pc.in (+1/-1)
src/common/CMakeLists.txt (+4/-0)
src/common/event.cpp (+179/-0)
src/common/input/input_event.cpp (+101/-52)
src/include/common/mir/event_type_to_string.h (+30/-0)
src/server/mirserver.pc.in (+1/-1)
tests/unit-tests/input/test_input_event.cpp (+2/-2)
To merge this branch: bzr merge lp:~mir-team/mir/add-more-event-getters
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Kevin DuBois (community) Approve
Alberto Aguirre (community) Approve
Alan Griffiths Abstain
Cemil Azizoglu (community) Approve
Daniel van Vugt Abstain
Review via email: mp+243579@code.launchpad.net

Commit message

Deprecate direct access to MirEvent.

Description of the change

This completes deprecation of direct access to MirEvent.

The old event headers are moved to a new event_private header. Accessors are added for MirSurfaceEvent, Resize Event, etc...event headers are moved to mir_toolkit/events to avoid polluting top level dir or putting too much in one header.

Boring stuff I know but trying to move the deprecation train along :)

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

This approach scales poorly in terms of complexity and maintenance for obvious reasons. And I think that the medicine is worse than the disease here, but the team wants to do it this way...

review: Abstain
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

I think you can eliminate all those casts though:

MirResizeEvent const* mir_event_get_resize_event(MirEvent const* ev)
   ...
   return reinterpret_cast<MirResizeEvent const*>(ev);

becomes:

MirResizeEvent const* mir_event_get_resize_event(MirEvent const* ev)
   ...
   return &ev->resize;

review: Needs Fixing
Revision history for this message
Robert Carr (robertcarr) wrote :

Casts be gone!

I think the medicine vs disease metaphor is apt...it is a trade off...im in favor of this given that the structure could be intended to last for a decade!

Revision history for this message
Daniel van Vugt (vanvugt) :
review: Abstain
Revision history for this message
Kevin DuBois (kdub) wrote :

needs info:
The intermediary seems a bit burdensome in terms of new API... what's the difficult part about transitioning downstreams to the new API again?

review: Needs Information
Revision history for this message
Cemil Azizoglu (cemil-azizoglu) wrote :

93 + * Retrieve the surface ID associated wih this MirCloseSurfaceEvent
spelling

929 + abort();
... and others
do we just abort with no error message or anything?

review: Needs Fixing
Revision history for this message
Robert Carr (robertcarr) wrote :

Spoke to Kevin on IRC...he is going to come back and post more :)

Cemil: At l 93 that's the correct spelling of retrieve right? This line is gone now anyway but I believe the spellings to be correct...

I believe abort with no error is the current strategy as discussed in introduce-event-2.0 MR + email thread. Maybe logging is appropriate?

Revision history for this message
Robert Carr (robertcarr) wrote :

Chris correctly points out the surface_id getters are not required or even useful and thus have been removed

Revision history for this message
Cemil Azizoglu (cemil-azizoglu) wrote :

> Cemil: At l 93 that's the correct spelling of retrieve right? This line is
> gone now anyway but I believe the spellings to be correct...

It was the "wih" but is now gone.

>
> I believe abort with no error is the current strategy as discussed in
> introduce-event-2.0 MR + email thread. Maybe logging is appropriate?

Yes abort is ok, just wish there was a semi-useful log message to go with it.

Revision history for this message
Robert Carr (robertcarr) wrote :

Log messages added. I would call them semi useless over semi useful :p...no matter what they say you always have to do the same thing...use a debugger to find the calling frame.

Revision history for this message
Cemil Azizoglu (cemil-azizoglu) wrote :

We may not always have the ability to repro things with a debugger (think problem reports from the field for rare, hard-to-repro bugs, or the person seeing it may not know how to use a debugger, etc).

This at least gives us a bit of a clue as to where to look.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Robert Carr (robertcarr) wrote :

MAde some changes to symbols.map which I think are correct.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Robert Carr (robertcarr) wrote :

Move modifiers to the MirInputEvent namespace and added mir_touch_event_get_modifiers.

Revision history for this message
Robert Carr (robertcarr) wrote :

I added mircommon to the pgkconfig file so downstreams can use these newly exported symbols.

Revision history for this message
Robert Carr (robertcarr) wrote :

pkgconfig file for mirserver and client that is

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

475 === added file 'include/common/mir_toolkit/events/event_private.h'

It seems odd to call a public header "private" and also to include it include/common/mir_toolkit/events/event.h.

I assume it is there to support the deprecated API? And will move from the public API once downstream toolkits have had the opportunity to migrate?

~~~~

1636 if(touch_index > old_mev.pointer_count)
1637 + {
1638 + mir::log_critical("touch index is greater than pointer count");
1639 abort();
1640 + }
etc.

This if...log...abort pattern calls out to be formalized - either as a mir::require() function (or maybe a MIR_REQUIRE macro if we feel that __LINE__ and __FILE__ could be useful additions).

review: Needs Information
Revision history for this message
Robert Carr (robertcarr) wrote :

>> I assume it is there to support the deprecated API? And will move from the public API once >> downstream toolkits have had the opportunity to migrate?

Yes. I could rename it to event_deprecated.h :) (and will do so!)

>>
>> This if...log...abort pattern calls out to be formalized - either as a mir::require()
>> function (or maybe a MIR_REQUIRE macro if we feel that __LINE__ and __FILE__ could be useful >> additions).

Ok added mir::logging::require and MIR_REQUIRE with __LINE__ __FILE__ and stringification of cond.

Revision history for this message
Robert Carr (robertcarr) wrote :

I see Alberto has already added MIR_REQUIRE as requested in another branch so I've reverted my MIR_REQUIRE.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

It's hard to be sure about the end state as there's a lot of "in flight".

review: Abstain
Revision history for this message
Alberto Aguirre (albaguirre) wrote :

===
820 +n * Copyright © 2014 Canonical Ltd.
===
Extraneous n

Need info:
I guess this is kinda of a pre-existing issue, but I'm wondering about managing the client ABI, as clients will have to link against mircommon to use these event getter apis; there are symbols (all the cursor names) that are intended for client use as well. What is the plan to manage these breakages? Should mircommon put those apis under the MIR_CLIENT symbol version stanza?

review: Needs Fixing
Revision history for this message
Alberto Aguirre (albaguirre) wrote :

LGTM

review: Approve
Revision history for this message
Alberto Aguirre (albaguirre) wrote :

And summarizing from IRC discussion about the symbols of mircommon (but outside the scope of this MP)

It would probably best if we split the mircommon library into its public and private parts (perhaps mircommon and mircommonprivate)

Private meaning the symbols needed only by mir libraries - mircommon, mirserver, etc - (basically what's exposed through src/include/common)

Public meaning any symbols for external consumption - like the apis defined in this MP, essentially what is exposed through include/common

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

The curse strikes again: "Text conflict in client-ABI-sha1sums"

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

> The curse strikes again: "Text conflict in client-ABI-sha1sums"

Fixed

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Kevin DuBois (kdub) wrote :

given that MirEvent 2.0 work is in full swing, this seems like the next step. So okay by me

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

Merging 'lp:~mir-team/mir/add-more-event-getters' in to 'mir'.
Text conflict in common-ABI-sha1sums
Text conflict in platform-ABI-sha1sums
Text conflict in server-ABI-sha1sums
Text conflict in src/common/symbols.map
4 conflicts encountered.

The curse lives!

Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'client-ABI-sha1sums'
2--- client-ABI-sha1sums 2014-12-18 12:11:25 +0000
3+++ client-ABI-sha1sums 2014-12-19 16:55:48 +0000
4@@ -9,13 +9,19 @@
5 42bcad3a72b47f4d904e6b7033b0001b89cb9779 include/client/mir_toolkit/mir_surface.h
6 b141c4d79802ad626d969249c0004744e5c2a525 include/client/mir_toolkit/mir_wait.h
7 6f7b4ecc22afba923806ed2bd7d8244be90b0cfd include/client/mir_toolkit/version.h
8-23a009b06de7bac17d33d988dc8d968be8bc094a include/common/mir_toolkit/client_types.h
9+3350dac884d6006753de2a955bc7a05663cd9449 include/common/mir_toolkit/client_types.h
10 c7c708734715a6d1b6fb2652584adb912071a518 include/common/mir_toolkit/common.h
11 fce4c1a9e0d037244f7e9e96ea2d8eaab4fc404c include/common/mir_toolkit/cursors.h
12-d71dddf6c4275ee423d3e0fa204e3b77b4d87401 include/common/mir_toolkit/event.h
13-49403c824f69fa1cc1f58bf5fe635639148765eb include/common/mir_toolkit/input/input_event.h
14-f531c6a49883884a6c694393d5614f9942fe2703 include/common/mir_toolkit/input/key_input_event.h
15-fd6d86becfa5ffa367480fd2654180f6ffcbf059 include/common/mir_toolkit/input/touch_input_event.h
16+f4d39e9893ce6308bddd83a49b90f0051f565323 include/common/mir_toolkit/event.h
17+2507f2929415aa423f9551d3c595c439fe1c6efd include/common/mir_toolkit/events/event_deprecated.h
18+ae75a0434588f2d086936e2a2dbe1e919a5fbc50 include/common/mir_toolkit/events/event.h
19+c591a02a8e9851db342c310cf829d018a1eddb51 include/common/mir_toolkit/events/input/input_event.h
20+7748a12138474e9be218eeb8f14b372af0fcec7e include/common/mir_toolkit/events/input/key_input_event.h
21+de7c23453e6d897296f32e49d9ba952a1baa0200 include/common/mir_toolkit/events/input/touch_input_event.h
22+8642e85a50e2de651589da3ced70e0fc0a915f26 include/common/mir_toolkit/events/orientation_event.h
23+f623dcf3c2ed134c1be20106eb54bcccc84af462 include/common/mir_toolkit/events/prompt_session_event.h
24+633893b0def2b71f969872908a5b3529bc2fbf10 include/common/mir_toolkit/events/resize_event.h
25+5944dc0556223cc54b45b32c8aa70b8c60ee0337 include/common/mir_toolkit/events/surface_event.h
26 4975998aa1056ed0d39dcc538127453e516ad8e9 include/common/mir_toolkit/mesa/native_display.h
27 101017c17714a57db57d79b7b5e7df40a3568236 include/common/mir_toolkit/mir_native_buffer.h
28 4ce105a3a18241f5d33db31939ca15256f353c37 include/common/mir_toolkit/mir_version_number.h
29
30=== modified file 'common-ABI-sha1sums'
31--- common-ABI-sha1sums 2014-12-19 04:52:10 +0000
32+++ common-ABI-sha1sums 2014-12-19 16:55:48 +0000
33@@ -13,16 +13,22 @@
34 208cd6aed5ef5f8f39b3eb86604e4133cb840485 include/common/mir/input/input_receiver_thread.h
35 be7d58c9fde2ce91cc66dd6144b76e08b536266b include/common/mir/int_wrapper.h
36 2de47e2790d0f7643e23eada2d8aa2987f58d086 include/common/mir/logging/logger.h
37-5ab81600183fdaca3fb949beb2307d1f6e4cbb61 include/common/mir/log.h
38+38f159ee67cf380ebd2bfee7a98d62bc0397c631 include/common/mir/log.h
39 31b9c24e2ce7194aeea6694e81c160354033d28a include/common/mir/optional_value.h
40 9ae8473df05dd9e048a73797f01a2f34f7447554 include/common/mir/time/types.h
41-23a009b06de7bac17d33d988dc8d968be8bc094a include/common/mir_toolkit/client_types.h
42+3350dac884d6006753de2a955bc7a05663cd9449 include/common/mir_toolkit/client_types.h
43 c7c708734715a6d1b6fb2652584adb912071a518 include/common/mir_toolkit/common.h
44 fce4c1a9e0d037244f7e9e96ea2d8eaab4fc404c include/common/mir_toolkit/cursors.h
45-d71dddf6c4275ee423d3e0fa204e3b77b4d87401 include/common/mir_toolkit/event.h
46-49403c824f69fa1cc1f58bf5fe635639148765eb include/common/mir_toolkit/input/input_event.h
47-f531c6a49883884a6c694393d5614f9942fe2703 include/common/mir_toolkit/input/key_input_event.h
48-fd6d86becfa5ffa367480fd2654180f6ffcbf059 include/common/mir_toolkit/input/touch_input_event.h
49+f4d39e9893ce6308bddd83a49b90f0051f565323 include/common/mir_toolkit/event.h
50+2507f2929415aa423f9551d3c595c439fe1c6efd include/common/mir_toolkit/events/event_deprecated.h
51+ae75a0434588f2d086936e2a2dbe1e919a5fbc50 include/common/mir_toolkit/events/event.h
52+c591a02a8e9851db342c310cf829d018a1eddb51 include/common/mir_toolkit/events/input/input_event.h
53+7748a12138474e9be218eeb8f14b372af0fcec7e include/common/mir_toolkit/events/input/key_input_event.h
54+de7c23453e6d897296f32e49d9ba952a1baa0200 include/common/mir_toolkit/events/input/touch_input_event.h
55+8642e85a50e2de651589da3ced70e0fc0a915f26 include/common/mir_toolkit/events/orientation_event.h
56+f623dcf3c2ed134c1be20106eb54bcccc84af462 include/common/mir_toolkit/events/prompt_session_event.h
57+633893b0def2b71f969872908a5b3529bc2fbf10 include/common/mir_toolkit/events/resize_event.h
58+5944dc0556223cc54b45b32c8aa70b8c60ee0337 include/common/mir_toolkit/events/surface_event.h
59 4975998aa1056ed0d39dcc538127453e516ad8e9 include/common/mir_toolkit/mesa/native_display.h
60 101017c17714a57db57d79b7b5e7df40a3568236 include/common/mir_toolkit/mir_native_buffer.h
61 4ce105a3a18241f5d33db31939ca15256f353c37 include/common/mir_toolkit/mir_version_number.h
62
63=== modified file 'examples/fingerpaint.c'
64--- examples/fingerpaint.c 2014-12-15 06:24:03 +0000
65+++ examples/fingerpaint.c 2014-12-19 16:55:48 +0000
66@@ -17,7 +17,7 @@
67 */
68
69 #include "mir_toolkit/mir_client_library.h"
70-#include "mir_toolkit/input/input_event.h"
71+#include "mir_toolkit/events/input/input_event.h"
72
73 #include <stdio.h>
74 #include <signal.h>
75
76=== modified file 'include/common/mir/log.h'
77--- include/common/mir/log.h 2014-12-09 03:14:55 +0000
78+++ include/common/mir/log.h 2014-12-19 16:55:48 +0000
79@@ -59,7 +59,20 @@
80 MIR_LOG_COMPONENT, fmt, args...);
81 }
82
83-// TODO later as required: error, critical, warning, debug
84+inline void log_critical(std::string const& message)
85+{
86+ ::mir::log(::mir::logging::Severity::critical,
87+ MIR_LOG_COMPONENT, message);
88+}
89+
90+template<typename... Args>
91+void log_critical(char const* fmt, Args... args)
92+{
93+ ::mir::log(::mir::logging::Severity::critical,
94+ MIR_LOG_COMPONENT, fmt, args...);
95+}
96+
97+// TODO later as required: error, warning, debug
98
99 } // (nested anonymous) namespace
100 #endif
101
102=== modified file 'include/common/mir_toolkit/client_types.h'
103--- include/common/mir_toolkit/client_types.h 2014-12-15 06:24:03 +0000
104+++ include/common/mir_toolkit/client_types.h 2014-12-19 16:55:48 +0000
105@@ -21,7 +21,7 @@
106 #ifndef MIR_TOOLKIT_CLIENT_TYPES_H_
107 #define MIR_TOOLKIT_CLIENT_TYPES_H_
108
109-#include <mir_toolkit/event.h>
110+#include <mir_toolkit/events/event.h>
111 #include <mir_toolkit/common.h>
112
113 #include <stddef.h>
114
115=== added file 'include/common/mir_toolkit/event.h'
116--- include/common/mir_toolkit/event.h 1970-01-01 00:00:00 +0000
117+++ include/common/mir_toolkit/event.h 2014-12-19 16:55:48 +0000
118@@ -0,0 +1,24 @@
119+/*
120+ * Copyright © 2014 Canonical Ltd.
121+ *
122+ * This program is free software: you can redistribute it and/or modify it
123+ * under the terms of the GNU Lesser General Public License version 3,
124+ * as published by the Free Software Foundation.
125+ *
126+ * This program is distributed in the hope that it will be useful,
127+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
128+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
129+ * GNU Lesser General Public License for more details.
130+ *
131+ * You should have received a copy of the GNU Lesser General Public License
132+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
133+ *
134+ * Authored by: Robert Carr <robert.carr@canonical.com>
135+ */
136+
137+#ifndef MIR_TOOLKIT_EVENT_COMPAT_HEADER_H_
138+#define MIR_TOOLKIT_EVENT_COMPAT_HEADER_H_
139+
140+#include "mir_toolkit/events/event.h"
141+
142+#endif /* MIR_TOOLKIT_EVENT_COMPAT_HEADER_H_ */
143
144=== added directory 'include/common/mir_toolkit/events'
145=== renamed file 'include/common/mir_toolkit/event.h' => 'include/common/mir_toolkit/events/event.h'
146--- include/common/mir_toolkit/event.h 2014-12-11 02:43:01 +0000
147+++ include/common/mir_toolkit/events/event.h 2014-12-19 16:55:48 +0000
148@@ -1,5 +1,5 @@
149 /*
150- * Copyright © 2013 Canonical Ltd.
151+ * Copyright © 2014 Canonical Ltd.
152 *
153 * This program is free software: you can redistribute it and/or modify it
154 * under the terms of the GNU Lesser General Public License version 3,
155@@ -13,7 +13,7 @@
156 * You should have received a copy of the GNU Lesser General Public License
157 * along with this program. If not, see <http://www.gnu.org/licenses/>.
158 *
159- * Authored by: Thomas Voss <thomas.voss@canonical.com>
160+ * Authored by: Robert Carr <robert.carr@canonical.com>
161 */
162
163 #ifndef MIR_TOOLKIT_EVENT_H_
164@@ -30,10 +30,6 @@
165 */
166 extern "C" {
167 #endif
168-/* TODO: To the moon. */
169-#define MIR_INPUT_EVENT_MAX_POINTER_COUNT 16
170-
171-typedef int64_t nsecs_t;
172
173 typedef enum
174 {
175@@ -49,211 +45,29 @@
176 mir_event_type_input
177 } MirEventType;
178
179-typedef enum {
180- mir_key_action_down = 0,
181- mir_key_action_up = 1,
182- mir_key_action_multiple = 2
183-} MirKeyAction;
184-
185-typedef enum {
186- mir_key_flag_woke_here = 0x1,
187- mir_key_flag_soft_keyboard = 0x2,
188- mir_key_flag_keep_touch_mode = 0x4,
189- mir_key_flag_from_system = 0x8,
190- mir_key_flag_editor_action = 0x10,
191- mir_key_flag_canceled = 0x20,
192- mir_key_flag_virtual_hard_key = 0x40,
193- mir_key_flag_long_press = 0x80,
194- mir_key_flag_canceled_long_press = 0x100,
195- mir_key_flag_tracking = 0x200,
196- mir_key_flag_fallback = 0x400
197-} MirKeyFlag;
198-
199-typedef enum {
200- mir_key_modifier_none = 0,
201- mir_key_modifier_alt = 0x02,
202- mir_key_modifier_alt_left = 0x10,
203- mir_key_modifier_alt_right = 0x20,
204- mir_key_modifier_shift = 0x01,
205- mir_key_modifier_shift_left = 0x40,
206- mir_key_modifier_shift_right = 0x80,
207- mir_key_modifier_sym = 0x04,
208- mir_key_modifier_function = 0x08,
209- mir_key_modifier_ctrl = 0x1000,
210- mir_key_modifier_ctrl_left = 0x2000,
211- mir_key_modifier_ctrl_right = 0x4000,
212- mir_key_modifier_meta = 0x10000,
213- mir_key_modifier_meta_left = 0x20000,
214- mir_key_modifier_meta_right = 0x40000,
215- mir_key_modifier_caps_lock = 0x100000,
216- mir_key_modifier_num_lock = 0x200000,
217- mir_key_modifier_scroll_lock = 0x400000
218-} MirKeyModifier;
219-
220-typedef enum {
221- mir_motion_action_down = 0,
222- mir_motion_action_up = 1,
223- mir_motion_action_move = 2,
224- mir_motion_action_cancel = 3,
225- mir_motion_action_outside = 4,
226- mir_motion_action_pointer_down = 5,
227- mir_motion_action_pointer_up = 6,
228- mir_motion_action_hover_move = 7,
229- mir_motion_action_scroll = 8,
230- mir_motion_action_hover_enter = 9,
231- mir_motion_action_hover_exit = 10
232-} MirMotionAction;
233-
234-typedef enum {
235- mir_motion_flag_window_is_obscured = 0x1
236-} MirMotionFlag;
237-
238-typedef enum {
239- mir_motion_button_primary = 1 << 0,
240- mir_motion_button_secondary = 1 << 1,
241- mir_motion_button_tertiary = 1 << 2,
242- mir_motion_button_back = 1 << 3,
243- mir_motion_button_forward = 1 << 4
244-} MirMotionButton;
245-
246-typedef enum {
247- mir_motion_tool_type_unknown = 0,
248- mir_motion_tool_type_finger = 1,
249- mir_motion_tool_type_stylus = 2,
250- mir_motion_tool_type_mouse = 3,
251- mir_motion_tool_type_eraser = 4
252-} MirMotionToolType;
253-
254-// DEPRECATED
255-// Direct access to MirKeyEvent is deprecated. Please use mir_event_get_input_event
256-// and the mir_input_event* family of functions.
257-typedef struct
258-{
259- MirEventType type;
260-
261- int32_t device_id;
262- int32_t source_id;
263- MirKeyAction action;
264- MirKeyFlag flags;
265- unsigned int modifiers;
266-
267- int32_t key_code;
268- int32_t scan_code;
269- int32_t repeat_count;
270- nsecs_t down_time;
271-
272- nsecs_t event_time;
273- int is_system_key;
274-} MirKeyEvent;
275-
276-typedef struct
277-{
278- int id;
279- float x, raw_x;
280- float y, raw_y;
281- float touch_major;
282- float touch_minor;
283- float size;
284- float pressure;
285- float orientation;
286- float vscroll;
287- float hscroll;
288- MirMotionToolType tool_type;
289- int unused1;
290- int unused2;
291- int unused3;
292-} MirMotionPointer;
293-
294-// DEPRECATED
295-// Direct access to MirMotionEvent is deprecated. Please use mir_event_get_input_event
296-// and the mir_input_event* family of functions.
297-typedef struct
298-{
299- MirEventType type;
300-
301- int32_t device_id;
302- int32_t source_id;
303- /*
304- * TODO(racarr): We would like to store this as a MirMotionAction but the android input stack
305- * encodes some non enumerable values in it. It's convenient to keep things
306- * this way for now until we can drop SF/Hybris support in QtUbuntu.
307- */
308- int action;
309- MirMotionFlag flags;
310- unsigned int modifiers;
311-
312- int32_t edge_flags;
313- MirMotionButton button_state;
314- float x_offset;
315- float y_offset;
316- float x_precision;
317- float y_precision;
318- nsecs_t down_time;
319- nsecs_t event_time;
320-
321- size_t pointer_count;
322- MirMotionPointer pointer_coordinates[MIR_INPUT_EVENT_MAX_POINTER_COUNT];
323- /* "_coordinates" is a misnomer here because there's plenty more info than
324- just coordinates, but renaming it accurately would be an API break */
325-
326- int unused0;
327- int unused1;
328- int unused2;
329- int unused3;
330-} MirMotionEvent;
331-
332-typedef struct
333-{
334- MirEventType type;
335-
336- int id;
337- MirSurfaceAttrib attrib;
338- int value;
339-} MirSurfaceEvent;
340-
341-typedef struct
342-{
343- MirEventType type;
344-
345- int surface_id;
346- int width;
347- int height;
348-} MirResizeEvent;
349-
350-typedef struct
351-{
352- MirEventType type;
353-
354- MirPromptSessionState new_state;
355-} MirPromptSessionEvent;
356-
357-typedef struct MirOrientationEvent
358-{
359- MirEventType type;
360-
361- int surface_id;
362- MirOrientation direction;
363-} MirOrientationEvent;
364-
365-typedef struct MirCloseSurfaceEvent
366-{
367- MirEventType type;
368-
369- int surface_id;
370-} MirCloseSurfaceEvent;
371-
372-typedef union
373-{
374- // Direct access to the type member is deprecated. Instead use mir_event_get_type.
375- MirEventType type;
376- MirKeyEvent key;
377- MirMotionEvent motion;
378- MirSurfaceEvent surface;
379- MirResizeEvent resize;
380- MirPromptSessionEvent prompt_session;
381- MirOrientationEvent orientation;
382- MirCloseSurfaceEvent close_surface;
383-} MirEvent;
384+typedef struct MirSurfaceEvent MirSurfaceEvent;
385+typedef struct MirResizeEvent MirResizeEvent;
386+typedef struct MirPromptSessionEvent MirPromptSessionEvent;
387+typedef struct MirOrientationEvent MirOrientationEvent;
388+typedef struct MirCloseSurfaceEvent MirCloseSurfaceEvent;
389+typedef struct MirInputEvent MirInputEvent;
390+
391+typedef union MirEvent MirEvent;
392+
393+#ifdef __cplusplus
394+}
395+/**@}*/
396+#endif
397+
398+#include "mir_toolkit/events/event_deprecated.h"
399+
400+#ifdef __cplusplus
401+/**
402+ * \addtogroup mir_toolkit
403+ * @{
404+ */
405+extern "C" {
406+#endif
407
408 /*
409 * Retrieves the type of a MirEvent. Now preferred over direct access to ev->type.
410@@ -265,6 +79,66 @@
411 */
412 MirEventType mir_event_get_type(MirEvent const* ev);
413
414+/*
415+ * Retrieve the MirInputEvent associated with a MirEvent of
416+ * type mir_event_type_input. See <mir_toolkit/events/input/input_event.h>
417+ * for accessors.
418+ *
419+ * \param [in] event The event
420+ * \return The associated MirInputEvent
421+ */
422+MirInputEvent const* mir_event_get_input_event(MirEvent const* ev);
423+
424+/*
425+ * Retrieve the MirSurfaceEvent associated with a MirEvent of
426+ * type mir_event_type_surface. See <mir_toolkit/events/surface_event.h>
427+ * for accessors.
428+ *
429+ * \param [in] event The event
430+ * \return The associated MirSurfaceEvent
431+ */
432+MirSurfaceEvent const* mir_event_get_surface_event(MirEvent const* ev);
433+
434+/*
435+ * Retrieve the MirResizeEvent associated with a MirEvent of
436+ * type mir_event_type_resize. See <mir_toolkits/events/resize_event.h>
437+ * for accessors.
438+ *
439+ * \param [in] event The event
440+ * \return The associated MirResizeEvent
441+ */
442+MirResizeEvent const* mir_event_get_resize_event(MirEvent const* ev);
443+
444+/*
445+ * Retrieve the MirPromptSessionEvent associated with a MirEvent of
446+ * type mir_event_type_prompt_session_state_change. See <mir_toolkits/events/prompt_session_event.h>
447+ * for accessors.
448+ *
449+ * \param [in] event The event
450+ * \return The associated MirPromptSessionEvent
451+ */
452+MirPromptSessionEvent const* mir_event_get_prompt_session_event(MirEvent const* ev);
453+
454+/*
455+ * Retrieve the MirOrientationEvent associated with a MirEvent of
456+ * type mir_event_type_orientation. See <mir_toolkit/events/orientation_event.h>
457+ * for accessors.
458+ *
459+ * \param [in] event The event
460+ * \return The associated MirOrientationEvent
461+ */
462+MirOrientationEvent const* mir_event_get_orientation_event(MirEvent const* ev);
463+
464+/*
465+ * Retrieve the MirCloseSurfaceEvent associated with a MirEvent of
466+ * type mir_event_type_close_surface. See <mir_toolkit/events/close_surface_event.h>
467+ * for accessors.
468+ *
469+ * \param [in] event The event
470+ * \return The associated MirCloseSurfaceEvent
471+ */
472+MirCloseSurfaceEvent const* mir_event_get_close_surface_event(MirEvent const* ev);
473+
474 #ifdef __cplusplus
475 }
476 /**@}*/
477
478=== added file 'include/common/mir_toolkit/events/event_deprecated.h'
479--- include/common/mir_toolkit/events/event_deprecated.h 1970-01-01 00:00:00 +0000
480+++ include/common/mir_toolkit/events/event_deprecated.h 2014-12-19 16:55:48 +0000
481@@ -0,0 +1,255 @@
482+/*
483+ * Copyright © 2013 Canonical Ltd.
484+ *
485+ * This program is free software: you can redistribute it and/or modify it
486+ * under the terms of the GNU Lesser General Public License version 3,
487+ * as published by the Free Software Foundation.
488+ *
489+ * This program is distributed in the hope that it will be useful,
490+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
491+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
492+ * GNU Lesser General Public License for more details.
493+ *
494+ * You should have received a copy of the GNU Lesser General Public License
495+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
496+ *
497+ * Authored by: Thomas Voss <thomas.voss@canonical.com>
498+ */
499+
500+// ==================================
501+//
502+// Direct access to MirEvent deprecated. Prefer mir_event_* family of functions.
503+//
504+// ==================================
505+
506+#ifndef MIR_TOOLKIT_EVENT_DEPRECATED_H_
507+#define MIR_TOOLKIT_EVENT_DEPRECATED_H_
508+
509+#include <stddef.h>
510+#include <stdint.h>
511+#include "mir_toolkit/common.h"
512+
513+#ifdef __cplusplus
514+/**
515+ * \addtogroup mir_toolkit
516+ * @{
517+ */
518+extern "C" {
519+#endif
520+/* TODO: To the moon. */
521+#define MIR_INPUT_EVENT_MAX_POINTER_COUNT 16
522+
523+typedef int64_t nsecs_t;
524+
525+typedef enum {
526+ mir_key_action_down = 0,
527+ mir_key_action_up = 1,
528+ mir_key_action_multiple = 2
529+} MirKeyAction;
530+
531+typedef enum {
532+ mir_key_flag_woke_here = 0x1,
533+ mir_key_flag_soft_keyboard = 0x2,
534+ mir_key_flag_keep_touch_mode = 0x4,
535+ mir_key_flag_from_system = 0x8,
536+ mir_key_flag_editor_action = 0x10,
537+ mir_key_flag_canceled = 0x20,
538+ mir_key_flag_virtual_hard_key = 0x40,
539+ mir_key_flag_long_press = 0x80,
540+ mir_key_flag_canceled_long_press = 0x100,
541+ mir_key_flag_tracking = 0x200,
542+ mir_key_flag_fallback = 0x400
543+} MirKeyFlag;
544+
545+typedef enum {
546+ mir_key_modifier_none = 0,
547+ mir_key_modifier_alt = 0x02,
548+ mir_key_modifier_alt_left = 0x10,
549+ mir_key_modifier_alt_right = 0x20,
550+ mir_key_modifier_shift = 0x01,
551+ mir_key_modifier_shift_left = 0x40,
552+ mir_key_modifier_shift_right = 0x80,
553+ mir_key_modifier_sym = 0x04,
554+ mir_key_modifier_function = 0x08,
555+ mir_key_modifier_ctrl = 0x1000,
556+ mir_key_modifier_ctrl_left = 0x2000,
557+ mir_key_modifier_ctrl_right = 0x4000,
558+ mir_key_modifier_meta = 0x10000,
559+ mir_key_modifier_meta_left = 0x20000,
560+ mir_key_modifier_meta_right = 0x40000,
561+ mir_key_modifier_caps_lock = 0x100000,
562+ mir_key_modifier_num_lock = 0x200000,
563+ mir_key_modifier_scroll_lock = 0x400000
564+} MirKeyModifier;
565+
566+typedef enum {
567+ mir_motion_action_down = 0,
568+ mir_motion_action_up = 1,
569+ mir_motion_action_move = 2,
570+ mir_motion_action_cancel = 3,
571+ mir_motion_action_outside = 4,
572+ mir_motion_action_pointer_down = 5,
573+ mir_motion_action_pointer_up = 6,
574+ mir_motion_action_hover_move = 7,
575+ mir_motion_action_scroll = 8,
576+ mir_motion_action_hover_enter = 9,
577+ mir_motion_action_hover_exit = 10
578+} MirMotionAction;
579+
580+typedef enum {
581+ mir_motion_flag_window_is_obscured = 0x1
582+} MirMotionFlag;
583+
584+typedef enum {
585+ mir_motion_button_primary = 1 << 0,
586+ mir_motion_button_secondary = 1 << 1,
587+ mir_motion_button_tertiary = 1 << 2,
588+ mir_motion_button_back = 1 << 3,
589+ mir_motion_button_forward = 1 << 4
590+} MirMotionButton;
591+
592+typedef enum {
593+ mir_motion_tool_type_unknown = 0,
594+ mir_motion_tool_type_finger = 1,
595+ mir_motion_tool_type_stylus = 2,
596+ mir_motion_tool_type_mouse = 3,
597+ mir_motion_tool_type_eraser = 4
598+} MirMotionToolType;
599+
600+// DEPRECATED
601+// Direct access to MirKeyEvent is deprecated. Please use mir_event_get_input_event
602+// and the mir_input_event* family of functions.
603+typedef struct
604+{
605+ MirEventType type;
606+
607+ int32_t device_id;
608+ int32_t source_id;
609+ MirKeyAction action;
610+ MirKeyFlag flags;
611+ unsigned int modifiers;
612+
613+ int32_t key_code;
614+ int32_t scan_code;
615+ int32_t repeat_count;
616+ nsecs_t down_time;
617+
618+ nsecs_t event_time;
619+ int is_system_key;
620+} MirKeyEvent;
621+
622+typedef struct
623+{
624+ int id;
625+ float x, raw_x;
626+ float y, raw_y;
627+ float touch_major;
628+ float touch_minor;
629+ float size;
630+ float pressure;
631+ float orientation;
632+ float vscroll;
633+ float hscroll;
634+ MirMotionToolType tool_type;
635+ int unused1;
636+ int unused2;
637+ int unused3;
638+} MirMotionPointer;
639+
640+// DEPRECATED
641+// Direct access to MirMotionEvent is deprecated. Please use mir_event_get_input_event
642+// and the mir_input_event* family of functions.
643+typedef struct
644+{
645+ MirEventType type;
646+
647+ int32_t device_id;
648+ int32_t source_id;
649+ /*
650+ * TODO(racarr): We would like to store this as a MirMotionAction but the android input stack
651+ * encodes some non enumerable values in it. It's convenient to keep things
652+ * this way for now until we can drop SF/Hybris support in QtUbuntu.
653+ */
654+ int action;
655+ MirMotionFlag flags;
656+ unsigned int modifiers;
657+
658+ int32_t edge_flags;
659+ MirMotionButton button_state;
660+ float x_offset;
661+ float y_offset;
662+ float x_precision;
663+ float y_precision;
664+ nsecs_t down_time;
665+ nsecs_t event_time;
666+
667+ size_t pointer_count;
668+ MirMotionPointer pointer_coordinates[MIR_INPUT_EVENT_MAX_POINTER_COUNT];
669+ /* "_coordinates" is a misnomer here because there's plenty more info than
670+ just coordinates, but renaming it accurately would be an API break */
671+
672+ int unused0;
673+ int unused1;
674+ int unused2;
675+ int unused3;
676+} MirMotionEvent;
677+
678+struct MirSurfaceEvent
679+{
680+ MirEventType type;
681+
682+ int id;
683+ MirSurfaceAttrib attrib;
684+ int value;
685+};
686+
687+struct MirResizeEvent
688+{
689+ MirEventType type;
690+
691+ int surface_id;
692+ int width;
693+ int height;
694+};
695+
696+struct MirPromptSessionEvent
697+{
698+ MirEventType type;
699+
700+ MirPromptSessionState new_state;
701+};
702+
703+struct MirOrientationEvent
704+{
705+ MirEventType type;
706+
707+ int surface_id;
708+ MirOrientation direction;
709+};
710+
711+struct MirCloseSurfaceEvent
712+{
713+ MirEventType type;
714+
715+ int surface_id;
716+};
717+
718+union MirEvent
719+{
720+ // Direct access to the type member is deprecated. Instead use mir_event_get_type.
721+ MirEventType type;
722+ MirKeyEvent key;
723+ MirMotionEvent motion;
724+ MirSurfaceEvent surface;
725+ MirResizeEvent resize;
726+ MirPromptSessionEvent prompt_session;
727+ MirOrientationEvent orientation;
728+ MirCloseSurfaceEvent close_surface;
729+};
730+
731+#ifdef __cplusplus
732+}
733+/**@}*/
734+#endif
735+
736+#endif /* MIR_TOOLKIT_EVENT_DEPRECATED_H_ */
737
738=== renamed directory 'include/common/mir_toolkit/input' => 'include/common/mir_toolkit/events/input'
739=== modified file 'include/common/mir_toolkit/events/input/input_event.h'
740--- include/common/mir_toolkit/input/input_event.h 2014-12-01 20:04:41 +0000
741+++ include/common/mir_toolkit/events/input/input_event.h 2014-12-19 16:55:48 +0000
742@@ -19,9 +19,7 @@
743 #ifndef MIR_TOOLKIT_INPUT_EVENT_H_
744 #define MIR_TOOLKIT_INPUT_EVENT_H_
745
746-#include "mir_toolkit/event.h"
747-#include "mir_toolkit/input/key_input_event.h"
748-#include "mir_toolkit/input/touch_input_event.h"
749+#include "mir_toolkit/events/event.h"
750
751 #include <stdint.h>
752
753@@ -33,8 +31,6 @@
754 extern "C" {
755 #endif
756
757-typedef struct MirInputEvent MirInputEvent;
758-
759 typedef int64_t MirInputDeviceId;
760
761 typedef enum {
762@@ -42,14 +38,45 @@
763 mir_input_event_type_touch = 1
764 } MirInputEventType;
765
766-/*
767- * Retrieve the MirInputEvent associated with a MirEvent of
768- * type mir_event_type_input.
769- *
770- * \param [in] event The event
771- * \return The associated MirInputEvent
772- */
773-MirInputEvent const* mir_event_get_input_event(MirEvent const* ev);
774+/**
775+ * Description of key modifier state.
776+ */
777+typedef enum {
778+ mir_input_event_modifier_none = 1 << 0,
779+ mir_input_event_modifier_alt = 1 << 1,
780+ mir_input_event_modifier_alt_left = 1 << 2,
781+ mir_input_event_modifier_alt_right = 1 << 3,
782+ mir_input_event_modifier_shift = 1 << 4,
783+ mir_input_event_modifier_shift_left = 1 << 5,
784+ mir_input_event_modifier_shift_right = 1 << 6,
785+ mir_input_event_modifier_sym = 1 << 7,
786+ mir_input_event_modifier_function = 1 << 8,
787+ mir_input_event_modifier_ctrl = 1 << 9,
788+ mir_input_event_modifier_ctrl_left = 1 << 10,
789+ mir_input_event_modifier_ctrl_right = 1 << 11,
790+ mir_input_event_modifier_meta = 1 << 12,
791+ mir_input_event_modifier_meta_left = 1 << 13,
792+ mir_input_event_modifier_meta_right = 1 << 14,
793+ mir_input_event_modifier_caps_lock = 1 << 15,
794+ mir_input_event_modifier_num_lock = 1 << 16,
795+ mir_input_event_modifier_scroll_lock = 1 << 17
796+} MirInputEventModifiers;
797+
798+#ifdef __cplusplus
799+}
800+/**@}*/
801+#endif
802+
803+#include "mir_toolkit/events/input/touch_input_event.h"
804+#include "mir_toolkit/events/input/key_input_event.h"
805+
806+#ifdef __cplusplus
807+/**
808+ * \addtogroup mir_toolkit
809+ * @{
810+ */
811+extern "C" {
812+#endif
813
814 /*
815 * Retrieves the device id responsible for generating an input event.
816
817=== modified file 'include/common/mir_toolkit/events/input/key_input_event.h'
818--- include/common/mir_toolkit/input/key_input_event.h 2014-12-01 17:00:22 +0000
819+++ include/common/mir_toolkit/events/input/key_input_event.h 2014-12-19 16:55:48 +0000
820@@ -48,30 +48,6 @@
821 } MirKeyInputEventAction;
822
823 /**
824- * Description of key modifier state.
825- */
826-typedef enum {
827- mir_key_input_event_modifier_none = 1 << 0,
828- mir_key_input_event_modifier_alt = 1 << 1,
829- mir_key_input_event_modifier_alt_left = 1 << 2,
830- mir_key_input_event_modifier_alt_right = 1 << 3,
831- mir_key_input_event_modifier_shift = 1 << 4,
832- mir_key_input_event_modifier_shift_left = 1 << 5,
833- mir_key_input_event_modifier_shift_right = 1 << 6,
834- mir_key_input_event_modifier_sym = 1 << 7,
835- mir_key_input_event_modifier_function = 1 << 8,
836- mir_key_input_event_modifier_ctrl = 1 << 9,
837- mir_key_input_event_modifier_ctrl_left = 1 << 10,
838- mir_key_input_event_modifier_ctrl_right = 1 << 11,
839- mir_key_input_event_modifier_meta = 1 << 12,
840- mir_key_input_event_modifier_meta_left = 1 << 13,
841- mir_key_input_event_modifier_meta_right = 1 << 14,
842- mir_key_input_event_modifier_caps_lock = 1 << 15,
843- mir_key_input_event_modifier_num_lock = 1 << 16,
844- mir_key_input_event_modifier_scroll_lock = 1 << 17
845-} MirKeyInputEventModifiers;
846-
847-/**
848 * Retrieve the action which triggered a given key event.
849 *
850 * \param [in] event The key event
851@@ -103,7 +79,7 @@
852 * \param [in] event The key event
853 * \return The modifier mask
854 */
855-MirKeyInputEventModifiers mir_key_input_event_get_modifiers(MirKeyInputEvent const* event);
856+MirInputEventModifiers mir_key_input_event_get_modifiers(MirKeyInputEvent const* event);
857
858 #ifdef __cplusplus
859 }
860
861=== modified file 'include/common/mir_toolkit/events/input/touch_input_event.h'
862--- include/common/mir_toolkit/input/touch_input_event.h 2014-11-25 23:00:05 +0000
863+++ include/common/mir_toolkit/events/input/touch_input_event.h 2014-12-19 16:55:48 +0000
864@@ -85,6 +85,14 @@
865 } MirTouchInputEventTouchTooltype;
866
867 /**
868+ * Retrieve the modifier keys pressed when the touch action occured.
869+ *
870+ * \param [in] event The key event
871+ * \return The modifier mask
872+ */
873+MirInputEventModifiers mir_touch_input_event_get_modifiers(MirTouchInputEvent const* event);
874+
875+/**
876 * Retrieve the number of touches reported for a given touch event. Each touch
877 * is said to be index in the event and may be accessed by index 0, 1, ... , (touch_count - 1)
878 *
879
880=== added file 'include/common/mir_toolkit/events/orientation_event.h'
881--- include/common/mir_toolkit/events/orientation_event.h 1970-01-01 00:00:00 +0000
882+++ include/common/mir_toolkit/events/orientation_event.h 2014-12-19 16:55:48 +0000
883@@ -0,0 +1,45 @@
884+/*
885+ * Copyright © 2014 Canonical Ltd.
886+ *
887+ * This program is free software: you can redistribute it and/or modify it
888+ * under the terms of the GNU Lesser General Public License version 3,
889+ * as published by the Free Software Foundation.
890+ *
891+ * This program is distributed in the hope that it will be useful,
892+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
893+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
894+ * GNU Lesser General Public License for more details.
895+ *
896+ * You should have received a copy of the GNU Lesser General Public License
897+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
898+ *
899+ * Authored by: Robert Carr <robert.carr@canonical.com>
900+ */
901+
902+#ifndef MIR_TOOLKIT_EVENTS_ORIENTATION_EVENT_H_
903+#define MIR_TOOLKIT_EVENTS_ORIENTATION_EVENT_H_
904+
905+#include <mir_toolkit/events/event.h>
906+
907+#ifdef __cplusplus
908+/**
909+ * \addtogroup mir_toolkit
910+ * @{
911+ */
912+extern "C" {
913+#endif
914+
915+/*
916+ * Retrieve the new orientation reported by this MirOrientationEvent
917+ *
918+ * \param[in] ev The orientation event
919+ * \return The new orientation
920+ */
921+MirOrientation mir_orientation_event_get_direction(MirOrientationEvent const* ev);
922+
923+#ifdef __cplusplus
924+}
925+/**@}*/
926+#endif
927+
928+#endif /* MIR_TOOLKIT_ORIENTATION_EVENT_H_ */
929
930=== added file 'include/common/mir_toolkit/events/prompt_session_event.h'
931--- include/common/mir_toolkit/events/prompt_session_event.h 1970-01-01 00:00:00 +0000
932+++ include/common/mir_toolkit/events/prompt_session_event.h 2014-12-19 16:55:48 +0000
933@@ -0,0 +1,45 @@
934+/*
935+ * Copyright © 2014 Canonical Ltd.
936+ *
937+ * This program is free software: you can redistribute it and/or modify it
938+ * under the terms of the GNU Lesser General Public License version 3,
939+ * as published by the Free Software Foundation.
940+ *
941+ * This program is distributed in the hope that it will be useful,
942+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
943+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
944+ * GNU Lesser General Public License for more details.
945+ *
946+ * You should have received a copy of the GNU Lesser General Public License
947+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
948+ *
949+ * Authored by: Robert Carr <robert.carr@canonical.com>
950+ */
951+
952+#ifndef MIR_TOOLKIT_EVENTS_PROMPT_SESSION_EVENT_H_
953+#define MIR_TOOLKIT_EVENTS_PROMPT_SESSION_EVENT_H_
954+
955+#include <mir_toolkit/events/event.h>
956+
957+#ifdef __cplusplus
958+/**
959+ * \addtogroup mir_toolkit
960+ * @{
961+ */
962+extern "C" {
963+#endif
964+
965+/*
966+ * Retrieve the new prompt session state reported by a given MirPromptSessionEvent
967+ *
968+ * \param [in] event The prompt session event
969+ * \return The new state
970+ */
971+MirPromptSessionState mir_prompt_session_event_get_state(MirPromptSessionEvent const* ev);
972+
973+#ifdef __cplusplus
974+}
975+/**@}*/
976+#endif
977+
978+#endif /* MIR_TOOLKIT_PROMPT_SESSION_EVENT_H_ */
979
980=== added file 'include/common/mir_toolkit/events/resize_event.h'
981--- include/common/mir_toolkit/events/resize_event.h 1970-01-01 00:00:00 +0000
982+++ include/common/mir_toolkit/events/resize_event.h 2014-12-19 16:55:48 +0000
983@@ -0,0 +1,53 @@
984+/*
985+ * Copyright © 2014 Canonical Ltd.
986+ *
987+ * This program is free software: you can redistribute it and/or modify it
988+ * under the terms of the GNU Lesser General Public License version 3,
989+ * as published by the Free Software Foundation.
990+ *
991+ * This program is distributed in the hope that it will be useful,
992+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
993+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
994+ * GNU Lesser General Public License for more details.
995+ *
996+ * You should have received a copy of the GNU Lesser General Public License
997+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
998+ *
999+ * Authored by: Robert Carr <robert.carr@canonical.com>
1000+ */
1001+
1002+#ifndef MIR_TOOLKIT_EVENTS_RESIZE_EVENT_H_
1003+#define MIR_TOOLKIT_EVENTS_RESIZE_EVENT_H_
1004+
1005+#include <mir_toolkit/events/event.h>
1006+
1007+#ifdef __cplusplus
1008+/**
1009+ * \addtogroup mir_toolkit
1010+ * @{
1011+ */
1012+extern "C" {
1013+#endif
1014+
1015+/*
1016+ * Retrieve the new width reported by a given MirResizeEvent
1017+ *
1018+ * \param[in] ev The resize event
1019+ * \return The reported width
1020+ */
1021+int mir_resize_event_get_width(MirResizeEvent const* ev);
1022+
1023+/*
1024+ * Retrieve the new height reported by a given MirResizeEvent
1025+ *
1026+ * \param[in] ev The resize event
1027+ * \return The reported height
1028+ */
1029+int mir_resize_event_get_height(MirResizeEvent const* ev);
1030+
1031+#ifdef __cplusplus
1032+}
1033+/**@}*/
1034+#endif
1035+
1036+#endif /* MIR_TOOLKIT_RESIZE_EVENT_H_ */
1037
1038=== added file 'include/common/mir_toolkit/events/surface_event.h'
1039--- include/common/mir_toolkit/events/surface_event.h 1970-01-01 00:00:00 +0000
1040+++ include/common/mir_toolkit/events/surface_event.h 2014-12-19 16:55:48 +0000
1041@@ -0,0 +1,53 @@
1042+/*
1043+ * Copyright © 2014 Canonical Ltd.
1044+ *
1045+ * This program is free software: you can redistribute it and/or modify it
1046+ * under the terms of the GNU Lesser General Public License version 3,
1047+ * as published by the Free Software Foundation.
1048+ *
1049+ * This program is distributed in the hope that it will be useful,
1050+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1051+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1052+ * GNU Lesser General Public License for more details.
1053+ *
1054+ * You should have received a copy of the GNU Lesser General Public License
1055+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1056+ *
1057+ * Authored by: Robert Carr <robert.carr@canonical.com>
1058+ */
1059+
1060+#ifndef MIR_TOOLKIT_EVENTS_SURFACE_EVENT_H_
1061+#define MIR_TOOLKIT_EVENTS_SURFACE_EVENT_H_
1062+
1063+#include <mir_toolkit/events/event.h>
1064+
1065+#ifdef __cplusplus
1066+/**
1067+ * \addtogroup mir_toolkit
1068+ * @{
1069+ */
1070+extern "C" {
1071+#endif
1072+
1073+/*
1074+ * Retrieve the attribute index configured with a given MirSurfaceEvent
1075+ *
1076+ * \param [in] Event The event
1077+ * \return The associated attribute
1078+ */
1079+MirSurfaceAttrib mir_surface_event_get_attribute(MirSurfaceEvent const* ev);
1080+
1081+/*
1082+ * Retrieve the new value of the associated attribute for a given MirSurfaceEvent
1083+ *
1084+ * \param [in] Event The event
1085+ * \return The associated attribute value
1086+ */
1087+int mir_surface_event_get_attribute_value(MirSurfaceEvent const* ev);
1088+
1089+#ifdef __cplusplus
1090+}
1091+/**@}*/
1092+#endif
1093+
1094+#endif /* MIR_TOOLKIT_SURFACE_EVENT_H_ */
1095
1096=== modified file 'platform-ABI-sha1sums'
1097--- platform-ABI-sha1sums 2014-12-19 15:31:01 +0000
1098+++ platform-ABI-sha1sums 2014-12-19 16:55:48 +0000
1099@@ -13,16 +13,22 @@
1100 208cd6aed5ef5f8f39b3eb86604e4133cb840485 include/common/mir/input/input_receiver_thread.h
1101 be7d58c9fde2ce91cc66dd6144b76e08b536266b include/common/mir/int_wrapper.h
1102 2de47e2790d0f7643e23eada2d8aa2987f58d086 include/common/mir/logging/logger.h
1103-5ab81600183fdaca3fb949beb2307d1f6e4cbb61 include/common/mir/log.h
1104+38f159ee67cf380ebd2bfee7a98d62bc0397c631 include/common/mir/log.h
1105 31b9c24e2ce7194aeea6694e81c160354033d28a include/common/mir/optional_value.h
1106 9ae8473df05dd9e048a73797f01a2f34f7447554 include/common/mir/time/types.h
1107-23a009b06de7bac17d33d988dc8d968be8bc094a include/common/mir_toolkit/client_types.h
1108+3350dac884d6006753de2a955bc7a05663cd9449 include/common/mir_toolkit/client_types.h
1109 c7c708734715a6d1b6fb2652584adb912071a518 include/common/mir_toolkit/common.h
1110 fce4c1a9e0d037244f7e9e96ea2d8eaab4fc404c include/common/mir_toolkit/cursors.h
1111-d71dddf6c4275ee423d3e0fa204e3b77b4d87401 include/common/mir_toolkit/event.h
1112-49403c824f69fa1cc1f58bf5fe635639148765eb include/common/mir_toolkit/input/input_event.h
1113-f531c6a49883884a6c694393d5614f9942fe2703 include/common/mir_toolkit/input/key_input_event.h
1114-fd6d86becfa5ffa367480fd2654180f6ffcbf059 include/common/mir_toolkit/input/touch_input_event.h
1115+f4d39e9893ce6308bddd83a49b90f0051f565323 include/common/mir_toolkit/event.h
1116+2507f2929415aa423f9551d3c595c439fe1c6efd include/common/mir_toolkit/events/event_deprecated.h
1117+ae75a0434588f2d086936e2a2dbe1e919a5fbc50 include/common/mir_toolkit/events/event.h
1118+c591a02a8e9851db342c310cf829d018a1eddb51 include/common/mir_toolkit/events/input/input_event.h
1119+7748a12138474e9be218eeb8f14b372af0fcec7e include/common/mir_toolkit/events/input/key_input_event.h
1120+de7c23453e6d897296f32e49d9ba952a1baa0200 include/common/mir_toolkit/events/input/touch_input_event.h
1121+8642e85a50e2de651589da3ced70e0fc0a915f26 include/common/mir_toolkit/events/orientation_event.h
1122+f623dcf3c2ed134c1be20106eb54bcccc84af462 include/common/mir_toolkit/events/prompt_session_event.h
1123+633893b0def2b71f969872908a5b3529bc2fbf10 include/common/mir_toolkit/events/resize_event.h
1124+5944dc0556223cc54b45b32c8aa70b8c60ee0337 include/common/mir_toolkit/events/surface_event.h
1125 4975998aa1056ed0d39dcc538127453e516ad8e9 include/common/mir_toolkit/mesa/native_display.h
1126 101017c17714a57db57d79b7b5e7df40a3568236 include/common/mir_toolkit/mir_native_buffer.h
1127 4ce105a3a18241f5d33db31939ca15256f353c37 include/common/mir_toolkit/mir_version_number.h
1128
1129=== modified file 'server-ABI-sha1sums'
1130--- server-ABI-sha1sums 2014-12-19 15:31:01 +0000
1131+++ server-ABI-sha1sums 2014-12-19 16:55:48 +0000
1132@@ -13,16 +13,22 @@
1133 208cd6aed5ef5f8f39b3eb86604e4133cb840485 include/common/mir/input/input_receiver_thread.h
1134 be7d58c9fde2ce91cc66dd6144b76e08b536266b include/common/mir/int_wrapper.h
1135 2de47e2790d0f7643e23eada2d8aa2987f58d086 include/common/mir/logging/logger.h
1136-5ab81600183fdaca3fb949beb2307d1f6e4cbb61 include/common/mir/log.h
1137+38f159ee67cf380ebd2bfee7a98d62bc0397c631 include/common/mir/log.h
1138 31b9c24e2ce7194aeea6694e81c160354033d28a include/common/mir/optional_value.h
1139 9ae8473df05dd9e048a73797f01a2f34f7447554 include/common/mir/time/types.h
1140-23a009b06de7bac17d33d988dc8d968be8bc094a include/common/mir_toolkit/client_types.h
1141+3350dac884d6006753de2a955bc7a05663cd9449 include/common/mir_toolkit/client_types.h
1142 c7c708734715a6d1b6fb2652584adb912071a518 include/common/mir_toolkit/common.h
1143 fce4c1a9e0d037244f7e9e96ea2d8eaab4fc404c include/common/mir_toolkit/cursors.h
1144-d71dddf6c4275ee423d3e0fa204e3b77b4d87401 include/common/mir_toolkit/event.h
1145-49403c824f69fa1cc1f58bf5fe635639148765eb include/common/mir_toolkit/input/input_event.h
1146-f531c6a49883884a6c694393d5614f9942fe2703 include/common/mir_toolkit/input/key_input_event.h
1147-fd6d86becfa5ffa367480fd2654180f6ffcbf059 include/common/mir_toolkit/input/touch_input_event.h
1148+f4d39e9893ce6308bddd83a49b90f0051f565323 include/common/mir_toolkit/event.h
1149+2507f2929415aa423f9551d3c595c439fe1c6efd include/common/mir_toolkit/events/event_deprecated.h
1150+ae75a0434588f2d086936e2a2dbe1e919a5fbc50 include/common/mir_toolkit/events/event.h
1151+c591a02a8e9851db342c310cf829d018a1eddb51 include/common/mir_toolkit/events/input/input_event.h
1152+7748a12138474e9be218eeb8f14b372af0fcec7e include/common/mir_toolkit/events/input/key_input_event.h
1153+de7c23453e6d897296f32e49d9ba952a1baa0200 include/common/mir_toolkit/events/input/touch_input_event.h
1154+8642e85a50e2de651589da3ced70e0fc0a915f26 include/common/mir_toolkit/events/orientation_event.h
1155+f623dcf3c2ed134c1be20106eb54bcccc84af462 include/common/mir_toolkit/events/prompt_session_event.h
1156+633893b0def2b71f969872908a5b3529bc2fbf10 include/common/mir_toolkit/events/resize_event.h
1157+5944dc0556223cc54b45b32c8aa70b8c60ee0337 include/common/mir_toolkit/events/surface_event.h
1158 4975998aa1056ed0d39dcc538127453e516ad8e9 include/common/mir_toolkit/mesa/native_display.h
1159 101017c17714a57db57d79b7b5e7df40a3568236 include/common/mir_toolkit/mir_native_buffer.h
1160 4ce105a3a18241f5d33db31939ca15256f353c37 include/common/mir_toolkit/mir_version_number.h
1161
1162=== modified file 'src/client/mirclient.pc.in'
1163--- src/client/mirclient.pc.in 2014-12-08 04:03:47 +0000
1164+++ src/client/mirclient.pc.in 2014-12-19 16:55:48 +0000
1165@@ -9,5 +9,5 @@
1166 Description: Mir client library
1167 Version: @MIR_VERSION@
1168 Requires.private: protobuf >= 2.4.1
1169-Libs: -L${libdir} -lmirclient
1170+Libs: -L${libdir} -lmirclient -lmircommon
1171 Cflags: -I${includedir} -I${common_includedir}
1172
1173=== modified file 'src/common/CMakeLists.txt'
1174--- src/common/CMakeLists.txt 2014-12-08 04:03:47 +0000
1175+++ src/common/CMakeLists.txt 2014-12-19 16:55:48 +0000
1176@@ -36,6 +36,10 @@
1177 MESSAGE( STATUS "MIR_COMMON_SOURCES. . . : ${MIR_COMMON_SOURCES}" )
1178 MESSAGE( STATUS "MIR_COMMON_REFERENCES . : ${MIR_COMMON_REFERENCES}" )
1179
1180+list(APPEND MIR_COMMON_SOURCES
1181+ ${CMAKE_CURRENT_SOURCE_DIR}/event.cpp
1182+)
1183+
1184 add_library(mircommon
1185 SHARED
1186 ${MIR_COMMON_SOURCES}
1187
1188=== added file 'src/common/event.cpp'
1189--- src/common/event.cpp 1970-01-01 00:00:00 +0000
1190+++ src/common/event.cpp 2014-12-19 16:55:48 +0000
1191@@ -0,0 +1,179 @@
1192+/*
1193+ * Copyright © 2014 Canonical Ltd.
1194+ *
1195+ * This program is free software: you can redistribute it and/or modify it
1196+ * under the terms of the GNU Lesser General Public License version 3,
1197+ * as published by the Free Software Foundation.
1198+ *
1199+ * This program is distributed in the hope that it will be useful,
1200+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1201+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1202+ * GNU Lesser General Public License for more details.
1203+ *
1204+ * You should have received a copy of the GNU Lesser General Public License
1205+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1206+ *
1207+ * Authored by: Robert Carr <robert.carr@canonical.com>
1208+ */
1209+
1210+#define MIR_LOG_COMPONENT "event-access"
1211+
1212+#include "mir/event_type_to_string.h"
1213+#include "mir/log.h"
1214+
1215+#include "mir_toolkit/events/event.h"
1216+#include "mir_toolkit/events/event_deprecated.h"
1217+
1218+#include "mir_toolkit/events/surface_event.h"
1219+#include "mir_toolkit/events/resize_event.h"
1220+#include "mir_toolkit/events/prompt_session_event.h"
1221+#include "mir_toolkit/events/orientation_event.h"
1222+
1223+#include <stdlib.h>
1224+
1225+namespace ml = mir::logging;
1226+
1227+namespace
1228+{
1229+template <typename EventType>
1230+void expect_event_type(EventType const* ev, MirEventType t)
1231+{
1232+ if (ev->type != t)
1233+ {
1234+ mir::log_critical("Expected " + mir::event_type_to_string(t) + " but event is of type " +
1235+ mir::event_type_to_string(ev->type));
1236+ abort();
1237+ }
1238+}
1239+}
1240+
1241+std::string mir::event_type_to_string(MirEventType t)
1242+{
1243+ switch (t)
1244+ {
1245+ case mir_event_type_key:
1246+ return "mir_event_type_key";
1247+ case mir_event_type_motion:
1248+ return "mir_event_type_motion";
1249+ case mir_event_type_surface:
1250+ return "mir_event_type_surface";
1251+ case mir_event_type_resize:
1252+ return "mir_event_type_resize";
1253+ case mir_event_type_prompt_session_state_change:
1254+ return "mir_event_type_prompt_session_state_change";
1255+ case mir_event_type_orientation:
1256+ return "mir_event_type_orientation";
1257+ case mir_event_type_close_surface:
1258+ return "mir_event_type_close_surface";
1259+ case mir_event_type_input:
1260+ return "mir_event_type_input";
1261+ default:
1262+ abort();
1263+ }
1264+}
1265+
1266+
1267+MirEventType mir_event_get_type(MirEvent const* ev)
1268+{
1269+ switch (ev->type)
1270+ {
1271+ case mir_event_type_key:
1272+ case mir_event_type_motion:
1273+ return mir_event_type_input;
1274+ default:
1275+ return ev->type;
1276+ }
1277+}
1278+
1279+MirInputEvent const* mir_event_get_input_event(MirEvent const* ev)
1280+{
1281+ if (ev->type != mir_event_type_key && ev->type != mir_event_type_motion)
1282+ {
1283+ mir::log_critical("Expected input event but event is of type " +
1284+ mir::event_type_to_string(ev->type));
1285+ abort();
1286+ }
1287+
1288+ return reinterpret_cast<MirInputEvent const*>(ev);
1289+}
1290+
1291+MirSurfaceEvent const* mir_event_get_surface_event(MirEvent const* ev)
1292+{
1293+ expect_event_type(ev, mir_event_type_surface);
1294+
1295+ return &ev->surface;
1296+}
1297+
1298+MirResizeEvent const* mir_event_get_resize_event(MirEvent const* ev)
1299+{
1300+ expect_event_type(ev, mir_event_type_resize);
1301+
1302+ return &ev->resize;
1303+}
1304+
1305+MirPromptSessionEvent const* mir_event_get_prompt_session_event(MirEvent const* ev)
1306+{
1307+ expect_event_type(ev, mir_event_type_prompt_session_state_change);
1308+
1309+ return &ev->prompt_session;
1310+}
1311+
1312+MirOrientationEvent const* mir_event_get_orientation_event(MirEvent const* ev)
1313+{
1314+ expect_event_type(ev, mir_event_type_orientation);
1315+
1316+ return &ev->orientation;
1317+}
1318+
1319+MirCloseSurfaceEvent const* mir_event_get_close_surface_event(MirEvent const* ev)
1320+{
1321+ expect_event_type(ev, mir_event_type_close_surface);
1322+
1323+ return &ev->close_surface;
1324+}
1325+
1326+/* Surface event accessors */
1327+
1328+MirSurfaceAttrib mir_surface_event_get_attribute(MirSurfaceEvent const* ev)
1329+{
1330+ expect_event_type(ev, mir_event_type_surface);
1331+
1332+ return ev->attrib;
1333+}
1334+
1335+int mir_surface_event_get_attribute_value(MirSurfaceEvent const* ev)
1336+{
1337+ expect_event_type(ev, mir_event_type_surface);
1338+
1339+ return ev->value;
1340+}
1341+
1342+/* Resize event accessors */
1343+
1344+int mir_resize_event_get_width(MirResizeEvent const* ev)
1345+{
1346+ expect_event_type(ev, mir_event_type_resize);
1347+ return ev->width;
1348+}
1349+
1350+int mir_resize_event_get_height(MirResizeEvent const* ev)
1351+{
1352+ expect_event_type(ev, mir_event_type_resize);
1353+ return ev->height;
1354+}
1355+
1356+/* Prompt session event accessors */
1357+
1358+MirPromptSessionState mir_prompt_session_event_get_state(MirPromptSessionEvent const* ev)
1359+{
1360+ expect_event_type(ev, mir_event_type_prompt_session_state_change);
1361+ return ev->new_state;
1362+}
1363+
1364+/* Orientation event accessors */
1365+
1366+MirOrientation mir_orientation_event_get_direction(MirOrientationEvent const* ev)
1367+{
1368+ expect_event_type(ev, mir_event_type_orientation);
1369+ return ev->direction;
1370+}
1371
1372=== modified file 'src/common/input/input_event.cpp'
1373--- src/common/input/input_event.cpp 2014-12-01 17:00:22 +0000
1374+++ src/common/input/input_event.cpp 2014-12-19 16:55:48 +0000
1375@@ -16,7 +16,12 @@
1376 * Authored by: Robert Carr <robert.carr@canonical.com>
1377 */
1378
1379-#include "mir_toolkit/input/input_event.h"
1380+#define MIR_LOGGING_COMPONENT "input-event-access"
1381+
1382+#include "mir/event_type_to_string.h"
1383+#include "mir/log.h"
1384+
1385+#include "mir_toolkit/events/input/input_event.h"
1386
1387 #include <assert.h>
1388 #include <stdlib.h>
1389@@ -26,8 +31,33 @@
1390 #define MIR_EVENT_ACTION_POINTER_INDEX_MASK 0xff00
1391 #define MIR_EVENT_ACTION_POINTER_INDEX_SHIFT 8;
1392
1393+namespace ml = mir::logging;
1394+
1395 namespace
1396 {
1397+void expect_old_event_type(MirEvent const* ev, MirEventType t)
1398+{
1399+ if (ev->type != t)
1400+ {
1401+ mir::log_critical("Expected " + mir::event_type_to_string(t) + " but event is of type " +
1402+ mir::event_type_to_string(ev->type));
1403+ abort();
1404+ }
1405+}
1406+
1407+std::string input_event_type_to_string(MirInputEventType input_event_type)
1408+{
1409+ switch (input_event_type)
1410+ {
1411+ case mir_input_event_type_key:
1412+ return "mir_input_event_type_key";
1413+ case mir_input_event_type_touch:
1414+ return "mir_input_event_type_touch";
1415+ default:
1416+ abort();
1417+ }
1418+}
1419+
1420 MirEvent const* old_ev_from_new(MirInputEvent const* ev)
1421 {
1422 return reinterpret_cast<MirEvent const*>(ev);
1423@@ -35,43 +65,26 @@
1424 MirKeyEvent const& old_kev_from_new(MirKeyInputEvent const* ev)
1425 {
1426 auto old_ev = reinterpret_cast<MirEvent const*>(ev);
1427- if (old_ev->type != mir_event_type_key)
1428- abort();
1429+ expect_old_event_type(old_ev, mir_event_type_key);
1430 return old_ev->key;
1431 }
1432 MirMotionEvent const& old_mev_from_new(MirTouchInputEvent const* ev)
1433 {
1434 auto old_ev = reinterpret_cast<MirEvent const*>(ev);
1435- if (old_ev->type != mir_event_type_motion)
1436- abort();
1437+ expect_old_event_type(old_ev, mir_event_type_motion);
1438 return old_ev->motion;
1439 }
1440 }
1441
1442-MirEventType mir_event_get_type(MirEvent const* ev)
1443-{
1444- switch (ev->type)
1445- {
1446- case mir_event_type_key:
1447- case mir_event_type_motion:
1448- return mir_event_type_input;
1449- default:
1450- return ev->type;
1451- }
1452-}
1453-
1454-MirInputEvent const* mir_event_get_input_event(MirEvent const* ev)
1455-{
1456- if(mir_event_get_type(ev) != mir_event_type_input)
1457- abort();
1458-
1459- return reinterpret_cast<MirInputEvent const*>(ev);
1460-}
1461-
1462 MirInputEventType mir_input_event_get_type(MirInputEvent const* ev)
1463 {
1464 auto old_ev = old_ev_from_new(ev);
1465- assert(old_ev->type == mir_event_type_key || old_ev->type == mir_event_type_motion);
1466+
1467+ if (old_ev->type != mir_event_type_key && old_ev->type != mir_event_type_motion)
1468+ {
1469+ mir::log_critical("expected input event but event was of type " + mir::event_type_to_string(old_ev->type));
1470+ abort();
1471+ }
1472
1473 switch (old_ev->type)
1474 {
1475@@ -87,7 +100,12 @@
1476 MirInputDeviceId mir_input_event_get_device_id(MirInputEvent const* ev)
1477 {
1478 auto old_ev = old_ev_from_new(ev);
1479- assert(mir_event_get_type(old_ev) == mir_event_type_input);
1480+
1481+ if(mir_event_get_type(old_ev) != mir_event_type_input)
1482+ {
1483+ mir::log_critical("expected input event but event was of type " + mir::event_type_to_string(old_ev->type));
1484+ abort();
1485+ }
1486
1487 switch (old_ev->type)
1488 {
1489@@ -103,7 +121,11 @@
1490 int64_t mir_input_event_get_event_time(MirInputEvent const* ev)
1491 {
1492 auto old_ev = old_ev_from_new(ev);
1493- assert(mir_event_get_type(old_ev) == mir_event_type_input);
1494+ if(mir_event_get_type(old_ev) != mir_event_type_input)
1495+ {
1496+ mir::log_critical("expected input event but event was of type " + mir::event_type_to_string(old_ev->type));
1497+ abort();
1498+ }
1499
1500 switch (old_ev->type)
1501 {
1502@@ -121,7 +143,11 @@
1503 MirKeyInputEvent const* mir_input_event_get_key_input_event(MirInputEvent const* ev)
1504 {
1505 if (mir_input_event_get_type(ev) != mir_input_event_type_key)
1506+ {
1507+ mir::log_critical("expected key input event but event was of type " +
1508+ input_event_type_to_string(mir_input_event_get_type(ev)));
1509 abort();
1510+ }
1511
1512 return reinterpret_cast<MirKeyInputEvent const*>(ev);
1513 }
1514@@ -161,59 +187,70 @@
1515
1516 namespace
1517 {
1518-MirKeyInputEventModifiers old_modifiers_to_new(MirKeyModifier old_modifier)
1519+MirInputEventModifiers old_modifiers_to_new(MirKeyModifier old_modifier)
1520 {
1521 unsigned modifier = 0;
1522
1523 if (old_modifier & mir_key_modifier_none)
1524- modifier |= mir_key_input_event_modifier_none;
1525+ modifier |= mir_input_event_modifier_none;
1526 if (old_modifier & mir_key_modifier_alt)
1527- modifier |= mir_key_input_event_modifier_alt;
1528+ modifier |= mir_input_event_modifier_alt;
1529 if (old_modifier & mir_key_modifier_alt_left)
1530- modifier |= mir_key_input_event_modifier_alt_left;
1531+ modifier |= mir_input_event_modifier_alt_left;
1532 if (old_modifier & mir_key_modifier_alt_right)
1533- modifier |= mir_key_input_event_modifier_alt_right;
1534+ modifier |= mir_input_event_modifier_alt_right;
1535 if (old_modifier & mir_key_modifier_shift)
1536- modifier |= mir_key_input_event_modifier_shift;
1537+ modifier |= mir_input_event_modifier_shift;
1538 if (old_modifier & mir_key_modifier_shift_left)
1539- modifier |= mir_key_input_event_modifier_shift_left;
1540+ modifier |= mir_input_event_modifier_shift_left;
1541 if (old_modifier & mir_key_modifier_shift_right)
1542- modifier |= mir_key_input_event_modifier_shift_right;
1543+ modifier |= mir_input_event_modifier_shift_right;
1544 if (old_modifier & mir_key_modifier_sym)
1545- modifier |= mir_key_input_event_modifier_sym;
1546+ modifier |= mir_input_event_modifier_sym;
1547 if (old_modifier & mir_key_modifier_function)
1548- modifier |= mir_key_input_event_modifier_function;
1549+ modifier |= mir_input_event_modifier_function;
1550 if (old_modifier & mir_key_modifier_ctrl)
1551- modifier |= mir_key_input_event_modifier_ctrl;
1552+ modifier |= mir_input_event_modifier_ctrl;
1553 if (old_modifier & mir_key_modifier_ctrl_left)
1554- modifier |= mir_key_input_event_modifier_ctrl_left;
1555+ modifier |= mir_input_event_modifier_ctrl_left;
1556 if (old_modifier & mir_key_modifier_ctrl_right)
1557- modifier |= mir_key_input_event_modifier_ctrl_right;
1558+ modifier |= mir_input_event_modifier_ctrl_right;
1559 if (old_modifier & mir_key_modifier_meta)
1560- modifier |= mir_key_input_event_modifier_meta;
1561+ modifier |= mir_input_event_modifier_meta;
1562 if (old_modifier & mir_key_modifier_meta_left)
1563- modifier |= mir_key_input_event_modifier_meta_left;
1564+ modifier |= mir_input_event_modifier_meta_left;
1565 if (old_modifier & mir_key_modifier_meta_right)
1566- modifier |= mir_key_input_event_modifier_meta_right;
1567+ modifier |= mir_input_event_modifier_meta_right;
1568 if (old_modifier & mir_key_modifier_caps_lock)
1569- modifier |= mir_key_input_event_modifier_caps_lock;
1570+ modifier |= mir_input_event_modifier_caps_lock;
1571 if (old_modifier & mir_key_modifier_num_lock)
1572- modifier |= mir_key_input_event_modifier_num_lock;
1573+ modifier |= mir_input_event_modifier_num_lock;
1574 if (old_modifier & mir_key_modifier_scroll_lock)
1575- modifier |= mir_key_input_event_modifier_scroll_lock;
1576- return static_cast<MirKeyInputEventModifiers>(modifier);
1577-}
1578-}
1579-MirKeyInputEventModifiers mir_key_input_event_get_modifiers(MirKeyInputEvent const* kev)
1580-{ auto const& old_kev = old_kev_from_new(kev);
1581+ modifier |= mir_input_event_modifier_scroll_lock;
1582+ return static_cast<MirInputEventModifiers>(modifier);
1583+}
1584+}
1585+MirInputEventModifiers mir_key_input_event_get_modifiers(MirKeyInputEvent const* kev)
1586+{
1587+ auto const& old_kev = old_kev_from_new(kev);
1588 return old_modifiers_to_new(static_cast<MirKeyModifier>(old_kev.modifiers));
1589 }
1590 /* Touch event accessors */
1591
1592+MirInputEventModifiers mir_touch_input_event_get_modifiers(MirTouchInputEvent const* tev)
1593+{
1594+ auto const& old_mev = old_mev_from_new(tev);
1595+ return old_modifiers_to_new(static_cast<MirKeyModifier>(old_mev.modifiers));
1596+}
1597+
1598 MirTouchInputEvent const* mir_input_event_get_touch_input_event(MirInputEvent const* ev)
1599 {
1600 if(mir_input_event_get_type(ev) != mir_input_event_type_touch)
1601+ {
1602+ mir::log_critical("expected touch input event but event was of type " +
1603+ input_event_type_to_string(mir_input_event_get_type(ev)));
1604 abort();
1605+ }
1606
1607 return reinterpret_cast<MirTouchInputEvent const*>(ev);
1608 }
1609@@ -229,7 +266,10 @@
1610 auto const& old_mev = old_mev_from_new(event);
1611
1612 if (touch_index >= old_mev.pointer_count)
1613+ {
1614+ mir::log_critical("touch index is greater than pointer count");
1615 abort();
1616+ }
1617
1618 return old_mev.pointer_coordinates[touch_index].id;
1619 }
1620@@ -239,7 +279,10 @@
1621 auto const& old_mev = old_mev_from_new(event);
1622
1623 if(touch_index > old_mev.pointer_count)
1624+ {
1625+ mir::log_critical("touch index is greater than pointer count");
1626 abort();
1627+ }
1628
1629 auto masked_action = old_mev.action & MIR_EVENT_ACTION_MASK;
1630 size_t masked_index = (old_mev.action & MIR_EVENT_ACTION_POINTER_INDEX_MASK) >> MIR_EVENT_ACTION_POINTER_INDEX_SHIFT;
1631@@ -285,7 +328,10 @@
1632 auto const& old_mev = old_mev_from_new(event);
1633
1634 if(touch_index > old_mev.pointer_count)
1635+ {
1636+ mir::log_critical("touch index is greater than pointer count");
1637 abort();
1638+ }
1639
1640 switch (old_mev.pointer_coordinates[touch_index].tool_type)
1641 {
1642@@ -307,7 +353,10 @@
1643 auto const& old_mev = old_mev_from_new(event);
1644
1645 if(touch_index > old_mev.pointer_count)
1646+ {
1647+ mir::log_critical("touch index is greater than pointer count");
1648 abort();
1649+ }
1650
1651 auto const& old_pc = old_mev.pointer_coordinates[touch_index];
1652 switch (axis)
1653
1654=== added file 'src/include/common/mir/event_type_to_string.h'
1655--- src/include/common/mir/event_type_to_string.h 1970-01-01 00:00:00 +0000
1656+++ src/include/common/mir/event_type_to_string.h 2014-12-19 16:55:48 +0000
1657@@ -0,0 +1,30 @@
1658+/*
1659+ * Copyright © 2014 Canonical Ltd.
1660+ *
1661+ * This program is free software: you can redistribute it and/or modify it
1662+ * under the terms of the GNU Lesser General Public License version 3,
1663+ * as published by the Free Software Foundation.
1664+ *
1665+ * This program is distributed in the hope that it will be useful,
1666+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1667+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1668+ * GNU Lesser General Public License for more details.
1669+ *
1670+ * You should have received a copy of the GNU Lesser General Public License
1671+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1672+ *
1673+ * Authored by: Robert Carr <robert.carr@canonical.com>
1674+ */
1675+
1676+#ifndef MIR_EVENT_TYPE_TO_STRING_H_
1677+#define MIR_EVENT_TYPE_TO_STRING_H_
1678+
1679+#include <string>
1680+#include "mir_toolkit/client_types.h"
1681+
1682+namespace mir
1683+{
1684+std::string event_type_to_string(MirEventType t);
1685+}
1686+
1687+#endif // MIR_EVENT_TYPE_TO_STRING_H_
1688
1689=== modified file 'src/server/mirserver.pc.in'
1690--- src/server/mirserver.pc.in 2014-12-08 04:03:47 +0000
1691+++ src/server/mirserver.pc.in 2014-12-19 16:55:48 +0000
1692@@ -8,5 +8,5 @@
1693 Version: @MIR_VERSION@
1694 Requires.private: mirclient
1695 Requires: mirplatform
1696-Libs: -L@LIBDIR@ -lmirserver
1697+Libs: -L@LIBDIR@ -lmirserver -lmircommon
1698 Cflags: -I@INCLUDEDIR@
1699
1700=== modified file 'tests/unit-tests/input/test_input_event.cpp'
1701--- tests/unit-tests/input/test_input_event.cpp 2014-11-25 22:20:10 +0000
1702+++ tests/unit-tests/input/test_input_event.cpp 2014-12-19 16:55:48 +0000
1703@@ -19,7 +19,7 @@
1704 #include <gtest/gtest.h>
1705
1706 #include "mir_toolkit/event.h"
1707-#include "mir_toolkit/input/input_event.h"
1708+#include "mir_toolkit/events/input/input_event.h"
1709
1710 // See: https://bugs.launchpad.net/mir/+bug/1311699
1711 #define MIR_EVENT_ACTION_POINTER_INDEX_MASK 0xff00
1712@@ -115,7 +115,7 @@
1713 auto new_kev = mir_input_event_get_key_input_event(mir_event_get_input_event(&old_ev));
1714 EXPECT_EQ(key_code, mir_key_input_event_get_key_code(new_kev));
1715 EXPECT_EQ(scan_code, mir_key_input_event_get_scan_code(new_kev));
1716- EXPECT_EQ(mir_key_input_event_modifier_shift, mir_key_input_event_get_modifiers(new_kev));
1717+ EXPECT_EQ(mir_input_event_modifier_shift, mir_key_input_event_get_modifiers(new_kev));
1718 }
1719
1720 TEST(TouchInputEventProperties, touch_count_taken_from_pointer_count)

Subscribers

People subscribed via source and target branches