Mir

Merge lp:~alan-griffiths/mir/tweak-cursor-configuration into lp:mir

Proposed by Alan Griffiths on 2015-10-06
Status: Merged
Approved by: Daniel van Vugt on 2015-10-07
Approved revision: 2998
Merged at revision: 2999
Proposed branch: lp:~alan-griffiths/mir/tweak-cursor-configuration
Merge into: lp:mir
Diff against target: 209 lines (+41/-34)
8 files modified
include/server/mir/server.h (+3/-3)
src/include/server/mir/default_server_configuration.h (+1/-0)
src/server/graphics/default_configuration.cpp (+26/-19)
src/server/graphics/nested/display.cpp (+5/-7)
src/server/server.cpp (+1/-1)
src/server/symbols.map (+3/-1)
tests/acceptance-tests/test_nested_mir.cpp (+1/-2)
tests/acceptance-tests/throwback/test_client_cursor_api.cpp (+1/-1)
To merge this branch: bzr merge lp:~alan-griffiths/mir/tweak-cursor-configuration
Reviewer Review Type Date Requested Status
Kevin DuBois (community) Approve on 2015-10-06
Andreas Pokorny (community) 2015-10-06 Approve on 2015-10-06
PS Jenkins bot continuous-integration Approve on 2015-10-06
Review via email: mp+273512@code.launchpad.net

Commit Message

server: replace Server::override_the_cursor() with Server::wrap_cursor()

Description of the Change

server: replace Server::override_the_cursor() with Server::wrap_cursor()

It is necessary for servers to wrap rather than replace cursors because they need access to the underlying hardware or nested cursor.

There are some tests coming that need this API change, but I want this to be ready before we branch 0.17 to avoid publishing Server::override_the_cursor().

There's also a bit of code tidy up and documentation of why things are not done the "obvious" way (of implementing nested::Display::create_hardware_cursor().

To post a comment you must log in.
Alan Griffiths (alan-griffiths) wrote :

*
GLib:ERROR:/build/buildd/glib2.0-2.44.1/./glib/ghash.c:373:g_hash_table_lookup_node: assertion failed: (hash_table->ref_count > 0)
/bin/bash: line 1: 6398 Aborted mir_demo_server --test-client /usr/bin/mir_demo_client_basic
+ mir_rc=-1

Concerning, but appears unrelated.

2998. By Alan Griffiths on 2015-10-06

merge lp:mir

Andreas Pokorny (andreas-pokorny) wrote :

> *
> GLib:ERROR:/build/buildd/glib2.0-2.44.1/./glib/ghash.c:373:g_hash_table_lookup
> _node: assertion failed: (hash_table->ref_count > 0)
> /bin/bash: line 1: 6398 Aborted mir_demo_server --test-client
> /usr/bin/mir_demo_client_basic
> + mir_rc=-1
>
> Concerning, but appears unrelated.

Yes .. back to asio main loop? or should we try to build one with dispatchables?.. (and with a simpler alarm interface)

Andreas Pokorny (andreas-pokorny) wrote :

yes makes sense

review: Approve
Kevin DuBois (kdub) wrote :

