Mir

Merge lp:~vanvugt/mir/quit-eglapp into lp:mir

Proposed by Daniel van Vugt
Status: Merged
Approved by: Alan Griffiths
Approved revision: no longer in the source branch.
Merged at revision: 3781
Proposed branch: lp:~vanvugt/mir/quit-eglapp
Merge into: lp:mir
Diff against target: 369 lines (+64/-45)
17 files modified
examples/animated_cursor_demo_client.c (+1/-1)
examples/camera.c (+7/-8)
examples/client_touch_validator.cpp (+1/-1)
examples/cursors_demo_client.c (+1/-1)
examples/demo_client_display_config.c (+1/-1)
examples/eglapp.c (+9/-4)
examples/eglapp.h (+4/-1)
examples/eglcounter.cpp (+1/-1)
examples/eglflash.c (+1/-1)
examples/eglplasma.c (+1/-1)
examples/eglstateswitcher.c (+1/-1)
examples/egltriangle.c (+1/-1)
examples/pointer_confinement.c (+1/-1)
examples/scroll.cpp (+1/-1)
examples/target.c (+1/-1)
examples/tooltip.c (+1/-1)
src/utils/vanity.c (+31/-19)
To merge this branch: bzr merge lp:~vanvugt/mir/quit-eglapp
Reviewer Review Type Date Requested Status
Alan Griffiths Approve
Cemil Azizoglu (community) Approve
Mir CI Bot continuous-integration Approve
Review via email: mp+308855@code.launchpad.net

Commit message

