Mir

Merge lp:~mir-team/mir/prepare-to-privatize-event into lp:mir

Proposed by Robert Carr
Status: Merged
Approved by: Daniel van Vugt
Approved revision: no longer in the source branch.
Merged at revision: 2436
Proposed branch: lp:~mir-team/mir/prepare-to-privatize-event
Merge into: lp:mir
Diff against target: 252 lines (+60/-61)
6 files modified
benchmarks/frame-uniformity/touch_samples.cpp (+18/-15)
examples/eglapp.c (+6/-3)
tests/acceptance-tests/test_client_focus_notification.cpp (+14/-16)
tests/acceptance-tests/test_client_library.cpp (+0/-13)
tests/acceptance-tests/test_client_surface_visibility.cpp (+11/-11)
tests/include/mir_test/event_matchers.h (+11/-3)
To merge this branch: bzr merge lp:~mir-team/mir/prepare-to-privatize-event
Reviewer Review Type Date Requested Status
Alan Griffiths Approve
PS Jenkins bot (community) continuous-integration Approve
Chris Halse Rogers Approve
Review via email: mp+254148@code.launchpad.net

Commit message

Some final event 2.0 porting in preparation to privatize the event header.

Description of the change

Some final event 2.0 porting in preparation to privatize the event header.

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
Chris Halse Rogers (raof) wrote :

Looks sensible

review: Approve
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: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

240 +MATCHER_P(OrientationEvent, direction, "")
241 +{
242 + auto as_address = to_address(arg);
243 + if (mir_event_get_type(as_address) != mir_event_type_orientation)
244 + return false;
245 + auto oev = mir_event_get_orientation_event(as_address);
246 + if (mir_orientation_event_get_direction(oev) != direction)
247 + return false;
248 + return true;
249 +}
250 +

Dead code.

OTOH It looks like the lack of use is a testing gap - should it be introduced in an MP to fill that gap?

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

> OTOH It looks like the lack of use is a testing gap - should it be introduced
> in an MP to fill that gap?

