Mir

Merge lp:~albaguirre/mir/fix-1483909 into lp:mir

Proposed by Alberto Aguirre
Status: Merged
Merged at revision: 2838
Proposed branch: lp:~albaguirre/mir/fix-1483909
Merge into: lp:mir
Diff against target: 252 lines (+149/-3)
5 files modified
examples/server_example_canonical_window_manager.cpp (+25/-1)
examples/server_example_canonical_window_manager.h (+1/-0)
src/include/server/mir/shell/canonical_window_manager.h (+1/-0)
src/server/shell/canonical_window_manager.cpp (+25/-1)
tests/acceptance-tests/test_surface_modifications.cpp (+97/-1)
To merge this branch: bzr merge lp:~albaguirre/mir/fix-1483909
Reviewer Review Type Date Requested Status
Kevin DuBois (community) Approve
PS Jenkins bot (community) continuous-integration Needs Fixing
Alan Griffiths Approve
Chris Halse Rogers Approve
Review via email: mp+267722@code.launchpad.net

Commit message

canonical window manager: restore surface visibility
(LP: #1483909)

surface->show() is now called by the window manager when appropriate.

Description of the change

When I modified BasicSurface::configure(mir_surface_attrib_state, state)to no longer modify its visibility state I forgot to actually make the window manager handle the restoration part.

I also addressed the the mir_surface_spec_set_state/mir_surface_apply_spec path as it did not previously propagate surface state changes.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Chris Halse Rogers (raof) wrote :

Looks sensible to me.

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

LGTM

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
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 'examples/server_example_canonical_window_manager.cpp'
2--- examples/server_example_canonical_window_manager.cpp 2015-07-27 07:24:50 +0000
3+++ examples/server_example_canonical_window_manager.cpp 2015-08-11 22:18:03 +0000
4@@ -181,6 +181,19 @@
5 }
6 }
7
8+bool me::CanonicalSurfaceInfoCopy::is_visible() const
9+{
10+ switch (state)
11+ {
12+ case mir_surface_state_hidden:
13+ case mir_surface_state_minimized:
14+ return false;
15+ default:
16+ break;
17+ }
18+ return true;
19+}
20+
21
22 me::CanonicalWindowManagerPolicyCopy::CanonicalWindowManagerPolicyCopy(
23 Tools* const tools,
24@@ -555,6 +568,12 @@
25
26 apply_resize(surface, surface_info.titlebar, top_left, new_size);
27 }
28+
29+ if (modifications.state.is_set())
30+ {
31+ auto const state = handle_set_state(surface, modifications.state.value());
32+ surface->configure(mir_surface_attrib_state, state);
33+ }
34 }
35
36 void me::CanonicalWindowManagerPolicyCopy::handle_delete_surface(std::shared_ptr<ms::Session> const& session, std::weak_ptr<ms::Surface> const& surface)
37@@ -682,7 +701,12 @@
38 // TODO some sensible layout rules.
39 move_tree(surface, movement);
40
41- return info.state = value;
42+ info.state = value;
43+
44+ if (info.is_visible())
45+ surface->show();
46+
47+ return info.state;
48 }
49
50 void me::CanonicalWindowManagerPolicyCopy::drag(Point cursor)
51
52=== modified file 'examples/server_example_canonical_window_manager.h'
53--- examples/server_example_canonical_window_manager.h 2015-06-23 06:49:01 +0000
54+++ examples/server_example_canonical_window_manager.h 2015-08-11 22:18:03 +0000
55@@ -50,6 +50,7 @@
56 bool can_morph_to(MirSurfaceType new_type) const;
57 bool must_have_parent() const;
58 bool must_not_have_parent() const;
59+ bool is_visible() const;
60
61 void constrain_resize(
62 std::shared_ptr<scene::Surface> const& surface,
63
64=== modified file 'src/include/server/mir/shell/canonical_window_manager.h'
65--- src/include/server/mir/shell/canonical_window_manager.h 2015-06-26 08:00:59 +0000
66+++ src/include/server/mir/shell/canonical_window_manager.h 2015-08-11 22:18:03 +0000
67@@ -46,6 +46,7 @@
68 bool can_morph_to(MirSurfaceType new_type) const;
69 bool must_have_parent() const;
70 bool must_not_have_parent() const;
71+ bool is_visible() const;
72
73 void constrain_resize(
74 std::shared_ptr<scene::Surface> const& surface,
75
76=== modified file 'src/server/shell/canonical_window_manager.cpp'
77--- src/server/shell/canonical_window_manager.cpp 2015-07-27 07:24:50 +0000
78+++ src/server/shell/canonical_window_manager.cpp 2015-08-11 22:18:03 +0000
79@@ -166,6 +166,19 @@
80 return ::must_not_have_parent(type);
81 }
82
83+bool msh::CanonicalSurfaceInfo::is_visible() const
84+{
85+ switch (state)
86+ {
87+ case mir_surface_state_hidden:
88+ case mir_surface_state_minimized:
89+ return false;
90+ default:
91+ break;
92+ }
93+ return true;
94+}
95+
96
97 msh::CanonicalWindowManagerPolicy::CanonicalWindowManagerPolicy(
98 Tools* const tools,
99@@ -468,6 +481,12 @@
100
101 if (modifications.input_shape.is_set())
102 surface->set_input_region(modifications.input_shape.value());
103+
104+ if (modifications.state.is_set())
105+ {
106+ auto const state = handle_set_state(surface, modifications.state.value());
107+ surface->configure(mir_surface_attrib_state, state);
108+ }
109 }
110
111 void msh::CanonicalWindowManagerPolicy::handle_delete_surface(std::shared_ptr<ms::Session> const& session, std::weak_ptr<ms::Surface> const& surface)
112@@ -573,7 +592,12 @@
113 // TODO some sensible layout rules.
114 move_tree(surface, movement);
115
116- return info.state = value;
117+ info.state = value;
118+
119+ if (info.is_visible())
120+ surface->show();
121+
122+ return info.state;
123 }
124
125 void msh::CanonicalWindowManagerPolicy::drag(Point cursor)
126
127=== modified file 'tests/acceptance-tests/test_surface_modifications.cpp'
128--- tests/acceptance-tests/test_surface_modifications.cpp 2015-06-26 08:00:59 +0000
129+++ tests/acceptance-tests/test_surface_modifications.cpp 2015-08-11 22:18:03 +0000
130@@ -46,6 +46,7 @@
131 public:
132 MOCK_METHOD1(renamed, void(char const*));
133 MOCK_METHOD1(resized_to, void(Size const& size));
134+ MOCK_METHOD1(hidden_set_to, void(bool));
135 };
136
137 struct SurfaceModifications : mtf::ConnectedClientWithASurface
138@@ -135,7 +136,7 @@
139
140 MirInputDeviceId const device_id = MirInputDeviceId(7);
141 std::chrono::nanoseconds const timestamp = std::chrono::nanoseconds(39);
142- MockSurfaceObserver surface_observer;
143+ NiceMock<MockSurfaceObserver> surface_observer;
144 std::weak_ptr<ms::Surface> shell_surface;
145 };
146
147@@ -149,6 +150,30 @@
148 return Height(value) == arg.height;
149 }
150
151+struct StatePair
152+{
153+ MirSurfaceState from;
154+ MirSurfaceState to;
155+
156+ friend std::ostream& operator<<(std::ostream& out, StatePair const& types)
157+ { return out << "from:" << types.from << ", to:" << types.to; }
158+};
159+
160+bool is_visible(MirSurfaceState state)
161+{
162+ switch (state)
163+ {
164+ case mir_surface_state_hidden:
165+ case mir_surface_state_minimized:
166+ return false;
167+ default:
168+ break;
169+ }
170+ return true;
171+}
172+
173+struct SurfaceStateCase : SurfaceModifications, ::testing::WithParamInterface<StatePair> {};
174+struct SurfaceSpecStateCase : SurfaceModifications, ::testing::WithParamInterface<StatePair> {};
175 }
176
177 TEST_F(SurfaceModifications, surface_spec_name_is_notified)
178@@ -486,3 +511,74 @@
179 EXPECT_THAT(actual, Eq(expected_size));
180 };
181 }
182+
183+TEST_F(SurfaceModifications, surface_spec_state_affects_surface_visibility)
184+{
185+ auto const new_state = mir_surface_state_hidden;
186+
187+ EXPECT_CALL(surface_observer, hidden_set_to(true));
188+
189+ apply_changes([&](MirSurfaceSpec* spec)
190+ {
191+ mir_surface_spec_set_state(spec, new_state);
192+ });
193+}
194+
195+TEST_P(SurfaceSpecStateCase, set_state_affects_surface_visibility)
196+{
197+ auto const initial_state = GetParam().from;
198+ auto const new_state = GetParam().to;
199+
200+ EXPECT_CALL(surface_observer, hidden_set_to(is_visible(initial_state)));
201+ EXPECT_CALL(surface_observer, hidden_set_to(is_visible(new_state)));
202+
203+ apply_changes([&](MirSurfaceSpec* spec)
204+ {
205+ mir_surface_spec_set_state(spec, initial_state);
206+ });
207+
208+ apply_changes([&](MirSurfaceSpec* spec)
209+ {
210+ mir_surface_spec_set_state(spec, new_state);
211+ });
212+}
213+
214+INSTANTIATE_TEST_CASE_P(SurfaceModifications, SurfaceSpecStateCase,
215+ Values(
216+ StatePair{mir_surface_state_hidden, mir_surface_state_restored},
217+ StatePair{mir_surface_state_hidden, mir_surface_state_maximized},
218+ StatePair{mir_surface_state_hidden, mir_surface_state_vertmaximized},
219+ StatePair{mir_surface_state_hidden, mir_surface_state_horizmaximized},
220+ StatePair{mir_surface_state_hidden, mir_surface_state_fullscreen},
221+ StatePair{mir_surface_state_minimized, mir_surface_state_restored},
222+ StatePair{mir_surface_state_minimized, mir_surface_state_maximized},
223+ StatePair{mir_surface_state_minimized, mir_surface_state_vertmaximized},
224+ StatePair{mir_surface_state_minimized, mir_surface_state_horizmaximized},
225+ StatePair{mir_surface_state_minimized, mir_surface_state_fullscreen}
226+ ));
227+
228+TEST_P(SurfaceStateCase, set_state_affects_surface_visibility)
229+{
230+ auto const initial_state = GetParam().from;
231+ auto const new_state = GetParam().to;
232+
233+ EXPECT_CALL(surface_observer, hidden_set_to(is_visible(initial_state)));
234+ EXPECT_CALL(surface_observer, hidden_set_to(is_visible(new_state)));
235+
236+ mir_wait_for(mir_surface_set_state(surface, initial_state));
237+ mir_wait_for(mir_surface_set_state(surface, new_state));
238+}
239+
240+INSTANTIATE_TEST_CASE_P(SurfaceModifications, SurfaceStateCase,
241+ Values(
242+ StatePair{mir_surface_state_hidden, mir_surface_state_restored},
243+ StatePair{mir_surface_state_hidden, mir_surface_state_maximized},
244+ StatePair{mir_surface_state_hidden, mir_surface_state_vertmaximized},
245+ StatePair{mir_surface_state_hidden, mir_surface_state_horizmaximized},
246+ StatePair{mir_surface_state_hidden, mir_surface_state_fullscreen},
247+ StatePair{mir_surface_state_minimized, mir_surface_state_restored},
248+ StatePair{mir_surface_state_minimized, mir_surface_state_maximized},
249+ StatePair{mir_surface_state_minimized, mir_surface_state_vertmaximized},
250+ StatePair{mir_surface_state_minimized, mir_surface_state_horizmaximized},
251+ StatePair{mir_surface_state_minimized, mir_surface_state_fullscreen}
252+ ));

Subscribers

People subscribed via source and target branches