Mir

Merge lp:~robert-ancell/mir/alt-ctrl-backspace into lp:~mir-team/mir/trunk

Proposed by Robert Ancell
Status: Rejected
Rejected by: Robert Ancell
Proposed branch: lp:~robert-ancell/mir/alt-ctrl-backspace
Merge into: lp:~mir-team/mir/trunk
Diff against target: 215 lines (+68/-8)
8 files modified
examples/demo-inprocess-surface-client/CMakeLists.txt (+1/-0)
examples/demo-inprocess-surface-client/demo_inprocess_surface_client.cpp (+5/-4)
examples/demo-shell/demo_shell.cpp (+3/-1)
examples/demo_input_filter.cpp (+1/-1)
examples/demo_server.cpp (+2/-1)
examples/render_surfaces.cpp (+3/-1)
examples/server_configuration.cpp (+28/-0)
examples/server_configuration.h (+25/-0)
To merge this branch: bzr merge lp:~robert-ancell/mir/alt-ctrl-backspace
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Daniel van Vugt Needs Fixing
Alan Griffiths Needs Fixing
Review via email: mp+178036@code.launchpad.net

Commit message

Quit demo servers on alt-ctrl-backspace

To post a comment you must log in.
Revision history for this message
Robert Ancell (robert-ancell) wrote :

It would have been nicer to put this into run_mir() so the code isn't copied everywhere. But since the filter needs to be in the configuration object it has to be defined in each application.

Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

In https://code.launchpad.net/~afrantzis/mir/multimonitor-examples/+merge/178039 (not merged yet) I have added a base mir::examples::ServerConfiguration which all the demo servers and standalone programs use. We could put the filters there. In order to allow derived configuration classes to extend the filter list, we need to change the filter list interface to use a vector, or other manipulable object, instead of an initializer list.

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

> In https://code.launchpad.net/~afrantzis/mir/multimonitor-
> examples/+merge/178039 (not merged yet) I have added a base
> mir::examples::ServerConfiguration which all the demo servers and standalone
> programs use. We could put the filters there. In order to allow derived
> configuration classes to extend the filter list, we need to change the filter
> list interface to use a vector, or other manipulable object, instead of an
> initializer list.

Sounds good!

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

> > In https://code.launchpad.net/~afrantzis/mir/multimonitor-
> > examples/+merge/178039 (not merged yet) I have added a base
> > mir::examples::ServerConfiguration which all the demo servers and standalone
> > programs use. We could put the filters there.
...
> Sounds good!

The above has landed, so is this the plan?

It will address the duplication of code.

~~~~

18 +static mir::DisplayServer *server_ptr{nullptr};

I'm not a fan of mutable static data, and this seems unnecessary as quit_filter can be captured by the init lambda and could have set_server()/server_ptr members.

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

> > > In https://code.launchpad.net/~afrantzis/mir/multimonitor-
> > > examples/+merge/178039 (not merged yet) I have added a base
> > > mir::examples::ServerConfiguration which all the demo servers and
> standalone
> > > programs use. We could put the filters there.
> ...
> > Sounds good!
>
> The above has landed, so is this the plan?
>
> It will address the duplication of code.

Yes, that my plan at least. I have started working on it, so assuming all goes well this MP will be obsoleted.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

I think we should only be concerned with examples/demo-shell/ right now (demo_server_shell)