Oh, it *is* used in the dependent branch - I won't block on the landing order.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'benchmarks/frame-uniformity/touch_samples.cpp'
2--- benchmarks/frame-uniformity/touch_samples.cpp 2015-03-25 02:48:40 +0000
3+++ benchmarks/frame-uniformity/touch_samples.cpp 2015-03-27 08:01:05 +0000
4@@ -16,8 +16,6 @@
5 * Authored by: Robert Carr <robert.carr@canonical.com>
6 */
7
8-#define MIR_INCLUDE_DEPRECATED_EVENT_HEADER
9-
10 #include "touch_samples.h"
11
12 void TouchSamples::record_frame_time(std::chrono::high_resolution_clock::time_point time)
13@@ -36,21 +34,26 @@
14 {
15 std::unique_lock<std::mutex> lg(guard);
16
17- if (event.type != mir_event_type_motion)
18- return;
19-
20- auto const& mev = event.motion;
21- if (mev.action != mir_motion_action_down &&
22- mev.action != mir_motion_action_up &&
23- mev.action != mir_motion_action_move)
24- {
25- return;
26- }
27+ if (mir_event_get_type(&event) != mir_event_type_input)
28+ return;
29+ auto iev = mir_event_get_input_event(&event);
30+ if (mir_input_event_get_type(iev) != mir_input_event_type_touch)
31+ return;
32+ auto tev = mir_input_event_get_touch_event(iev);
33+
34 // We could support multitouch, etc...
35- auto const& coordinates = mev.pointer_coordinates[0];
36-
37+ size_t touch_index = 0;
38+ auto action = mir_touch_event_action(tev, touch_index);
39+ if (action != mir_touch_action_down &&
40+ action != mir_touch_action_up &&
41+ action != mir_touch_action_change)
42+ {
43+ return;
44+ }
45+ auto x = mir_touch_event_axis_value(tev, 0, mir_touch_axis_x);
46+ auto y = mir_touch_event_axis_value(tev, 0, mir_touch_axis_y);
47 // TODO: Record both event time and reception time
48- samples_being_prepared.push_back(Sample{coordinates.x, coordinates.y, reception_time, {}});
49+ samples_being_prepared.push_back(Sample{x, y, reception_time, {}});
50 }
51
52 std::vector<TouchSamples::Sample> TouchSamples::get()
53
54=== modified file 'examples/eglapp.c'
55--- examples/eglapp.c 2015-03-25 02:48:40 +0000
56+++ examples/eglapp.c 2015-03-27 08:01:05 +0000
57@@ -16,8 +16,6 @@
58 * Author: Daniel van Vugt <daniel.van.vugt@canonical.com>
59 */
60
61-#define MIR_INCLUDE_DEPRECATED_EVENT_HEADER
62-
63 #include "eglapp.h"
64 #include "mir_toolkit/mir_client_library.h"
65 #include <stdio.h>
66@@ -144,7 +142,12 @@
67 * support for event queuing (directing them to another thread) or
68 * full single-threaded callbacks. (LP: #1194384).
69 */
70- printf("Resized to %dx%d\n", ev->resize.width, ev->resize.height);
71+ {
72+ MirResizeEvent const* resize = mir_event_get_resize_event(ev);
73+ printf("Resized to %dx%d\n",
74+ mir_resize_event_get_width(resize),
75+ mir_resize_event_get_height(resize));
76+ }
77 break;
78 case mir_event_type_close_surface:
79 printf("Received close event from server.\n");
80
81=== modified file 'tests/acceptance-tests/test_client_focus_notification.cpp'
82--- tests/acceptance-tests/test_client_focus_notification.cpp 2015-03-25 02:48:40 +0000
83+++ tests/acceptance-tests/test_client_focus_notification.cpp 2015-03-27 08:01:05 +0000
84@@ -16,8 +16,6 @@
85 * Authored by: Robert Carr <robert.carr@canonical.com>
86 */
87
88-#define MIR_INCLUDE_DEPRECATED_EVENT_HEADER
89-
90 #include "mir_toolkit/mir_client_library.h"
91
92 #include "mir_test/wait_condition.h"
93@@ -101,10 +99,10 @@
94 run_in_client([&]
95 {
96 InSequence s;
97- EXPECT_CALL(observer, see(Pointee(mt::SurfaceEvent(mir_surface_attrib_focus, mir_surface_focused)))).Times(1)
98+ EXPECT_CALL(observer, see(mt::SurfaceEvent(mir_surface_attrib_focus, mir_surface_focused))).Times(1)
99 .WillOnce(mt::WakeUp(&all_events_received));
100 // We may not see mir_surface_unfocused before connection closes
101- EXPECT_CALL(observer, see(Pointee(mt::SurfaceEvent(mir_surface_attrib_focus, mir_surface_unfocused)))).Times(AtMost(1));
102+ EXPECT_CALL(observer, see(mt::SurfaceEvent(mir_surface_attrib_focus, mir_surface_unfocused))).Times(AtMost(1));
103
104 connect_and_create_surface();
105 });
106@@ -130,19 +128,19 @@
107 {
108 InSequence seq;
109 // We should receive focus as we are created
110- EXPECT_CALL(observer, see(Pointee(mt::SurfaceEvent(mir_surface_attrib_focus,
111- mir_surface_focused)))).Times(1)
112+ EXPECT_CALL(observer, see(mt::SurfaceEvent(mir_surface_attrib_focus,
113+ mir_surface_focused))).Times(1)
114 .WillOnce(SignalFence(&ready_for_second_client));
115
116 // And lose it as the second surface is created
117- EXPECT_CALL(observer, see(Pointee(mt::SurfaceEvent(mir_surface_attrib_focus,
118- mir_surface_unfocused)))).Times(1);
119+ EXPECT_CALL(observer, see(mt::SurfaceEvent(mir_surface_attrib_focus,
120+ mir_surface_unfocused))).Times(1);
121 // And regain it when the second surface is closed
122- EXPECT_CALL(observer, see(Pointee(mt::SurfaceEvent(mir_surface_attrib_focus,
123- mir_surface_focused)))).Times(1).WillOnce(mt::WakeUp(&all_events_received));
124+ EXPECT_CALL(observer, see(mt::SurfaceEvent(mir_surface_attrib_focus,
125+ mir_surface_focused))).Times(1).WillOnce(mt::WakeUp(&all_events_received));
126 // And then lose it as we are closed (but we may not see confirmation before connection closes)
127- EXPECT_CALL(observer, see(Pointee(mt::SurfaceEvent(mir_surface_attrib_focus,
128- mir_surface_unfocused)))).Times(AtMost(1));
129+ EXPECT_CALL(observer, see(mt::SurfaceEvent(mir_surface_attrib_focus,
130+ mir_surface_unfocused))).Times(AtMost(1));
131
132 connect_and_create_surface();
133 });
134@@ -151,12 +149,12 @@
135 {
136 ready_for_second_client.wait_for_signal_ready_for();
137
138- EXPECT_CALL(observer, see(Pointee(
139- mt::SurfaceEvent(mir_surface_attrib_focus, mir_surface_focused))))
140+ EXPECT_CALL(observer, see(
141+ mt::SurfaceEvent(mir_surface_attrib_focus, mir_surface_focused)))
142 .Times(1).WillOnce(mt::WakeUp(&all_events_received));
143 // We may not see mir_surface_unfocused before connection closes
144- EXPECT_CALL(observer, see(Pointee(
145- mt::SurfaceEvent(mir_surface_attrib_focus, mir_surface_unfocused))))
146+ EXPECT_CALL(observer, see(
147+ mt::SurfaceEvent(mir_surface_attrib_focus, mir_surface_unfocused)))
148 .Times(AtMost(1));
149
150 connect_and_create_surface();
151
152=== modified file 'tests/acceptance-tests/test_client_library.cpp'
153--- tests/acceptance-tests/test_client_library.cpp 2015-03-25 02:48:40 +0000
154+++ tests/acceptance-tests/test_client_library.cpp 2015-03-27 08:01:05 +0000
155@@ -16,8 +16,6 @@
156 * Authored by: Thomas Guest <thomas.guest@canonical.com>
157 */
158
159-#define MIR_INCLUDE_DEPRECATED_EVENT_HEADER
160-
161 #include "mir_toolkit/mir_client_library.h"
162
163 #include "mir_test_framework/headless_in_process_server.h"
164@@ -118,17 +116,6 @@
165 return surfaces.size();
166 }
167
168- MirEvent last_event{};
169- MirSurface* last_event_surface = nullptr;
170-
171- static void event_callback(MirSurface* surface, MirEvent const* event,
172- void* ctx)
173- {
174- ClientLibrary* self = static_cast<ClientLibrary*>(ctx);
175- self->last_event = *event;
176- self->last_event_surface = surface;
177- }
178-
179 static void nosey_thread(MirSurface *surf)
180 {
181 for (int i = 0; i < 10; i++)
182
183=== modified file 'tests/acceptance-tests/test_client_surface_visibility.cpp'
184--- tests/acceptance-tests/test_client_surface_visibility.cpp 2015-03-27 06:58:51 +0000
185+++ tests/acceptance-tests/test_client_surface_visibility.cpp 2015-03-27 08:01:05 +0000
186@@ -16,8 +16,6 @@
187 * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com>
188 */
189
190-#define MIR_INCLUDE_DEPRECATED_EVENT_HEADER
191-
192 #include "mir_toolkit/mir_client_library.h"
193
194 #include "mir/scene/session.h"
195@@ -87,15 +85,17 @@
196
197 void event_callback(MirSurface* surface, MirEvent const* event, void* ctx)
198 {
199- if (event->type == mir_event_type_surface &&
200- event->surface.attrib == mir_surface_attrib_visibility)
201- {
202- auto const mock_visibility_callback =
203- reinterpret_cast<testing::NiceMock<MockVisibilityCallback>*>(ctx);
204- mock_visibility_callback->handle(
205- surface,
206- static_cast<MirSurfaceVisibility>(event->surface.value));
207- }
208+ if (mir_event_get_type(event) != mir_event_type_surface)
209+ return;
210+ auto sev = mir_event_get_surface_event(event);
211+ if (mir_surface_event_get_attribute(sev) != mir_surface_attrib_visibility)
212+ return;
213+
214+ auto const mock_visibility_callback =
215+ reinterpret_cast<testing::NiceMock<MockVisibilityCallback>*>(ctx);
216+ mock_visibility_callback->handle(
217+ surface,
218+ static_cast<MirSurfaceVisibility>(mir_surface_event_get_attribute_value(sev)));
219 }
220
221 struct MirSurfaceVisibilityEvent : mtf::ConnectedClientWithASurface
222
223=== modified file 'tests/include/mir_test/event_matchers.h'
224--- tests/include/mir_test/event_matchers.h 2015-03-25 02:48:40 +0000
225+++ tests/include/mir_test/event_matchers.h 2015-03-27 08:01:05 +0000
226@@ -20,9 +20,6 @@
227 #ifndef MIR_TEST_CLIENT_EVENT_MATCHERS_H_
228 #define MIR_TEST_CLIENT_EVENT_MATCHERS_H_
229
230-#define MIR_INCLUDE_DEPRECATED_EVENT_HEADER
231-
232-
233 #include "mir_toolkit/event.h"
234
235 #include <xkbcommon/xkbcommon.h>
236@@ -362,6 +359,17 @@
237 return true;
238 }
239
240+MATCHER_P(OrientationEvent, direction, "")
241+{
242+ auto as_address = to_address(arg);
243+ if (mir_event_get_type(as_address) != mir_event_type_orientation)
244+ return false;
245+ auto oev = mir_event_get_orientation_event(as_address);
246+ if (mir_orientation_event_get_direction(oev) != direction)
247+ return false;
248+ return true;
249+}
250+
251 }
252 }
253

Subscribers

People subscribed via source and target branches