lgtm

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'include/server/mir/server.h'
2--- include/server/mir/server.h 2015-09-30 07:19:48 +0000
3+++ include/server/mir/server.h 2015-10-06 13:26:24 +0000
4@@ -224,9 +224,6 @@
5 /// Sets an override functor for creating the compositor.
6 void override_the_compositor(Builder<compositor::Compositor> const& compositor_builder);
7
8- /// Sets an override functor for creating the cursor.
9- void override_the_cursor(Builder<graphics::Cursor> const& cursor_builder);
10-
11 /// Sets an override functor for creating the cursor images.
12 void override_the_cursor_images(Builder<input::CursorImages> const& cursor_images_builder);
13
14@@ -282,6 +279,9 @@
15 /// Each of the wrap functions takes a wrapper functor of the same form
16 template<typename T> using Wrapper = std::function<std::shared_ptr<T>(std::shared_ptr<T> const&)>;
17
18+ /// Sets a wrapper functor for creating the cursor.
19+ void wrap_cursor(Wrapper<graphics::Cursor> const& cursor_builder);
20+
21 /// Sets a wrapper functor for creating the cursor listener.
22 void wrap_cursor_listener(Wrapper<input::CursorListener> const& wrapper);
23
24
25=== modified file 'src/include/server/mir/default_server_configuration.h'
26--- src/include/server/mir/default_server_configuration.h 2015-09-30 07:19:48 +0000
27+++ src/include/server/mir/default_server_configuration.h 2015-10-06 13:26:24 +0000
28@@ -220,6 +220,7 @@
29 * @{ */
30 virtual std::shared_ptr<graphics::DisplayReport> the_display_report();
31 virtual std::shared_ptr<graphics::Cursor> the_cursor();
32+ virtual std::shared_ptr<graphics::Cursor> wrap_cursor(std::shared_ptr<graphics::Cursor> const& wrapped);
33 virtual std::shared_ptr<graphics::CursorImage> the_default_cursor_image();
34 virtual std::shared_ptr<input::CursorImages> the_cursor_images();
35 virtual std::shared_ptr<graphics::DisplayConfigurationReport> the_display_configuration_report();
36
37=== modified file 'src/server/graphics/default_configuration.cpp'
38--- src/server/graphics/default_configuration.cpp 2015-10-05 08:19:39 +0000
39+++ src/server/graphics/default_configuration.cpp 2015-10-06 13:26:24 +0000
40@@ -168,31 +168,38 @@
41 return cursor(
42 [this]() -> std::shared_ptr<mg::Cursor>
43 {
44+ // In nested mode we delegate cursor presentation to the host
45 if (the_options()->is_set(options::host_socket_opt))
46- return std::make_shared<mgn::Cursor>(the_host_connection(), the_default_cursor_image());
47-
48- // We try to create a hardware cursor, if this fails we use a software cursor
49- auto hardware_cursor = the_display()->create_hardware_cursor(the_default_cursor_image());
50- if (hardware_cursor)
51+ {
52+ mir::log_info("Using nested cursor");
53+ return wrap_cursor(std::make_shared<mgn::Cursor>(the_host_connection(), the_default_cursor_image()));
54+ }
55+
56+ // Otherwise we try to create a hardware cursor
57+ if (auto hardware_cursor = the_display()->create_hardware_cursor(the_default_cursor_image()))
58 {
59 mir::log_info("Using hardware cursor");
60- return hardware_cursor;
61- }
62- else
63- {
64- mir::log_info("Using software cursor");
65-
66- auto const cursor = std::make_shared<mg::SoftwareCursor>(
67- the_buffer_allocator(),
68- the_input_scene());
69-
70- cursor->show(*the_default_cursor_image());
71-
72- return cursor;
73- }
74+ return wrap_cursor(hardware_cursor);
75+ }
76+
77+ // If other options fail we use a software cursor
78+ mir::log_info("Using software cursor");
79+ auto const cursor = wrap_cursor(std::make_shared<mg::SoftwareCursor>(
80+ the_buffer_allocator(),
81+ the_input_scene()));
82+
83+ cursor->show(*the_default_cursor_image());
84+
85+ return cursor;
86 });
87 }
88
89+std::shared_ptr<mg::Cursor>
90+mir::DefaultServerConfiguration::wrap_cursor(std::shared_ptr<mg::Cursor> const& wrapped)
91+{
92+ return wrapped;
93+}
94+
95 auto mir::DefaultServerConfiguration::the_host_connection()
96 -> std::shared_ptr<graphics::nested::HostConnection>
97 {
98
99=== modified file 'src/server/graphics/nested/display.cpp'
100--- src/server/graphics/nested/display.cpp 2015-06-24 08:48:36 +0000
101+++ src/server/graphics/nested/display.cpp 2015-10-06 13:26:24 +0000
102@@ -273,20 +273,18 @@
103
104 void mgn::Display::pause()
105 {
106- // TODO Do we "own" the cursor or does the host mir?
107- // If we "own" the cursor then we need to hide it
108+ // No need to do anything
109 }
110
111 void mgn::Display::resume()
112 {
113- // TODO Do we "own" the cursor or does the host mir?
114- // TODO If we "own" the cursor then we need to restore it
115+ // No need to do anything
116 }
117
118-auto mgn::Display::create_hardware_cursor(std::shared_ptr<mg::CursorImage> const& /* initial image */)->std::shared_ptr<Cursor>
119+auto mgn::Display::create_hardware_cursor(std::shared_ptr<mg::CursorImage> const& /*initial_image*/) -> std::shared_ptr<mg::Cursor>
120 {
121- // TODO Do we "own" the cursor or does the host mir?
122- return std::shared_ptr<Cursor>();
123+ BOOST_THROW_EXCEPTION(std::logic_error("Initialization loop: we already need the Cursor when creating the Display"));
124+ // So we can't do this: return std::make_shared<Cursor>(connection, initial_image);
125 }
126
127 std::unique_ptr<mg::GLContext> mgn::Display::create_gl_context()
128
129=== modified file 'src/server/server.cpp'
130--- src/server/server.cpp 2015-10-06 04:45:25 +0000
131+++ src/server/server.cpp 2015-10-06 13:26:24 +0000
132@@ -43,6 +43,7 @@
133 namespace mo = mir::options;
134
135 #define FOREACH_WRAPPER(MACRO)\
136+ MACRO(cursor)\
137 MACRO(cursor_listener)\
138 MACRO(display_buffer_compositor_factory)\
139 MACRO(display_configuration_policy)\
140@@ -50,7 +51,6 @@
141
142 #define FOREACH_OVERRIDE(MACRO)\
143 MACRO(compositor)\
144- MACRO(cursor)\
145 MACRO(cursor_images)\
146 MACRO(display_buffer_compositor_factory)\
147 MACRO(display_configuration_report)\
148
149=== modified file 'src/server/symbols.map'
150--- src/server/symbols.map 2015-09-30 07:19:48 +0000
151+++ src/server/symbols.map 2015-10-06 13:26:24 +0000
152@@ -145,7 +145,7 @@
153 mir::Server::open_prompt_socket*;
154 mir::Server::override_the_application_not_responding_detector*;
155 mir::Server::override_the_compositor*;
156- mir::Server::override_the_cursor*;
157+ mir::Server::override_the_cursor_images*;
158 mir::Server::override_the_display_buffer_compositor_factory*;
159 mir::Server::override_the_display_configuration_report*;
160 mir::Server::override_the_gl_config*;
161@@ -199,6 +199,7 @@
162 mir::Server::the_surface_coordinator*;
163 mir::Server::the_surface_factory*;
164 mir::Server::the_touch_visualizer*;
165+ mir::Server::wrap_cursor*;
166 mir::Server::wrap_cursor_listener*;
167 mir::Server::wrap_display_buffer_compositor_factory*;
168 mir::Server::wrap_display_configuration_policy*;
169@@ -684,6 +685,7 @@
170 mir::DefaultServerConfiguration::the_surface_stack_model*;
171 mir::DefaultServerConfiguration::the_touch_visualizer*;
172 mir::DefaultServerConfiguration::the_window_manager_builder*;
173+ mir::DefaultServerConfiguration::wrap_cursor*;
174 mir::DefaultServerConfiguration::wrap_cursor_listener*;
175 mir::DefaultServerConfiguration::wrap_display_buffer_compositor_factory*;
176 mir::DefaultServerConfiguration::wrap_display_configuration_policy*;
177
178=== modified file 'tests/acceptance-tests/test_nested_mir.cpp'
179--- tests/acceptance-tests/test_nested_mir.cpp 2015-10-05 08:59:41 +0000
180+++ tests/acceptance-tests/test_nested_mir.cpp 2015-10-06 13:26:24 +0000
181@@ -159,7 +159,7 @@
182 server.override_the_display_configuration_report([this]
183 { return the_mock_display_configuration_report(); });
184
185- server.override_the_cursor([this] { return the_mock_cursor(); });
186+ server.wrap_cursor([this](std::shared_ptr<mg::Cursor> const&) { return the_mock_cursor(); });
187
188 mtf::HeadlessInProcessServer::SetUp();
189 }
190@@ -495,7 +495,6 @@
191 mir_surface_apply_spec(surface, spec);
192 mir_surface_spec_release(spec);
193
194- nested_mir.server.the_cursor()->move_to({489, 9});
195 server.the_cursor_listener()->cursor_moved_to(489, 9);
196
197 auto stream = mir_connection_create_buffer_stream_sync(
198
199=== modified file 'tests/acceptance-tests/throwback/test_client_cursor_api.cpp'
200--- tests/acceptance-tests/throwback/test_client_cursor_api.cpp 2015-10-02 21:04:21 +0000
201+++ tests/acceptance-tests/throwback/test_client_cursor_api.cpp 2015-10-06 13:26:24 +0000
202@@ -227,7 +227,7 @@
203 mock_egl.provide_egl_extensions();
204 mock_egl.provide_stub_platform_buffer_swapping();
205
206- server.override_the_cursor([this]() { return mt::fake_shared(cursor); });
207+ server.wrap_cursor([this](std::shared_ptr<mg::Cursor> const&) { return mt::fake_shared(cursor); });
208
209 server.override_the_cursor_images([]() { return std::make_shared<NamedCursorImages>(); });
210

Subscribers

People subscribed via source and target branches