Fix apps refusing to quit (LP: #1635010) and also pass unhandled events
on to the default event handler, so other features are not accidentally
disabled.

To post a comment you must log in.
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3774
https://mir-jenkins.ubuntu.com/job/mir-ci/2014/
Executed test runs:
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-mir/2581
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/2644
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/2636
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/2636
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=yakkety/2636
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/2610
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/2610/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/2610
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/2610/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/2610
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/2610/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/2610
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/2610/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/2610
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/2610/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/2610
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/2610/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/2014/rebuild

review: Approve (continuous-integration)
Revision history for this message
Cemil Azizoglu (cemil-azizoglu) wrote :

Ok

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

OK

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'examples/animated_cursor_demo_client.c'
2--- examples/animated_cursor_demo_client.c 2016-10-05 08:42:26 +0000
3+++ examples/animated_cursor_demo_client.c 2016-10-19 19:29:35 +0000
4@@ -99,7 +99,7 @@
5 animate_cursor(stream);
6 }
7
8- mir_eglapp_shutdown();
9+ mir_eglapp_cleanup();
10
11 return 0;
12 }
13
14=== modified file 'examples/camera.c'
15--- examples/camera.c 2016-10-05 08:42:26 +0000
16+++ examples/camera.c 2016-10-19 19:29:35 +0000
17@@ -87,6 +87,7 @@
18 {
19 (void)surface;
20 State *state = (State*)context;
21+ bool handled = true;
22
23 // FIXME: We presently need to know that events come in on a different
24 // thread to main (LP: #1194384). When that's resolved, simple
25@@ -95,21 +96,19 @@
26
27 switch (mir_event_get_type(event))
28 {
29- case mir_event_type_input:
30- break;
31 case mir_event_type_resize:
32 state->resized = true;
33 break;
34- case mir_event_type_close_surface:
35- // TODO: eglapp.h needs a quit() function or different behaviour of
36- // mir_eglapp_shutdown().
37- raise(SIGTERM); // handled by eglapp
38- break;
39 default:
40+ handled = false;
41 break;
42 }
43
44 pthread_mutex_unlock(&state->mutex);
45+
46+ if (!handled)
47+ mir_eglapp_handle_event(surface, event, NULL);
48+
49 }
50
51 static void fourcc_string(__u32 x, char str[5])
52@@ -553,7 +552,7 @@
53 }
54
55 mir_surface_set_event_handler(surface, NULL, NULL);
56- mir_eglapp_shutdown();
57+ mir_eglapp_cleanup();
58 close_camera(cam);
59
60 return 0;
61
62=== modified file 'examples/client_touch_validator.cpp'
63--- examples/client_touch_validator.cpp 2016-10-04 08:15:29 +0000
64+++ examples/client_touch_validator.cpp 2016-10-19 19:29:35 +0000
65@@ -194,7 +194,7 @@
66 sleep(1);
67 }
68
69- mir_eglapp_shutdown();
70+ mir_eglapp_cleanup();
71
72 return 0;
73 }
74
75=== modified file 'examples/cursors_demo_client.c'
76--- examples/cursors_demo_client.c 2016-10-05 08:42:26 +0000
77+++ examples/cursors_demo_client.c 2016-10-19 19:29:35 +0000
78@@ -72,7 +72,7 @@
79 usleep(100000);
80 }
81
82- mir_eglapp_shutdown();
83+ mir_eglapp_cleanup();
84
85 return 0;
86 }
87
88=== modified file 'examples/demo_client_display_config.c'
89--- examples/demo_client_display_config.c 2016-10-04 08:15:29 +0000
90+++ examples/demo_client_display_config.c 2016-10-19 19:29:35 +0000
91@@ -390,7 +390,7 @@
92 }
93 }
94
95- mir_eglapp_shutdown();
96+ mir_eglapp_cleanup();
97
98 return 0;
99 }
100
101=== modified file 'examples/eglapp.c'
102--- examples/eglapp.c 2016-10-05 08:42:26 +0000
103+++ examples/eglapp.c 2016-10-19 19:29:35 +0000
104@@ -45,7 +45,7 @@
105 return 0; \
106 }
107
108-void mir_eglapp_shutdown(void)
109+void mir_eglapp_cleanup(void)
110 {
111 eglMakeCurrent(egldisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
112 eglTerminate(egldisplay);
113@@ -55,11 +55,16 @@
114 connection = NULL;
115 }
116
117+void mir_eglapp_quit(void)
118+{
119+ running = 0;
120+}
121+
122 static void shutdown(int signum)
123 {
124 if (running)
125 {
126- running = 0;
127+ mir_eglapp_quit();
128 printf("Signal %d received. Good night.\n", signum);
129 }
130 }
131@@ -138,10 +143,10 @@
132 mir_surface_output_event_get_refresh_rate(out));
133 }
134
135-static void mir_eglapp_handle_event(MirSurface* surface, MirEvent const* ev, void* context)
136+void mir_eglapp_handle_event(MirSurface* surface, MirEvent const* ev, void* unused)
137 {
138 (void) surface;
139- (void) context;
140+ (void) unused;
141
142 switch (mir_event_get_type(ev))
143 {
144
145=== modified file 'examples/eglapp.h'
146--- examples/eglapp.h 2016-10-04 08:15:29 +0000
147+++ examples/eglapp.h 2016-10-19 19:29:35 +0000
148@@ -25,6 +25,7 @@
149
150 struct MirConnection;
151 struct MirSurface;
152+struct MirEvent;
153
154 typedef int mir_eglapp_bool;
155
156@@ -42,8 +43,10 @@
157 unsigned int* width, unsigned int* height,
158 struct mir_eglapp_arg const* custom_args);
159 void mir_eglapp_swap_buffers(void);
160+void mir_eglapp_quit(void);
161 mir_eglapp_bool mir_eglapp_running(void);
162-void mir_eglapp_shutdown(void);
163+void mir_eglapp_cleanup(void);
164+void mir_eglapp_handle_event(struct MirSurface* surface, struct MirEvent const* ev, void* unused);
165
166 struct MirConnection* mir_eglapp_native_connection();
167 struct MirSurface* mir_eglapp_native_surface();
168
169=== modified file 'examples/eglcounter.cpp'
170--- examples/eglcounter.cpp 2016-10-04 08:15:29 +0000
171+++ examples/eglcounter.cpp 2016-10-19 19:29:35 +0000
172@@ -274,7 +274,7 @@
173 mir_eglapp_swap_buffers();
174 }
175
176- mir_eglapp_shutdown();
177+ mir_eglapp_cleanup();
178
179 return 0;
180 }
181
182=== modified file 'examples/eglflash.c'
183--- examples/eglflash.c 2016-10-04 08:15:29 +0000
184+++ examples/eglflash.c 2016-10-19 19:29:35 +0000
185@@ -59,7 +59,7 @@
186 sleep(1);
187 }
188
189- mir_eglapp_shutdown();
190+ mir_eglapp_cleanup();
191
192 return 0;
193 }
194
195=== modified file 'examples/eglplasma.c'
196--- examples/eglplasma.c 2016-10-05 08:42:26 +0000
197+++ examples/eglplasma.c 2016-10-19 19:29:35 +0000
198@@ -143,7 +143,7 @@
199 mir_eglapp_swap_buffers();
200 }
201
202- mir_eglapp_shutdown();
203+ mir_eglapp_cleanup();
204
205 return 0;
206 }
207
208=== modified file 'examples/eglstateswitcher.c'
209--- examples/eglstateswitcher.c 2016-10-04 08:15:29 +0000
210+++ examples/eglstateswitcher.c 2016-10-19 19:29:35 +0000
211@@ -56,7 +56,7 @@
212 toggle_surface_state(surface, &state);
213 }
214
215- mir_eglapp_shutdown();
216+ mir_eglapp_cleanup();
217
218 return 0;
219 }
220
221=== modified file 'examples/egltriangle.c'
222--- examples/egltriangle.c 2016-10-04 08:15:29 +0000
223+++ examples/egltriangle.c 2016-10-19 19:29:35 +0000
224@@ -128,7 +128,7 @@
225 mir_eglapp_swap_buffers();
226 }
227
228- mir_eglapp_shutdown();
229+ mir_eglapp_cleanup();
230
231 return 0;
232 }
233
234=== modified file 'examples/pointer_confinement.c'
235--- examples/pointer_confinement.c 2016-10-04 08:15:29 +0000
236+++ examples/pointer_confinement.c 2016-10-19 19:29:35 +0000
237@@ -278,6 +278,6 @@
238 mir_eglapp_swap_buffers();
239 }
240
241- mir_eglapp_shutdown();
242+ mir_eglapp_cleanup();
243 return 0;
244 }
245
246=== modified file 'examples/scroll.cpp'
247--- examples/scroll.cpp 2016-10-05 08:42:26 +0000
248+++ examples/scroll.cpp 2016-10-19 19:29:35 +0000
249@@ -39,7 +39,7 @@
250 gl_animation.step();
251 }
252
253- mir_eglapp_shutdown();
254+ mir_eglapp_cleanup();
255 return 0;
256 }
257 catch(std::exception& e)
258
259=== modified file 'examples/target.c'
260--- examples/target.c 2016-10-05 08:42:26 +0000
261+++ examples/target.c 2016-10-19 19:29:35 +0000
262@@ -422,7 +422,7 @@
263 }
264
265 mir_surface_set_event_handler(surface, NULL, NULL);
266- mir_eglapp_shutdown();
267+ mir_eglapp_cleanup();
268
269 pthread_join(shutdown_handler_thread, NULL);
270 return 0;
271
272=== modified file 'examples/tooltip.c'
273--- examples/tooltip.c 2016-10-04 08:15:29 +0000
274+++ examples/tooltip.c 2016-10-19 19:29:35 +0000
275@@ -67,7 +67,7 @@
276 }
277
278 mir_surface_release_sync(tooltip);
279- mir_eglapp_shutdown();
280+ mir_eglapp_cleanup();
281
282 return 0;
283 }
284
285=== modified file 'src/utils/vanity.c'
286--- src/utils/vanity.c 2016-10-10 09:20:42 +0000
287+++ src/utils/vanity.c 2016-10-19 19:29:35 +0000
288@@ -110,8 +110,33 @@
289 return shader;
290 }
291
292+static bool on_key_event(MirKeyboardEvent const* kevent, State* state)
293+{
294+ if (mir_keyboard_event_action(kevent) == mir_keyboard_action_up)
295+ {
296+ switch (mir_keyboard_event_scan_code(kevent))
297+ {
298+ case KEY_R:
299+ state->reset = true;
300+ return true;
301+ default:
302+ break;
303+ }
304+ }
305+ return false;
306+}
307+
308+static bool on_input_event(MirInputEvent const* ievent, State* state)
309+{
310+ if (mir_input_event_get_type(ievent) == mir_input_event_type_key)
311+ return on_key_event(mir_input_event_get_keyboard_event(ievent), state);
312+ return false;
313+}
314+
315 static void on_event(MirSurface* surface, MirEvent const* event, void* context)
316 {
317+ bool handled = true;
318+
319 (void)surface;
320 State* state = (State*)context;
321
322@@ -123,33 +148,20 @@
323 switch (mir_event_get_type(event))
324 {
325 case mir_event_type_input:
326- {
327- MirInputEvent const* ievent = mir_event_get_input_event(event);
328- if (mir_input_event_get_type(ievent) == mir_input_event_type_key)
329- {
330- MirKeyboardEvent const* kevent =
331- mir_input_event_get_keyboard_event(ievent);
332- if (mir_keyboard_event_action(kevent) == mir_keyboard_action_up
333- && mir_keyboard_event_scan_code(kevent) == KEY_R)
334- {
335- state->reset = true;
336- }
337- }
338- }
339+ handled = on_input_event(mir_event_get_input_event(event), state);
340 break;
341 case mir_event_type_resize:
342 state->resized = true;
343 break;
344- case mir_event_type_close_surface:
345- // TODO: eglapp.h needs a quit() function or different behaviour of
346- // mir_eglapp_shutdown().
347- raise(SIGTERM); // handled by eglapp
348- break;
349 default:
350+ handled = false;
351 break;
352 }
353
354 pthread_mutex_unlock(&state->mutex);
355+
356+ if (!handled)
357+ mir_eglapp_handle_event(surface, event, NULL);
358 }
359
360 static void fourcc_string(__u32 x, char str[5])
361@@ -829,7 +841,7 @@
362 }
363
364 mir_surface_set_event_handler(surface, NULL, NULL);
365- mir_eglapp_shutdown();
366+ mir_eglapp_cleanup();
367
368 pthread_join(capture_thread, NULL);
369 close_camera(cam);

Subscribers

People subscribed via source and target branches