The purpose of demo_server is to show what a minimal server looks like. So adding complexity there is probably not a good idea. I would like to see the changes to examples/*.{h,cpp} reverted then.

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

> I think we should only be concerned with examples/demo-shell/ right now
> (demo_server_shell)
>
> The purpose of demo_server is to show what a minimal server looks like. So
> adding complexity there is probably not a good idea. I would like to see the
> changes to examples/*.{h,cpp} reverted then.

Good point. This definitely blurs the line between what the Mir library should provide and the minimal client code required to use it.

I think it would be better for the library to provide a default and allow it to be overridden than for every client to need to provide something similar to this.

review: Needs Fixing
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

The plan was to add this to the mir::examples::ServerConfiguration (after changing the interface so that derived ServerConfigurations can add more filters), so that all example servers and standalone programs can benefit from this transparently.

Alternatively, as mentioned, we can add support for this in mir::DefaultServerConfiguration, depending on what we want the default policy to be. I am OK with both.

Revision history for this message
Robert Ancell (robert-ancell) wrote :

Now updated with Alexandros' changes so the filter can be shared between all the examples.

I don't think this should be in mir::DefaultServerConfiguration since we don't want a magic key combination to kill Mir. For "real" Mir servers you should VT switch and kill the server. I'll make a separate MP to add VT switching key combinations by default.

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 :

Now mir_demo_server* all seem to exit immediately (without crashing!?), exit status zero.

Try merging lp:mir again?

review: Needs Fixing
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

212 + std::shared_ptr<QuitFilter> quit_filter;

The quit filter doesn't seem to get created...

Anyway, I will propose an alternative MP for this, removing the need for the set_server() calls. Stay tuned.

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'examples/demo-inprocess-surface-client/CMakeLists.txt'
2--- examples/demo-inprocess-surface-client/CMakeLists.txt 2013-05-22 14:21:16 +0000
3+++ examples/demo-inprocess-surface-client/CMakeLists.txt 2013-08-07 07:20:37 +0000
4@@ -4,6 +4,7 @@
5 demo_inprocess_surface_client.cpp
6 inprocess_egl_client.cpp
7 example_egl_helper.cpp
8+ ../server_configuration.cpp
9 )
10
11 target_link_libraries(mir_demo_standalone_inprocess_egl
12
13=== modified file 'examples/demo-inprocess-surface-client/demo_inprocess_surface_client.cpp'
14--- examples/demo-inprocess-surface-client/demo_inprocess_surface_client.cpp 2013-05-13 20:40:37 +0000
15+++ examples/demo-inprocess-surface-client/demo_inprocess_surface_client.cpp 2013-08-07 07:20:37 +0000
16@@ -17,11 +17,11 @@
17 */
18
19 #include "inprocess_egl_client.h"
20+#include "../server_configuration.h"
21
22 #include "mir/run_mir.h"
23-#include "mir/default_server_configuration.h"
24-
25 #include "mir/report_exception.h"
26+
27 #include <iostream>
28
29 namespace me = mir::examples;
30@@ -40,11 +40,12 @@
31 try
32 {
33 ///\internal [main_tag]
34- mir::DefaultServerConfiguration config(argc, argv);
35+ me::ServerConfiguration config(argc, argv);
36
37 std::shared_ptr<me::InprocessEGLClient> client;
38- mir::run_mir(config, [&config, &client](mir::DisplayServer&)
39+ mir::run_mir(config, [&config, &client](mir::DisplayServer& display_server)
40 {
41+ config.set_server(display_server);
42 client = std::make_shared<me::InprocessEGLClient>(
43 config.the_main_loop(),
44 config.the_graphics_platform(),
45
46=== modified file 'examples/demo-shell/demo_shell.cpp'
47--- examples/demo-shell/demo_shell.cpp 2013-08-06 10:39:53 +0000
48+++ examples/demo-shell/demo_shell.cpp 2013-08-07 07:20:37 +0000
49@@ -92,8 +92,10 @@
50 auto wm = std::make_shared<me::WindowManager>();
51 me::DemoServerConfiguration config(argc, argv, {wm});
52
53- mir::run_mir(config, [&config, &wm](mir::DisplayServer&)
54+ mir::run_mir(config, [&config, &wm](mir::DisplayServer& display_server)
55 {
56+ config.set_server(display_server);
57+
58 // We use this strange two stage initialization to avoid a circular dependency between the EventFilters
59 // and the SessionStore
60 wm->set_focus_controller(config.the_focus_controller());
61
62=== modified file 'examples/demo_input_filter.cpp'
63--- examples/demo_input_filter.cpp 2013-08-06 10:39:53 +0000
64+++ examples/demo_input_filter.cpp 2013-08-07 07:20:37 +0000
65@@ -74,7 +74,7 @@
66 {
67 DemoServerConfiguration config(argc, argv);
68
69- mir::run_mir(config, [](mir::DisplayServer&) {/* empty init */});
70+ mir::run_mir(config, [&](mir::DisplayServer& display_server) { config.set_server(display_server); });
71 return 0;
72 }
73 catch (mir::AbnormalExit const& error)
74
75=== modified file 'examples/demo_server.cpp'
76--- examples/demo_server.cpp 2013-08-01 11:05:45 +0000
77+++ examples/demo_server.cpp 2013-08-07 07:20:37 +0000
78@@ -17,6 +17,7 @@
79 */
80
81 #include "mir/run_mir.h"
82+#include "mir/display_server.h"
83 #include "mir/report_exception.h"
84 #include "server_configuration.h"
85
86@@ -27,7 +28,7 @@
87 {
88 mir::examples::ServerConfiguration config(argc, argv);
89
90- run_mir(config, [](mir::DisplayServer&) {/* empty init */});
91+ run_mir(config, [&](mir::DisplayServer& display_server) { config.set_server(display_server); });
92 return 0;
93 }
94 catch (...)
95
96=== modified file 'examples/render_surfaces.cpp'
97--- examples/render_surfaces.cpp 2013-08-01 11:05:45 +0000
98+++ examples/render_surfaces.cpp 2013-08-07 07:20:37 +0000
99@@ -464,8 +464,10 @@
100 ///\internal [main_tag]
101 RenderSurfacesServerConfiguration conf{argc, argv};
102
103- mir::run_mir(conf, [&](mir::DisplayServer&)
104+ mir::run_mir(conf, [&](mir::DisplayServer& display_server)
105 {
106+ conf.set_server(display_server);
107+
108 conf.create_surfaces();
109
110 cursor = conf.the_cursor();
111
112=== modified file 'examples/server_configuration.cpp'
113--- examples/server_configuration.cpp 2013-08-01 11:05:45 +0000
114+++ examples/server_configuration.cpp 2013-08-07 07:20:37 +0000
115@@ -17,13 +17,17 @@
116 */
117
118 #include "server_configuration.h"
119+#include "mir/display_server.h"
120 #include "mir/graphics/display_configuration_policy.h"
121 #include "mir/graphics/display_configuration.h"
122+#include "mir/input/composite_event_filter.h"
123
124 #include <string>
125+#include <linux/input.h>
126
127 namespace me = mir::examples;
128 namespace mg = mir::graphics;
129+namespace mi = mir::input;
130 namespace geom = mir::geometry;
131
132 namespace
133@@ -88,6 +92,21 @@
134
135 }
136
137+bool me::QuitFilter::handle(MirEvent const& event)
138+{
139+ if (event.type == mir_event_type_key &&
140+ event.key.action == mir_key_action_down &&
141+ (event.key.modifiers & mir_key_modifier_alt) &&
142+ (event.key.modifiers & mir_key_modifier_ctrl) &&
143+ event.key.scan_code == KEY_BACKSPACE)
144+ {
145+ server_ptr->stop();
146+ return true;
147+ }
148+
149+ return false;
150+}
151+
152 me::ServerConfiguration::ServerConfiguration(int argc, char const** argv)
153 : DefaultServerConfiguration(argc, argv)
154 {
155@@ -114,3 +133,12 @@
156 return DefaultServerConfiguration::the_display_configuration_policy();
157 });
158 }
159+
160+std::shared_ptr<mi::CompositeEventFilter>
161+me::ServerConfiguration::the_composite_event_filter()
162+{
163+ auto composite_filter = mir::DefaultServerConfiguration::the_composite_event_filter();
164+ composite_filter->prepend(quit_filter);
165+
166+ return composite_filter;
167+}
168
169=== modified file 'examples/server_configuration.h'
170--- examples/server_configuration.h 2013-08-01 11:05:45 +0000
171+++ examples/server_configuration.h 2013-08-07 07:20:37 +0000
172@@ -20,18 +20,43 @@
173 #define MIR_EXAMPLES_SERVER_CONFIGURATION_H_
174
175 #include "mir/default_server_configuration.h"
176+#include "mir/input/event_filter.h"
177
178 namespace mir
179 {
180+class DisplayServer;
181+
182 namespace examples
183 {
184+class QuitFilter : public mir::input::EventFilter
185+{
186+public:
187+ bool handle(MirEvent const& event) override;
188+
189+ void set_server(DisplayServer& display_server)
190+ {
191+ server_ptr = &display_server;
192+ }
193+
194+private:
195+ mir::DisplayServer *server_ptr;
196+};
197
198 class ServerConfiguration : public DefaultServerConfiguration
199 {
200 public:
201 ServerConfiguration(int argc, char const** argv);
202
203+ void set_server(DisplayServer& display_server)
204+ {
205+ quit_filter->set_server(display_server);
206+ }
207+
208 std::shared_ptr<graphics::DisplayConfigurationPolicy> the_display_configuration_policy() override;
209+ std::shared_ptr<input::CompositeEventFilter> the_composite_event_filter() override;
210+
211+private:
212+ std::shared_ptr<QuitFilter> quit_filter;
213 };
214
215 }

Subscribers

People subscribed via source and target branches