Mir

Merge lp:~alan-griffiths/mir/add-mir_surface_spec_set_shell_chrome into lp:mir

Proposed by Alan Griffiths
Status: Merged
Approved by: Alan Griffiths
Approved revision: no longer in the source branch.
Merged at revision: 3267
Proposed branch: lp:~alan-griffiths/mir/add-mir_surface_spec_set_shell_chrome
Merge into: lp:mir
Diff against target: 252 lines (+108/-2)
12 files modified
include/client/mir_toolkit/mir_surface.h (+10/-0)
include/common/mir_toolkit/common.h (+9/-0)
include/server/mir/scene/surface_creation_parameters.h (+1/-0)
include/server/mir/shell/surface_specification.h (+1/-0)
src/client/mir_connection.cpp (+1/-0)
src/client/mir_surface.cpp (+1/-0)
src/client/mir_surface.h (+1/-0)
src/client/mir_surface_api.cpp (+6/-0)
src/client/symbols.map (+1/-2)
src/protobuf/mir_protobuf.proto (+2/-0)
src/server/frontend/session_mediator.cpp (+2/-0)
tests/acceptance-tests/test_custom_window_management.cpp (+73/-0)
To merge this branch: bzr merge lp:~alan-griffiths/mir/add-mir_surface_spec_set_shell_chrome
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Alberto Aguirre (community) Approve
Brandon Schaefer (community) Approve
Mir CI Bot continuous-integration Needs Fixing
Nick Dedekind (community) Approve
Michał Sawicz conceptual Approve
Review via email: mp+283818@code.launchpad.net

Commit message

client API, shell: Add an API to request a low-chrome display mode

Description of the change

client API, shell: Add an API to request a low-chrome display mode

The server may interpret this by, for example, hiding indicators

To post a comment you must log in.
Revision history for this message
Michał Sawicz (saviq) :
review: Approve (conceptual)
Revision history for this message
Nick Dedekind (nick-dedekind) :
review: Approve
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3267
https://mir-jenkins.ubuntu.com/job/mir-ci/152/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/152/console

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

review: Needs Fixing (continuous-integration)
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

   repeated Rectangle input_shape = 22;
+ optional int32 shell_chrome = 24;

23 here? Or 24 to be consistent with the other one?

- local:
- *;

As long as there is a different local:*; in client which IIRC theres hundreds.

Also not 100% what *chrome* is but code looks fine to me

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

Good, separate from window state.

LGTM.

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

PASSED: Continuous integration, rev:3267
http://jenkins.qa.ubuntu.com/job/mir-ci/6124/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-android-vivid-i386-build/5679
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-clang-vivid-amd64-build/4586
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-vivid-touch/5635
    FAILURE: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-xenial-touch/333/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/448
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/448/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/448
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/448/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5632
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5632/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-touch/8067
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/27016
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/329
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/329/artifact/work/output/*zip*/output.zip
    FAILURE: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-xenial-touch/185/console
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/27019

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/mir-ci/6124/rebuild

review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'include/client/mir_toolkit/mir_surface.h'
2--- include/client/mir_toolkit/mir_surface.h 2016-01-20 23:59:18 +0000
3+++ include/client/mir_toolkit/mir_surface.h 2016-01-25 14:54:02 +0000
4@@ -499,6 +499,16 @@
5 mir_surface_event_callback callback,
6 void* context);
7
8+
9+/**
10+ * Ask the shell to customize "chrome" for this surface.
11+ * For example, on the phone hide indicators when this surface is active.
12+ *
13+ * \param [in] spec The spec to accumulate the request in.
14+ * \param [in] style The requested level of "chrome"
15+ */
16+void mir_surface_spec_set_shell_chrome(MirSurfaceSpec* spec, MirShellChrome style);
17+
18 /**
19 * Set the event handler to be called when events arrive for a surface.
20 * \warning event_handler could be called from another thread. You must do
21
22=== modified file 'include/common/mir_toolkit/common.h'
23--- include/common/mir_toolkit/common.h 2016-01-20 23:59:18 +0000
24+++ include/common/mir_toolkit/common.h 2016-01-25 14:54:02 +0000
25@@ -204,6 +204,15 @@
26 mir_form_factor_projector,
27 } MirFormFactor;
28
29+/**
30+ * Shell chrome
31+ */
32+typedef enum MirShellChrome
33+{
34+ mir_shell_chrome_normal,
35+ mir_shell_chrome_low,
36+} MirShellChrome;
37+
38 /**@}*/
39
40 #endif
41
42=== modified file 'include/server/mir/scene/surface_creation_parameters.h'
43--- include/server/mir/scene/surface_creation_parameters.h 2016-01-20 23:59:18 +0000
44+++ include/server/mir/scene/surface_creation_parameters.h 2016-01-25 14:54:02 +0000
45@@ -100,6 +100,7 @@
46 mir::optional_value<shell::SurfaceAspectRatio> max_aspect;
47
48 mir::optional_value<std::vector<geometry::Rectangle>> input_shape;
49+ mir::optional_value<MirShellChrome> shell_chrome;
50 };
51
52 bool operator==(const SurfaceCreationParameters& lhs, const SurfaceCreationParameters& rhs);
53
54=== modified file 'include/server/mir/shell/surface_specification.h'
55--- include/server/mir/shell/surface_specification.h 2016-01-20 23:59:18 +0000
56+++ include/server/mir/shell/surface_specification.h 2016-01-25 14:54:02 +0000
57@@ -81,6 +81,7 @@
58 //
59 // it also has size instead of width + height
60 // Maybe SurfaceCreationParameters /HasA/ SurfaceSpecification?
61+ mir::optional_value<MirShellChrome> shell_chrome;
62 };
63 }
64 }
65
66=== modified file 'src/client/mir_connection.cpp'
67--- src/client/mir_connection.cpp 2016-01-20 23:59:18 +0000
68+++ src/client/mir_connection.cpp 2016-01-25 14:54:02 +0000
69@@ -117,6 +117,7 @@
70 SERIALIZE_OPTION_IF_SET(max_height);
71 SERIALIZE_OPTION_IF_SET(width_inc);
72 SERIALIZE_OPTION_IF_SET(height_inc);
73+ SERIALIZE_OPTION_IF_SET(shell_chrome);
74 // min_aspect is a special case (below)
75 // max_aspect is a special case (below)
76
77
78=== modified file 'src/client/mir_surface.cpp'
79--- src/client/mir_surface.cpp 2016-01-23 03:16:06 +0000
80+++ src/client/mir_surface.cpp 2016-01-25 14:54:02 +0000
81@@ -555,6 +555,7 @@
82 COPY_IF_SET(max_height);
83 COPY_IF_SET(width_inc);
84 COPY_IF_SET(height_inc);
85+ COPY_IF_SET(shell_chrome);
86 // min_aspect is a special case (below)
87 // max_aspect is a special case (below)
88 #undef COPY_IF_SET
89
90=== modified file 'src/client/mir_surface.h'
91--- src/client/mir_surface.h 2016-01-20 23:59:18 +0000
92+++ src/client/mir_surface.h 2016-01-25 14:54:02 +0000
93@@ -122,6 +122,7 @@
94 void* context;
95 };
96 mir::optional_value<EventHandler> event_handler;
97+ mir::optional_value<MirShellChrome> shell_chrome;
98 };
99
100 struct MirPersistentId
101
102=== modified file 'src/client/mir_surface_api.cpp'
103--- src/client/mir_surface_api.cpp 2016-01-20 23:59:18 +0000
104+++ src/client/mir_surface_api.cpp 2016-01-25 14:54:02 +0000
105@@ -224,6 +224,12 @@
106 spec->event_handler = MirSurfaceSpec::EventHandler{callback, context};
107 }
108
109+void mir_surface_spec_set_shell_chrome(MirSurfaceSpec* spec, MirShellChrome style)
110+{
111+ mir::require(spec);
112+ spec->shell_chrome = style;
113+}
114+
115 void mir_surface_spec_release(MirSurfaceSpec* spec)
116 {
117 delete spec;
118
119=== modified file 'src/client/symbols.map'
120--- src/client/symbols.map 2016-01-23 03:16:06 +0000
121+++ src/client/symbols.map 2016-01-25 14:54:02 +0000
122@@ -212,8 +212,7 @@
123 mir_connection_get_graphics_module;
124 mir_keymap_event_get_keymap_buffer;
125 mir_keymap_event_get_device_id;
126- local:
127- *;
128+ mir_surface_spec_set_shell_chrome;
129 } MIR_CLIENT_9v18;
130
131 MIR_CLIENT_DETAIL_9 {
132
133=== modified file 'src/protobuf/mir_protobuf.proto'
134--- src/protobuf/mir_protobuf.proto 2016-01-20 23:59:18 +0000
135+++ src/protobuf/mir_protobuf.proto 2016-01-25 14:54:02 +0000
136@@ -38,6 +38,7 @@
137
138 optional PersistentSurfaceId parent_persistent_id = 21;
139 repeated Rectangle input_shape = 22;
140+ optional int32 shell_chrome = 24;
141 }
142
143 message SurfaceAspectRatio
144@@ -76,6 +77,7 @@
145
146 optional PersistentSurfaceId parent_persistent_id = 22;
147 repeated Rectangle input_shape = 23;
148+ optional int32 shell_chrome = 24;
149 }
150
151 message StreamConfiguration {
152
153=== modified file 'src/server/frontend/session_mediator.cpp'
154--- src/server/frontend/session_mediator.cpp 2016-01-20 23:59:18 +0000
155+++ src/server/frontend/session_mediator.cpp 2016-01-25 14:54:02 +0000
156@@ -269,6 +269,7 @@
157 COPY_IF_SET(max_height);
158 COPY_IF_SET(width_inc);
159 COPY_IF_SET(height_inc);
160+ COPY_IF_SET(shell_chrome);
161
162 #undef COPY_IF_SET
163
164@@ -568,6 +569,7 @@
165 COPY_IF_SET(max_height);
166 COPY_IF_SET(width_inc);
167 COPY_IF_SET(height_inc);
168+ COPY_IF_SET(shell_chrome);
169 // min_aspect is a special case (below)
170 // max_aspect is a special case (below)
171
172
173=== modified file 'tests/acceptance-tests/test_custom_window_management.cpp'
174--- tests/acceptance-tests/test_custom_window_management.cpp 2016-01-20 23:59:18 +0000
175+++ tests/acceptance-tests/test_custom_window_management.cpp 2016-01-25 14:54:02 +0000
176@@ -287,3 +287,76 @@
177 for (auto const surface : client_surface)
178 mir_surface_release_sync(surface);
179 }
180+
181+TEST_F(CustomWindowManagement, create_low_chrome_surface_from_spec)
182+{
183+ start_server();
184+
185+ auto connection = mir_connect_sync(new_connection().c_str(), __PRETTY_FUNCTION__);
186+
187+ int const width{800}, height{600};
188+ MirPixelFormat const format{mir_pixel_format_bgr_888};
189+ auto surface_spec = mir_connection_create_spec_for_normal_surface(connection,
190+ width, height,
191+ format);
192+
193+ mir_surface_spec_set_shell_chrome(surface_spec, mir_shell_chrome_low);
194+
195+ auto const check_add_surface = [](
196+ std::shared_ptr<ms::Session> const& session,
197+ ms::SurfaceCreationParameters const& params,
198+ std::function<mf::SurfaceId(std::shared_ptr<ms::Session> const& session, ms::SurfaceCreationParameters const& params)> const& build)
199+ {
200+ EXPECT_TRUE(params.shell_chrome.is_set());
201+ return build(session, params);
202+ };
203+
204+ EXPECT_CALL(window_manager, add_surface(_,_,_)).WillOnce(Invoke(check_add_surface));
205+
206+ auto surface = mir_surface_create_sync(surface_spec);
207+ mir_surface_spec_release(surface_spec);
208+
209+ mir_surface_release_sync(surface);
210+ mir_connection_release(connection);
211+}
212+
213+TEST_F(CustomWindowManagement, apply_low_chrome_to_surface)
214+{
215+ start_server();
216+
217+ auto connection = mir_connect_sync(new_connection().c_str(), __PRETTY_FUNCTION__);
218+
219+ int const width{800}, height{600};
220+ MirPixelFormat const format{mir_pixel_format_bgr_888};
221+ auto surface_spec = mir_connection_create_spec_for_normal_surface(connection,
222+ width, height,
223+ format);
224+
225+ auto surface = mir_surface_create_sync(surface_spec);
226+ mir_surface_spec_release(surface_spec);
227+
228+ surface_spec = mir_connection_create_spec_for_changes(connection);
229+
230+ mt::Signal received;
231+
232+ mir_surface_spec_set_shell_chrome(surface_spec, mir_shell_chrome_low);
233+
234+ auto const check_apply_surface = [&received](
235+ std::shared_ptr<ms::Session> const&,
236+ std::shared_ptr<ms::Surface> const&,
237+ msh::SurfaceSpecification const& spec)
238+ {
239+ EXPECT_TRUE(spec.shell_chrome.is_set());
240+ received.raise();
241+ };
242+
243+ EXPECT_CALL(window_manager, modify_surface(_,_,_)).WillOnce(Invoke(check_apply_surface));
244+
245+ mir_surface_apply_spec(surface, surface_spec);
246+ mir_surface_spec_release(surface_spec);
247+
248+ EXPECT_TRUE(received.wait_for(400ms));
249+
250+ mir_surface_release_sync(surface);
251+ mir_connection_release(connection);
252+}

Subscribers

People subscribed via source and target branches